My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Sd2PinMap.h 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /* Arduino SdFat Library
  2. * Copyright (C) 2010 by William Greiman
  3. *
  4. * This file is part of the Arduino SdFat Library
  5. *
  6. * This Library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This Library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Arduino SdFat Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. // Warning this file was generated by a program.
  21. #include "Marlin.h"
  22. #ifdef SDSUPPORT
  23. #ifndef Sd2PinMap_h
  24. #define Sd2PinMap_h
  25. #include <avr/io.h>
  26. //------------------------------------------------------------------------------
  27. /** struct for mapping digital pins */
  28. struct pin_map_t {
  29. volatile uint8_t* ddr;
  30. volatile uint8_t* pin;
  31. volatile uint8_t* port;
  32. uint8_t bit;
  33. };
  34. //------------------------------------------------------------------------------
  35. #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Mega
  36. // Two Wire (aka I2C) ports
  37. uint8_t const SDA_PIN = 20; // D1
  38. uint8_t const SCL_PIN = 21; // D0
  39. #undef MOSI_PIN
  40. #undef MISO_PIN
  41. #undef SCK_PIN
  42. // SPI port
  43. uint8_t const SS_PIN = 53; // B0
  44. uint8_t const MOSI_PIN = 51; // B2
  45. uint8_t const MISO_PIN = 50; // B3
  46. uint8_t const SCK_PIN = 52; // B1
  47. static const pin_map_t digitalPinMap[] = {
  48. {&DDRE, &PINE, &PORTE, 0}, // E0 0
  49. {&DDRE, &PINE, &PORTE, 1}, // E1 1
  50. {&DDRE, &PINE, &PORTE, 4}, // E4 2
  51. {&DDRE, &PINE, &PORTE, 5}, // E5 3
  52. {&DDRG, &PING, &PORTG, 5}, // G5 4
  53. {&DDRE, &PINE, &PORTE, 3}, // E3 5
  54. {&DDRH, &PINH, &PORTH, 3}, // H3 6
  55. {&DDRH, &PINH, &PORTH, 4}, // H4 7
  56. {&DDRH, &PINH, &PORTH, 5}, // H5 8
  57. {&DDRH, &PINH, &PORTH, 6}, // H6 9
  58. {&DDRB, &PINB, &PORTB, 4}, // B4 10
  59. {&DDRB, &PINB, &PORTB, 5}, // B5 11
  60. {&DDRB, &PINB, &PORTB, 6}, // B6 12
  61. {&DDRB, &PINB, &PORTB, 7}, // B7 13
  62. {&DDRJ, &PINJ, &PORTJ, 1}, // J1 14
  63. {&DDRJ, &PINJ, &PORTJ, 0}, // J0 15
  64. {&DDRH, &PINH, &PORTH, 1}, // H1 16
  65. {&DDRH, &PINH, &PORTH, 0}, // H0 17
  66. {&DDRD, &PIND, &PORTD, 3}, // D3 18
  67. {&DDRD, &PIND, &PORTD, 2}, // D2 19
  68. {&DDRD, &PIND, &PORTD, 1}, // D1 20
  69. {&DDRD, &PIND, &PORTD, 0}, // D0 21
  70. {&DDRA, &PINA, &PORTA, 0}, // A0 22
  71. {&DDRA, &PINA, &PORTA, 1}, // A1 23
  72. {&DDRA, &PINA, &PORTA, 2}, // A2 24
  73. {&DDRA, &PINA, &PORTA, 3}, // A3 25
  74. {&DDRA, &PINA, &PORTA, 4}, // A4 26
  75. {&DDRA, &PINA, &PORTA, 5}, // A5 27
  76. {&DDRA, &PINA, &PORTA, 6}, // A6 28
  77. {&DDRA, &PINA, &PORTA, 7}, // A7 29
  78. {&DDRC, &PINC, &PORTC, 7}, // C7 30
  79. {&DDRC, &PINC, &PORTC, 6}, // C6 31
  80. {&DDRC, &PINC, &PORTC, 5}, // C5 32
  81. {&DDRC, &PINC, &PORTC, 4}, // C4 33
  82. {&DDRC, &PINC, &PORTC, 3}, // C3 34
  83. {&DDRC, &PINC, &PORTC, 2}, // C2 35
  84. {&DDRC, &PINC, &PORTC, 1}, // C1 36
  85. {&DDRC, &PINC, &PORTC, 0}, // C0 37
  86. {&DDRD, &PIND, &PORTD, 7}, // D7 38
  87. {&DDRG, &PING, &PORTG, 2}, // G2 39
  88. {&DDRG, &PING, &PORTG, 1}, // G1 40
  89. {&DDRG, &PING, &PORTG, 0}, // G0 41
  90. {&DDRL, &PINL, &PORTL, 7}, // L7 42
  91. {&DDRL, &PINL, &PORTL, 6}, // L6 43
  92. {&DDRL, &PINL, &PORTL, 5}, // L5 44
  93. {&DDRL, &PINL, &PORTL, 4}, // L4 45
  94. {&DDRL, &PINL, &PORTL, 3}, // L3 46
  95. {&DDRL, &PINL, &PORTL, 2}, // L2 47
  96. {&DDRL, &PINL, &PORTL, 1}, // L1 48
  97. {&DDRL, &PINL, &PORTL, 0}, // L0 49
  98. {&DDRB, &PINB, &PORTB, 3}, // B3 50
  99. {&DDRB, &PINB, &PORTB, 2}, // B2 51
  100. {&DDRB, &PINB, &PORTB, 1}, // B1 52
  101. {&DDRB, &PINB, &PORTB, 0}, // B0 53
  102. {&DDRF, &PINF, &PORTF, 0}, // F0 54
  103. {&DDRF, &PINF, &PORTF, 1}, // F1 55
  104. {&DDRF, &PINF, &PORTF, 2}, // F2 56
  105. {&DDRF, &PINF, &PORTF, 3}, // F3 57
  106. {&DDRF, &PINF, &PORTF, 4}, // F4 58
  107. {&DDRF, &PINF, &PORTF, 5}, // F5 59
  108. {&DDRF, &PINF, &PORTF, 6}, // F6 60
  109. {&DDRF, &PINF, &PORTF, 7}, // F7 61
  110. {&DDRK, &PINK, &PORTK, 0}, // K0 62
  111. {&DDRK, &PINK, &PORTK, 1}, // K1 63
  112. {&DDRK, &PINK, &PORTK, 2}, // K2 64
  113. {&DDRK, &PINK, &PORTK, 3}, // K3 65
  114. {&DDRK, &PINK, &PORTK, 4}, // K4 66
  115. {&DDRK, &PINK, &PORTK, 5}, // K5 67
  116. {&DDRK, &PINK, &PORTK, 6}, // K6 68
  117. {&DDRK, &PINK, &PORTK, 7} // K7 69
  118. };
  119. //------------------------------------------------------------------------------
  120. #elif defined(__AVR_ATmega644P__)\
  121. || defined(__AVR_ATmega644__)\
  122. || defined(__AVR_ATmega1284P__)
  123. // Sanguino
  124. // Two Wire (aka I2C) ports
  125. uint8_t const SDA_PIN = 17; // C1
  126. uint8_t const SCL_PIN = 18; // C2
  127. // SPI port
  128. uint8_t const SS_PIN = 4; // B4
  129. uint8_t const MOSI_PIN = 5; // B5
  130. uint8_t const MISO_PIN = 6; // B6
  131. uint8_t const SCK_PIN = 7; // B7
  132. static const pin_map_t digitalPinMap[] = {
  133. {&DDRB, &PINB, &PORTB, 0}, // B0 0
  134. {&DDRB, &PINB, &PORTB, 1}, // B1 1
  135. {&DDRB, &PINB, &PORTB, 2}, // B2 2
  136. {&DDRB, &PINB, &PORTB, 3}, // B3 3
  137. {&DDRB, &PINB, &PORTB, 4}, // B4 4
  138. {&DDRB, &PINB, &PORTB, 5}, // B5 5
  139. {&DDRB, &PINB, &PORTB, 6}, // B6 6
  140. {&DDRB, &PINB, &PORTB, 7}, // B7 7
  141. {&DDRD, &PIND, &PORTD, 0}, // D0 8
  142. {&DDRD, &PIND, &PORTD, 1}, // D1 9
  143. {&DDRD, &PIND, &PORTD, 2}, // D2 10
  144. {&DDRD, &PIND, &PORTD, 3}, // D3 11
  145. {&DDRD, &PIND, &PORTD, 4}, // D4 12
  146. {&DDRD, &PIND, &PORTD, 5}, // D5 13
  147. {&DDRD, &PIND, &PORTD, 6}, // D6 14
  148. {&DDRD, &PIND, &PORTD, 7}, // D7 15
  149. {&DDRC, &PINC, &PORTC, 0}, // C0 16
  150. {&DDRC, &PINC, &PORTC, 1}, // C1 17
  151. {&DDRC, &PINC, &PORTC, 2}, // C2 18
  152. {&DDRC, &PINC, &PORTC, 3}, // C3 19
  153. {&DDRC, &PINC, &PORTC, 4}, // C4 20
  154. {&DDRC, &PINC, &PORTC, 5}, // C5 21
  155. {&DDRC, &PINC, &PORTC, 6}, // C6 22
  156. {&DDRC, &PINC, &PORTC, 7}, // C7 23
  157. {&DDRA, &PINA, &PORTA, 7}, // A7 24
  158. {&DDRA, &PINA, &PORTA, 6}, // A6 25
  159. {&DDRA, &PINA, &PORTA, 5}, // A5 26
  160. {&DDRA, &PINA, &PORTA, 4}, // A4 27
  161. {&DDRA, &PINA, &PORTA, 3}, // A3 28
  162. {&DDRA, &PINA, &PORTA, 2}, // A2 29
  163. {&DDRA, &PINA, &PORTA, 1}, // A1 30
  164. {&DDRA, &PINA, &PORTA, 0} // A0 31
  165. };
  166. //------------------------------------------------------------------------------
  167. #elif defined(__AVR_ATmega32U4__)
  168. // Teensy 2.0
  169. // Two Wire (aka I2C) ports
  170. uint8_t const SDA_PIN = 6; // D1
  171. uint8_t const SCL_PIN = 5; // D0
  172. // SPI port
  173. uint8_t const SS_PIN = 0; // B0
  174. uint8_t const MOSI_PIN = 2; // B2
  175. uint8_t const MISO_PIN = 3; // B3
  176. uint8_t const SCK_PIN = 1; // B1
  177. static const pin_map_t digitalPinMap[] = {
  178. {&DDRB, &PINB, &PORTB, 0}, // B0 0
  179. {&DDRB, &PINB, &PORTB, 1}, // B1 1
  180. {&DDRB, &PINB, &PORTB, 2}, // B2 2
  181. {&DDRB, &PINB, &PORTB, 3}, // B3 3
  182. {&DDRB, &PINB, &PORTB, 7}, // B7 4
  183. {&DDRD, &PIND, &PORTD, 0}, // D0 5
  184. {&DDRD, &PIND, &PORTD, 1}, // D1 6
  185. {&DDRD, &PIND, &PORTD, 2}, // D2 7
  186. {&DDRD, &PIND, &PORTD, 3}, // D3 8
  187. {&DDRC, &PINC, &PORTC, 6}, // C6 9
  188. {&DDRC, &PINC, &PORTC, 7}, // C7 10
  189. {&DDRD, &PIND, &PORTD, 6}, // D6 11
  190. {&DDRD, &PIND, &PORTD, 7}, // D7 12
  191. {&DDRB, &PINB, &PORTB, 4}, // B4 13
  192. {&DDRB, &PINB, &PORTB, 5}, // B5 14
  193. {&DDRB, &PINB, &PORTB, 6}, // B6 15
  194. {&DDRF, &PINF, &PORTF, 7}, // F7 16
  195. {&DDRF, &PINF, &PORTF, 6}, // F6 17
  196. {&DDRF, &PINF, &PORTF, 5}, // F5 18
  197. {&DDRF, &PINF, &PORTF, 4}, // F4 19
  198. {&DDRF, &PINF, &PORTF, 1}, // F1 20
  199. {&DDRF, &PINF, &PORTF, 0}, // F0 21
  200. {&DDRD, &PIND, &PORTD, 4}, // D4 22
  201. {&DDRD, &PIND, &PORTD, 5}, // D5 23
  202. {&DDRE, &PINE, &PORTE, 6} // E6 24
  203. };
  204. //------------------------------------------------------------------------------
  205. #elif defined(__AVR_AT90USB646__)\
  206. || defined(__AVR_AT90USB1286__)
  207. // Teensy++ 1.0 & 2.0
  208. // Two Wire (aka I2C) ports
  209. uint8_t const SDA_PIN = 1; // D1
  210. uint8_t const SCL_PIN = 0; // D0
  211. // SPI port
  212. uint8_t const SS_PIN = 20; // B0
  213. uint8_t const MOSI_PIN = 22; // B2
  214. uint8_t const MISO_PIN = 23; // B3
  215. uint8_t const SCK_PIN = 21; // B1
  216. static const pin_map_t digitalPinMap[] = {
  217. {&DDRD, &PIND, &PORTD, 0}, // D0 0
  218. {&DDRD, &PIND, &PORTD, 1}, // D1 1
  219. {&DDRD, &PIND, &PORTD, 2}, // D2 2
  220. {&DDRD, &PIND, &PORTD, 3}, // D3 3
  221. {&DDRD, &PIND, &PORTD, 4}, // D4 4
  222. {&DDRD, &PIND, &PORTD, 5}, // D5 5
  223. {&DDRD, &PIND, &PORTD, 6}, // D6 6
  224. {&DDRD, &PIND, &PORTD, 7}, // D7 7
  225. {&DDRE, &PINE, &PORTE, 0}, // E0 8
  226. {&DDRE, &PINE, &PORTE, 1}, // E1 9
  227. {&DDRC, &PINC, &PORTC, 0}, // C0 10
  228. {&DDRC, &PINC, &PORTC, 1}, // C1 11
  229. {&DDRC, &PINC, &PORTC, 2}, // C2 12
  230. {&DDRC, &PINC, &PORTC, 3}, // C3 13
  231. {&DDRC, &PINC, &PORTC, 4}, // C4 14
  232. {&DDRC, &PINC, &PORTC, 5}, // C5 15
  233. {&DDRC, &PINC, &PORTC, 6}, // C6 16
  234. {&DDRC, &PINC, &PORTC, 7}, // C7 17
  235. {&DDRE, &PINE, &PORTE, 6}, // E6 18
  236. {&DDRE, &PINE, &PORTE, 7}, // E7 19
  237. {&DDRB, &PINB, &PORTB, 0}, // B0 20
  238. {&DDRB, &PINB, &PORTB, 1}, // B1 21
  239. {&DDRB, &PINB, &PORTB, 2}, // B2 22
  240. {&DDRB, &PINB, &PORTB, 3}, // B3 23
  241. {&DDRB, &PINB, &PORTB, 4}, // B4 24
  242. {&DDRB, &PINB, &PORTB, 5}, // B5 25
  243. {&DDRB, &PINB, &PORTB, 6}, // B6 26
  244. {&DDRB, &PINB, &PORTB, 7}, // B7 27
  245. {&DDRA, &PINA, &PORTA, 0}, // A0 28
  246. {&DDRA, &PINA, &PORTA, 1}, // A1 29
  247. {&DDRA, &PINA, &PORTA, 2}, // A2 30
  248. {&DDRA, &PINA, &PORTA, 3}, // A3 31
  249. {&DDRA, &PINA, &PORTA, 4}, // A4 32
  250. {&DDRA, &PINA, &PORTA, 5}, // A5 33
  251. {&DDRA, &PINA, &PORTA, 6}, // A6 34
  252. {&DDRA, &PINA, &PORTA, 7}, // A7 35
  253. {&DDRE, &PINE, &PORTE, 4}, // E4 36
  254. {&DDRE, &PINE, &PORTE, 5}, // E5 37
  255. {&DDRF, &PINF, &PORTF, 0}, // F0 38
  256. {&DDRF, &PINF, &PORTF, 1}, // F1 39
  257. {&DDRF, &PINF, &PORTF, 2}, // F2 40
  258. {&DDRF, &PINF, &PORTF, 3}, // F3 41
  259. {&DDRF, &PINF, &PORTF, 4}, // F4 42
  260. {&DDRF, &PINF, &PORTF, 5}, // F5 43
  261. {&DDRF, &PINF, &PORTF, 6}, // F6 44
  262. {&DDRF, &PINF, &PORTF, 7} // F7 45
  263. };
  264. //------------------------------------------------------------------------------
  265. #elif defined(__AVR_ATmega168__)\
  266. ||defined(__AVR_ATmega168P__)\
  267. ||defined(__AVR_ATmega328P__)
  268. // 168 and 328 Arduinos
  269. // Two Wire (aka I2C) ports
  270. uint8_t const SDA_PIN = 18; // C4
  271. uint8_t const SCL_PIN = 19; // C5
  272. // SPI port
  273. uint8_t const SS_PIN = 10; // B2
  274. uint8_t const MOSI_PIN = 11; // B3
  275. uint8_t const MISO_PIN = 12; // B4
  276. uint8_t const SCK_PIN = 13; // B5
  277. static const pin_map_t digitalPinMap[] = {
  278. {&DDRD, &PIND, &PORTD, 0}, // D0 0
  279. {&DDRD, &PIND, &PORTD, 1}, // D1 1
  280. {&DDRD, &PIND, &PORTD, 2}, // D2 2
  281. {&DDRD, &PIND, &PORTD, 3}, // D3 3
  282. {&DDRD, &PIND, &PORTD, 4}, // D4 4
  283. {&DDRD, &PIND, &PORTD, 5}, // D5 5
  284. {&DDRD, &PIND, &PORTD, 6}, // D6 6
  285. {&DDRD, &PIND, &PORTD, 7}, // D7 7
  286. {&DDRB, &PINB, &PORTB, 0}, // B0 8
  287. {&DDRB, &PINB, &PORTB, 1}, // B1 9
  288. {&DDRB, &PINB, &PORTB, 2}, // B2 10
  289. {&DDRB, &PINB, &PORTB, 3}, // B3 11
  290. {&DDRB, &PINB, &PORTB, 4}, // B4 12
  291. {&DDRB, &PINB, &PORTB, 5}, // B5 13
  292. {&DDRC, &PINC, &PORTC, 0}, // C0 14
  293. {&DDRC, &PINC, &PORTC, 1}, // C1 15
  294. {&DDRC, &PINC, &PORTC, 2}, // C2 16
  295. {&DDRC, &PINC, &PORTC, 3}, // C3 17
  296. {&DDRC, &PINC, &PORTC, 4}, // C4 18
  297. {&DDRC, &PINC, &PORTC, 5} // C5 19
  298. };
  299. #elif defined(__AVR_ATmega1281__)
  300. // Waspmote
  301. // Two Wire (aka I2C) ports
  302. uint8_t const SDA_PIN = 41;
  303. uint8_t const SCL_PIN = 40;
  304. #undef MOSI_PIN
  305. #undef MISO_PIN
  306. // SPI port
  307. uint8_t const SS_PIN = 16; // B0
  308. uint8_t const MOSI_PIN = 11; // B2
  309. uint8_t const MISO_PIN = 12; // B3
  310. uint8_t const SCK_PIN = 10; // B1
  311. static const pin_map_t digitalPinMap[] = {
  312. {&DDRE, &PINE, &PORTE, 0}, // E0 0
  313. {&DDRE, &PINE, &PORTE, 1}, // E1 1
  314. {&DDRE, &PINE, &PORTE, 3}, // E3 2
  315. {&DDRE, &PINE, &PORTE, 4}, // E4 3
  316. {&DDRC, &PINC, &PORTC, 4}, // C4 4
  317. {&DDRC, &PINC, &PORTC, 5}, // C5 5
  318. {&DDRC, &PINC, &PORTC, 6}, // C6 6
  319. {&DDRC, &PINC, &PORTC, 7}, // C7 7
  320. {&DDRA, &PINA, &PORTA, 2}, // A2 8
  321. {&DDRA, &PINA, &PORTA, 3}, // A3 9
  322. {&DDRA, &PINA, &PORTA, 4}, // A4 10
  323. {&DDRD, &PIND, &PORTD, 5}, // D5 11
  324. {&DDRD, &PIND, &PORTD, 6}, // D6 12
  325. {&DDRC, &PINC, &PORTC, 1}, // C1 13
  326. {&DDRF, &PINF, &PORTF, 1}, // F1 14
  327. {&DDRF, &PINF, &PORTF, 2}, // F2 15
  328. {&DDRF, &PINF, &PORTF, 3}, // F3 16
  329. {&DDRF, &PINF, &PORTF, 4}, // F4 17
  330. {&DDRF, &PINF, &PORTF, 5}, // F5 18
  331. {&DDRF, &PINF, &PORTF, 6}, // F6 19
  332. {&DDRF, &PINF, &PORTF, 7}, // F7 20
  333. {&DDRF, &PINF, &PORTF, 0}, // F0 21
  334. {&DDRA, &PINA, &PORTA, 1}, // A1 22
  335. {&DDRD, &PIND, &PORTD, 7}, // D7 23
  336. {&DDRE, &PINE, &PORTE, 5}, // E5 24
  337. {&DDRA, &PINA, &PORTA, 6}, // A6 25
  338. {&DDRE, &PINE, &PORTE, 2}, // E2 26
  339. {&DDRA, &PINA, &PORTA, 5}, // A5 27
  340. {&DDRC, &PINC, &PORTC, 0}, // C0 28
  341. {&DDRB, &PINB, &PORTB, 0}, // B0 29
  342. {&DDRB, &PINB, &PORTB, 1}, // B1 30
  343. {&DDRB, &PINB, &PORTB, 2}, // B2 31
  344. {&DDRB, &PINB, &PORTB, 3}, // B3 32
  345. {&DDRB, &PINB, &PORTB, 4}, // B4 33
  346. {&DDRB, &PINB, &PORTB, 5}, // B5 34
  347. {&DDRA, &PINA, &PORTA, 0}, // A0 35
  348. {&DDRB, &PINB, &PORTB, 6}, // B6 36
  349. {&DDRB, &PINB, &PORTB, 7}, // B7 37
  350. {&DDRE, &PINE, &PORTE, 6}, // E6 38
  351. {&DDRE, &PINE, &PORTE, 7}, // E7 39
  352. {&DDRD, &PIND, &PORTD, 0}, // D0 40
  353. {&DDRD, &PIND, &PORTD, 1}, // D1 41
  354. {&DDRC, &PINC, &PORTC, 3}, // C3 42
  355. {&DDRD, &PIND, &PORTD, 2}, // D2 43
  356. {&DDRD, &PIND, &PORTD, 3}, // D3 44
  357. {&DDRA, &PINA, &PORTA, 7}, // A7 45
  358. {&DDRC, &PINC, &PORTC, 2}, // C2 46
  359. {&DDRD, &PIND, &PORTD, 4}, // D4 47
  360. {&DDRG, &PING, &PORTG, 2}, // G2 48
  361. {&DDRG, &PING, &PORTG, 1}, // G1 49
  362. {&DDRG, &PING, &PORTG, 0}, // G0 50
  363. };
  364. #else // defined(__AVR_ATmega1280__)
  365. #error unknown chip
  366. #endif // defined(__AVR_ATmega1280__)
  367. //------------------------------------------------------------------------------
  368. static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t);
  369. uint8_t badPinNumber(void)
  370. __attribute__((error("Pin number is too large or not a constant")));
  371. static inline __attribute__((always_inline))
  372. bool getPinMode(uint8_t pin) {
  373. if (__builtin_constant_p(pin) && pin < digitalPinCount) {
  374. return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
  375. } else {
  376. return badPinNumber();
  377. }
  378. }
  379. static inline __attribute__((always_inline))
  380. void setPinMode(uint8_t pin, uint8_t mode) {
  381. if (__builtin_constant_p(pin) && pin < digitalPinCount) {
  382. if (mode) {
  383. *digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit);
  384. } else {
  385. *digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit);
  386. }
  387. } else {
  388. badPinNumber();
  389. }
  390. }
  391. static inline __attribute__((always_inline))
  392. bool fastDigitalRead(uint8_t pin) {
  393. if (__builtin_constant_p(pin) && pin < digitalPinCount) {
  394. return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
  395. } else {
  396. return badPinNumber();
  397. }
  398. }
  399. static inline __attribute__((always_inline))
  400. void fastDigitalWrite(uint8_t pin, uint8_t value) {
  401. if (__builtin_constant_p(pin) && pin < digitalPinCount) {
  402. if (value) {
  403. *digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit);
  404. } else {
  405. *digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit);
  406. }
  407. } else {
  408. badPinNumber();
  409. }
  410. }
  411. #endif // Sd2PinMap_h
  412. #endif