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

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