Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

pins_arduino.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /*
  2. pins_arduino.h - Pin definition functions for Arduino
  3. Part of Arduino - http://www.arduino.cc/
  4. Copyright (c) 2007 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: wiring.h 249 2007-02-03 16:52:51Z mellis $
  18. */
  19. #ifndef Pins_Arduino_h
  20. #define Pins_Arduino_h
  21. #include <avr/pgmspace.h>
  22. #define NUM_DIGITAL_PINS 70
  23. #define NUM_ANALOG_INPUTS 16
  24. #define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1)
  25. #define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
  26. static const uint8_t SS = 53;
  27. static const uint8_t MOSI = 51;
  28. static const uint8_t MISO = 50;
  29. static const uint8_t SCK = 52;
  30. static const uint8_t SDA = 20;
  31. static const uint8_t SCL = 21;
  32. static const uint8_t LED_BUILTIN = 13;
  33. static const uint8_t A0 = 54;
  34. static const uint8_t A1 = 55;
  35. static const uint8_t A2 = 56;
  36. static const uint8_t A3 = 57;
  37. static const uint8_t A4 = 58;
  38. static const uint8_t A5 = 59;
  39. static const uint8_t A6 = 60;
  40. static const uint8_t A7 = 61;
  41. static const uint8_t A8 = 62;
  42. static const uint8_t A9 = 63;
  43. static const uint8_t A10 = 64;
  44. static const uint8_t A11 = 65;
  45. static const uint8_t A12 = 66;
  46. static const uint8_t A13 = 67;
  47. static const uint8_t A14 = 68;
  48. static const uint8_t A15 = 69;
  49. // A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
  50. // Only pins available for RECEIVE (TRANSMIT can be on any pin):
  51. // (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
  52. // Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
  53. #define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \
  54. (((p) >= 50) && ((p) <= 53)) || \
  55. (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
  56. #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
  57. ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
  58. 0 ) )
  59. #define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
  60. ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
  61. ((uint8_t *)0) ) )
  62. #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
  63. ( ((p) == 50) ? 3 : \
  64. ( ((p) == 51) ? 2 : \
  65. ( ((p) == 52) ? 1 : \
  66. ( ((p) == 53) ? 0 : \
  67. ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
  68. 0 ) ) ) ) ) )
  69. #ifdef ARDUINO_MAIN
  70. const uint16_t PROGMEM port_to_mode_PGM[] = {
  71. NOT_A_PORT,
  72. (uint16_t) &DDRA,
  73. (uint16_t) &DDRB,
  74. (uint16_t) &DDRC,
  75. (uint16_t) &DDRD,
  76. (uint16_t) &DDRE,
  77. (uint16_t) &DDRF,
  78. (uint16_t) &DDRG,
  79. (uint16_t) &DDRH,
  80. NOT_A_PORT,
  81. (uint16_t) &DDRJ,
  82. (uint16_t) &DDRK,
  83. (uint16_t) &DDRL,
  84. };
  85. const uint16_t PROGMEM port_to_output_PGM[] = {
  86. NOT_A_PORT,
  87. (uint16_t) &PORTA,
  88. (uint16_t) &PORTB,
  89. (uint16_t) &PORTC,
  90. (uint16_t) &PORTD,
  91. (uint16_t) &PORTE,
  92. (uint16_t) &PORTF,
  93. (uint16_t) &PORTG,
  94. (uint16_t) &PORTH,
  95. NOT_A_PORT,
  96. (uint16_t) &PORTJ,
  97. (uint16_t) &PORTK,
  98. (uint16_t) &PORTL,
  99. };
  100. const uint16_t PROGMEM port_to_input_PGM[] = {
  101. NOT_A_PIN,
  102. (uint16_t) &PINA,
  103. (uint16_t) &PINB,
  104. (uint16_t) &PINC,
  105. (uint16_t) &PIND,
  106. (uint16_t) &PINE,
  107. (uint16_t) &PINF,
  108. (uint16_t) &PING,
  109. (uint16_t) &PINH,
  110. NOT_A_PIN,
  111. (uint16_t) &PINJ,
  112. (uint16_t) &PINK,
  113. (uint16_t) &PINL,
  114. };
  115. const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
  116. // PORTLIST
  117. // -------------------------------------------
  118. PE , // PE 0 ** 0 ** USART0_RX
  119. PE , // PE 1 ** 1 ** USART0_TX
  120. PE , // PE 4 ** 2 ** PWM2
  121. PE , // PE 5 ** 3 ** PWM3
  122. PG , // PG 5 ** 4 ** PWM4
  123. PE , // PE 3 ** 5 ** PWM5
  124. PH , // PH 3 ** 6 ** PWM6
  125. PH , // PH 4 ** 7 ** PWM7
  126. PH , // PH 5 ** 8 ** PWM8
  127. PH , // PH 6 ** 9 ** PWM9
  128. PB , // PB 4 ** 10 ** PWM10
  129. PB , // PB 5 ** 11 ** PWM11
  130. PB , // PB 6 ** 12 ** PWM12
  131. PB , // PB 7 ** 13 ** PWM13
  132. PJ , // PJ 1 ** 14 ** USART3_TX
  133. PJ , // PJ 0 ** 15 ** USART3_RX
  134. PH , // PH 1 ** 16 ** USART2_TX
  135. PH , // PH 0 ** 17 ** USART2_RX
  136. PD , // PD 3 ** 18 ** USART1_TX
  137. PD , // PD 2 ** 19 ** USART1_RX
  138. PD , // PD 1 ** 20 ** I2C_SDA
  139. PD , // PD 0 ** 21 ** I2C_SCL
  140. PA , // PA 0 ** 22 ** D22
  141. PA , // PA 1 ** 23 ** D23
  142. PA , // PA 2 ** 24 ** D24
  143. PA , // PA 3 ** 25 ** D25
  144. PA , // PA 4 ** 26 ** D26
  145. PA , // PA 5 ** 27 ** D27
  146. PA , // PA 6 ** 28 ** D28
  147. PA , // PA 7 ** 29 ** D29
  148. PC , // PC 7 ** 30 ** D30
  149. PC , // PC 6 ** 31 ** D31
  150. PC , // PC 5 ** 32 ** D32
  151. PC , // PC 4 ** 33 ** D33
  152. PC , // PC 3 ** 34 ** D34
  153. PC , // PC 2 ** 35 ** D35
  154. PC , // PC 1 ** 36 ** D36
  155. PC , // PC 0 ** 37 ** D37
  156. PD , // PD 7 ** 38 ** D38
  157. PG , // PG 2 ** 39 ** D39
  158. PG , // PG 1 ** 40 ** D40
  159. PG , // PG 0 ** 41 ** D41
  160. PL , // PL 7 ** 42 ** D42
  161. PL , // PL 6 ** 43 ** D43
  162. PL , // PL 5 ** 44 ** D44
  163. PL , // PL 4 ** 45 ** D45
  164. PL , // PL 3 ** 46 ** D46
  165. PL , // PL 2 ** 47 ** D47
  166. PL , // PL 1 ** 48 ** D48
  167. PL , // PL 0 ** 49 ** D49
  168. PB , // PB 3 ** 50 ** SPI_MISO
  169. PB , // PB 2 ** 51 ** SPI_MOSI
  170. PB , // PB 1 ** 52 ** SPI_SCK
  171. PB , // PB 0 ** 53 ** SPI_SS
  172. PF , // PF 0 ** 54 ** A0
  173. PF , // PF 1 ** 55 ** A1
  174. PF , // PF 2 ** 56 ** A2
  175. PF , // PF 3 ** 57 ** A3
  176. PF , // PF 4 ** 58 ** A4
  177. PF , // PF 5 ** 59 ** A5
  178. PF , // PF 6 ** 60 ** A6
  179. PF , // PF 7 ** 61 ** A7
  180. PK , // PK 0 ** 62 ** A8
  181. PK , // PK 1 ** 63 ** A9
  182. PK , // PK 2 ** 64 ** A10
  183. PK , // PK 3 ** 65 ** A11
  184. PK , // PK 4 ** 66 ** A12
  185. PK , // PK 5 ** 67 ** A13
  186. PK , // PK 6 ** 68 ** A14
  187. PK , // PK 7 ** 69 ** A15
  188. };
  189. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
  190. // PIN IN PORT
  191. // -------------------------------------------
  192. _BV( 0 ) , // PE 0 ** 0 ** USART0_RX
  193. _BV( 1 ) , // PE 1 ** 1 ** USART0_TX
  194. _BV( 4 ) , // PE 4 ** 2 ** PWM2
  195. _BV( 5 ) , // PE 5 ** 3 ** PWM3
  196. _BV( 5 ) , // PG 5 ** 4 ** PWM4
  197. _BV( 3 ) , // PE 3 ** 5 ** PWM5
  198. _BV( 3 ) , // PH 3 ** 6 ** PWM6
  199. _BV( 4 ) , // PH 4 ** 7 ** PWM7
  200. _BV( 5 ) , // PH 5 ** 8 ** PWM8
  201. _BV( 6 ) , // PH 6 ** 9 ** PWM9
  202. _BV( 4 ) , // PB 4 ** 10 ** PWM10
  203. _BV( 5 ) , // PB 5 ** 11 ** PWM11
  204. _BV( 6 ) , // PB 6 ** 12 ** PWM12
  205. _BV( 7 ) , // PB 7 ** 13 ** PWM13
  206. _BV( 1 ) , // PJ 1 ** 14 ** USART3_TX
  207. _BV( 0 ) , // PJ 0 ** 15 ** USART3_RX
  208. _BV( 1 ) , // PH 1 ** 16 ** USART2_TX
  209. _BV( 0 ) , // PH 0 ** 17 ** USART2_RX
  210. _BV( 3 ) , // PD 3 ** 18 ** USART1_TX
  211. _BV( 2 ) , // PD 2 ** 19 ** USART1_RX
  212. _BV( 1 ) , // PD 1 ** 20 ** I2C_SDA
  213. _BV( 0 ) , // PD 0 ** 21 ** I2C_SCL
  214. _BV( 0 ) , // PA 0 ** 22 ** D22
  215. _BV( 1 ) , // PA 1 ** 23 ** D23
  216. _BV( 2 ) , // PA 2 ** 24 ** D24
  217. _BV( 3 ) , // PA 3 ** 25 ** D25
  218. _BV( 4 ) , // PA 4 ** 26 ** D26
  219. _BV( 5 ) , // PA 5 ** 27 ** D27
  220. _BV( 6 ) , // PA 6 ** 28 ** D28
  221. _BV( 7 ) , // PA 7 ** 29 ** D29
  222. _BV( 7 ) , // PC 7 ** 30 ** D30
  223. _BV( 6 ) , // PC 6 ** 31 ** D31
  224. _BV( 5 ) , // PC 5 ** 32 ** D32
  225. _BV( 4 ) , // PC 4 ** 33 ** D33
  226. _BV( 3 ) , // PC 3 ** 34 ** D34
  227. _BV( 2 ) , // PC 2 ** 35 ** D35
  228. _BV( 1 ) , // PC 1 ** 36 ** D36
  229. _BV( 0 ) , // PC 0 ** 37 ** D37
  230. _BV( 7 ) , // PD 7 ** 38 ** D38
  231. _BV( 2 ) , // PG 2 ** 39 ** D39
  232. _BV( 1 ) , // PG 1 ** 40 ** D40
  233. _BV( 0 ) , // PG 0 ** 41 ** D41
  234. _BV( 7 ) , // PL 7 ** 42 ** D42
  235. _BV( 6 ) , // PL 6 ** 43 ** D43
  236. _BV( 5 ) , // PL 5 ** 44 ** D44
  237. _BV( 4 ) , // PL 4 ** 45 ** D45
  238. _BV( 3 ) , // PL 3 ** 46 ** D46
  239. _BV( 2 ) , // PL 2 ** 47 ** D47
  240. _BV( 1 ) , // PL 1 ** 48 ** D48
  241. _BV( 0 ) , // PL 0 ** 49 ** D49
  242. _BV( 3 ) , // PB 3 ** 50 ** SPI_MISO
  243. _BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI
  244. _BV( 1 ) , // PB 1 ** 52 ** SPI_SCK
  245. _BV( 0 ) , // PB 0 ** 53 ** SPI_SS
  246. _BV( 0 ) , // PF 0 ** 54 ** A0
  247. _BV( 1 ) , // PF 1 ** 55 ** A1
  248. _BV( 2 ) , // PF 2 ** 56 ** A2
  249. _BV( 3 ) , // PF 3 ** 57 ** A3
  250. _BV( 4 ) , // PF 4 ** 58 ** A4
  251. _BV( 5 ) , // PF 5 ** 59 ** A5
  252. _BV( 6 ) , // PF 6 ** 60 ** A6
  253. _BV( 7 ) , // PF 7 ** 61 ** A7
  254. _BV( 0 ) , // PK 0 ** 62 ** A8
  255. _BV( 1 ) , // PK 1 ** 63 ** A9
  256. _BV( 2 ) , // PK 2 ** 64 ** A10
  257. _BV( 3 ) , // PK 3 ** 65 ** A11
  258. _BV( 4 ) , // PK 4 ** 66 ** A12
  259. _BV( 5 ) , // PK 5 ** 67 ** A13
  260. _BV( 6 ) , // PK 6 ** 68 ** A14
  261. _BV( 7 ) , // PK 7 ** 69 ** A15
  262. };
  263. const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
  264. // TIMERS
  265. // -------------------------------------------
  266. NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
  267. NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
  268. TIMER3B , // PE 4 ** 2 ** PWM2
  269. TIMER3C , // PE 5 ** 3 ** PWM3
  270. TIMER0B , // PG 5 ** 4 ** PWM4
  271. TIMER3A , // PE 3 ** 5 ** PWM5
  272. TIMER4A , // PH 3 ** 6 ** PWM6
  273. TIMER4B , // PH 4 ** 7 ** PWM7
  274. TIMER4C , // PH 5 ** 8 ** PWM8
  275. TIMER2B , // PH 6 ** 9 ** PWM9
  276. TIMER2A , // PB 4 ** 10 ** PWM10
  277. TIMER1A , // PB 5 ** 11 ** PWM11
  278. TIMER1B , // PB 6 ** 12 ** PWM12
  279. TIMER0A , // PB 7 ** 13 ** PWM13
  280. NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX
  281. NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX
  282. NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX
  283. NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX
  284. NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX
  285. NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX
  286. NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA
  287. NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL
  288. NOT_ON_TIMER , // PA 0 ** 22 ** D22
  289. NOT_ON_TIMER , // PA 1 ** 23 ** D23
  290. NOT_ON_TIMER , // PA 2 ** 24 ** D24
  291. NOT_ON_TIMER , // PA 3 ** 25 ** D25
  292. NOT_ON_TIMER , // PA 4 ** 26 ** D26
  293. NOT_ON_TIMER , // PA 5 ** 27 ** D27
  294. NOT_ON_TIMER , // PA 6 ** 28 ** D28
  295. NOT_ON_TIMER , // PA 7 ** 29 ** D29
  296. NOT_ON_TIMER , // PC 7 ** 30 ** D30
  297. NOT_ON_TIMER , // PC 6 ** 31 ** D31
  298. NOT_ON_TIMER , // PC 5 ** 32 ** D32
  299. NOT_ON_TIMER , // PC 4 ** 33 ** D33
  300. NOT_ON_TIMER , // PC 3 ** 34 ** D34
  301. NOT_ON_TIMER , // PC 2 ** 35 ** D35
  302. NOT_ON_TIMER , // PC 1 ** 36 ** D36
  303. NOT_ON_TIMER , // PC 0 ** 37 ** D37
  304. NOT_ON_TIMER , // PD 7 ** 38 ** D38
  305. NOT_ON_TIMER , // PG 2 ** 39 ** D39
  306. NOT_ON_TIMER , // PG 1 ** 40 ** D40
  307. NOT_ON_TIMER , // PG 0 ** 41 ** D41
  308. NOT_ON_TIMER , // PL 7 ** 42 ** D42
  309. NOT_ON_TIMER , // PL 6 ** 43 ** D43
  310. TIMER5C , // PL 5 ** 44 ** D44
  311. TIMER5B , // PL 4 ** 45 ** D45
  312. TIMER5A , // PL 3 ** 46 ** D46
  313. NOT_ON_TIMER , // PL 2 ** 47 ** D47
  314. NOT_ON_TIMER , // PL 1 ** 48 ** D48
  315. NOT_ON_TIMER , // PL 0 ** 49 ** D49
  316. NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO
  317. NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI
  318. NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK
  319. NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS
  320. NOT_ON_TIMER , // PF 0 ** 54 ** A0
  321. NOT_ON_TIMER , // PF 1 ** 55 ** A1
  322. NOT_ON_TIMER , // PF 2 ** 56 ** A2
  323. NOT_ON_TIMER , // PF 3 ** 57 ** A3
  324. NOT_ON_TIMER , // PF 4 ** 58 ** A4
  325. NOT_ON_TIMER , // PF 5 ** 59 ** A5
  326. NOT_ON_TIMER , // PF 6 ** 60 ** A6
  327. NOT_ON_TIMER , // PF 7 ** 61 ** A7
  328. NOT_ON_TIMER , // PK 0 ** 62 ** A8
  329. NOT_ON_TIMER , // PK 1 ** 63 ** A9
  330. NOT_ON_TIMER , // PK 2 ** 64 ** A10
  331. NOT_ON_TIMER , // PK 3 ** 65 ** A11
  332. NOT_ON_TIMER , // PK 4 ** 66 ** A12
  333. NOT_ON_TIMER , // PK 5 ** 67 ** A13
  334. NOT_ON_TIMER , // PK 6 ** 68 ** A14
  335. NOT_ON_TIMER , // PK 7 ** 69 ** A15
  336. };
  337. #endif
  338. #endif