My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Sd2PinMap.h 15KB

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