pins_arduino.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. pins_arduino.c - pin definitions for the Arduino board
  3. Part of Arduino / Wiring Lite
  4. Copyright (c) 2005 David A. Mellis
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General
  14. Public License along with this library; if not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. $Id: pins_arduino.c 522 2008-11-01 22:06:13Z mellis $
  18. */
  19. #include <avr/io.h>
  20. #include "wiring_private.h"
  21. #include "pins_arduino.h"
  22. // On the Arduino board, digital pins are also used
  23. // for the analog output (software PWM). Analog input
  24. // pins are a separate set.
  25. // Luminet board
  26. // * *
  27. // D0 D1
  28. // VCC PA7 PB2 GND
  29. // | | | |
  30. // | | | |
  31. // VCC--- ---VCC
  32. //D7 PA3--- ---PB1 D2
  33. //D6 PA2--- ---PB0 D3
  34. // GND--- ---GND
  35. // | | | |
  36. // | | | |
  37. // VCC PA1 PA0 GND
  38. // D5 D4
  39. //
  40. // red led: PA4 (d8) -- pin available if jumper is not connected
  41. // green led: * PA5 (d9) -- pin available if jumper is not connected
  42. // blue led: * PA6 (d10) -- pin available if jumper is not connected
  43. // reset: PB3 (d11)
  44. //
  45. // * indicates the PWM pins on the attiny84
  46. #define PA 2
  47. #define PB 3
  48. // these arrays map port names (e.g. port B) to the
  49. // appropriate addresses for various functions (e.g. reading
  50. // and writing)
  51. const uint8_t PROGMEM port_to_mode_PGM[] = {
  52. NOT_A_PORT,
  53. NOT_A_PORT,
  54. &DDRA,
  55. &DDRB,
  56. };
  57. const uint8_t PROGMEM port_to_output_PGM[] = {
  58. NOT_A_PORT,
  59. NOT_A_PORT,
  60. &PORTA,
  61. &PORTB,
  62. };
  63. const uint8_t PROGMEM port_to_input_PGM[] = {
  64. NOT_A_PORT,
  65. NOT_A_PORT,
  66. &PINA,
  67. &PINB,
  68. };
  69. const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
  70. PA, /* 0 */
  71. PB,
  72. PB,
  73. PB,
  74. PA,
  75. PA,
  76. PA,
  77. PA,
  78. PA, /* 8 */
  79. PA,
  80. PA,
  81. PB,
  82. PA,
  83. PA,
  84. PA, /* 14 */
  85. PA,
  86. PA,
  87. PA,
  88. PA,
  89. PA,
  90. };
  91. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
  92. _BV(7), /* 0, port D */
  93. _BV(2),
  94. _BV(1),
  95. _BV(0),
  96. _BV(0),
  97. _BV(1),
  98. _BV(2),
  99. _BV(3),
  100. _BV(4), /* 8 */
  101. _BV(5),
  102. _BV(6),
  103. _BV(3),
  104. _BV(4),
  105. _BV(6),
  106. _BV(0), /* 14 */
  107. _BV(1),
  108. _BV(2),
  109. _BV(3),
  110. _BV(4),
  111. _BV(5),
  112. };
  113. const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
  114. NOT_ON_TIMER, /* 0 - port D */
  115. NOT_ON_TIMER,
  116. NOT_ON_TIMER,
  117. NOT_ON_TIMER,
  118. NOT_ON_TIMER,
  119. NOT_ON_TIMER,
  120. NOT_ON_TIMER,
  121. NOT_ON_TIMER,
  122. NOT_ON_TIMER, /* 8 - port B */
  123. NOT_ON_TIMER,
  124. NOT_ON_TIMER,
  125. NOT_ON_TIMER,
  126. NOT_ON_TIMER,
  127. NOT_ON_TIMER,
  128. NOT_ON_TIMER, /* 14 - port C */
  129. NOT_ON_TIMER,
  130. NOT_ON_TIMER,
  131. NOT_ON_TIMER,
  132. NOT_ON_TIMER,
  133. };