PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

fastpin_avr.h 14KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. #ifndef __INC_FASTPIN_AVR_H
  2. #define __INC_FASTPIN_AVR_H
  3. FASTLED_NAMESPACE_BEGIN
  4. #if defined(FASTLED_FORCE_SOFTWARE_PINS)
  5. #warning "Software pin support forced, pin access will be slightly slower."
  6. #define NO_HARDWARE_PIN_SUPPORT
  7. #undef HAS_HARDWARE_PIN_SUPPORT
  8. #else
  9. #define AVR_PIN_CYCLES(_PIN) ((((int)FastPin<_PIN>::port())-0x20 < 64) ? 1 : 2)
  10. /// Class definition for a Pin where we know the port registers at compile time for said pin. This allows us to make
  11. /// a lot of optimizations, as the inlined hi/lo methods will devolve to a single io register write/bitset.
  12. template<uint8_t PIN, uint8_t _MASK, typename _PORT, typename _DDR, typename _PIN> class _AVRPIN {
  13. public:
  14. typedef volatile uint8_t * port_ptr_t;
  15. typedef uint8_t port_t;
  16. inline static void setOutput() { _DDR::r() |= _MASK; }
  17. inline static void setInput() { _DDR::r() &= ~_MASK; }
  18. inline static void hi() __attribute__ ((always_inline)) { _PORT::r() |= _MASK; }
  19. inline static void lo() __attribute__ ((always_inline)) { _PORT::r() &= ~_MASK; }
  20. inline static void set(register uint8_t val) __attribute__ ((always_inline)) { _PORT::r() = val; }
  21. inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); }
  22. inline static void toggle() __attribute__ ((always_inline)) { _PIN::r() = _MASK; }
  23. inline static void hi(register port_ptr_t /*port*/) __attribute__ ((always_inline)) { hi(); }
  24. inline static void lo(register port_ptr_t /*port*/) __attribute__ ((always_inline)) { lo(); }
  25. inline static void fastset(register port_ptr_t /*port*/, register uint8_t val) __attribute__ ((always_inline)) { set(val); }
  26. inline static port_t hival() __attribute__ ((always_inline)) { return _PORT::r() | _MASK; }
  27. inline static port_t loval() __attribute__ ((always_inline)) { return _PORT::r() & ~_MASK; }
  28. inline static port_ptr_t port() __attribute__ ((always_inline)) { return &_PORT::r(); }
  29. inline static port_t mask() __attribute__ ((always_inline)) { return _MASK; }
  30. };
  31. /// AVR definitions for pins. Getting around the fact that I can't pass GPIO register addresses in as template arguments by instead creating
  32. /// a custom type for each GPIO register with a single, static, aggressively inlined function that returns that specific GPIO register. A similar
  33. /// trick is used a bit further below for the ARM GPIO registers (of which there are far more than on AVR!)
  34. typedef volatile uint8_t & reg8_t;
  35. #define _R(T) struct __gen_struct_ ## T
  36. #define _RD8(T) struct __gen_struct_ ## T { static inline reg8_t r() { return T; }};
  37. #define _FL_IO(L,C) _RD8(DDR ## L); _RD8(PORT ## L); _RD8(PIN ## L); _FL_DEFINE_PORT3(L, C, _R(PORT ## L));
  38. #define _FL_DEFPIN(_PIN, BIT, L) template<> class FastPin<_PIN> : public _AVRPIN<_PIN, 1<<BIT, _R(PORT ## L), _R(DDR ## L), _R(PIN ## L)> {};
  39. // Pre-do all the port definitions
  40. #ifdef PORTA
  41. _FL_IO(A,0)
  42. #endif
  43. #ifdef PORTB
  44. _FL_IO(B,1)
  45. #endif
  46. #ifdef PORTC
  47. _FL_IO(C,2)
  48. #endif
  49. #ifdef PORTD
  50. _FL_IO(D,3)
  51. #endif
  52. #ifdef PORTE
  53. _FL_IO(E,4)
  54. #endif
  55. #ifdef PORTF
  56. _FL_IO(F,5)
  57. #endif
  58. #ifdef PORTG
  59. _FL_IO(G,6)
  60. #endif
  61. #ifdef PORTH
  62. _FL_IO(H,7)
  63. #endif
  64. #ifdef PORTI
  65. _FL_IO(I,8)
  66. #endif
  67. #ifdef PORTJ
  68. _FL_IO(J,9)
  69. #endif
  70. #ifdef PORTK
  71. _FL_IO(K,10)
  72. #endif
  73. #ifdef PORTL
  74. _FL_IO(L,11)
  75. #endif
  76. #ifdef PORTM
  77. _FL_IO(M,12)
  78. #endif
  79. #ifdef PORTN
  80. _FL_IO(N,13)
  81. #endif
  82. #if defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny25__)
  83. #if defined(__AVR_ATtiny25__)
  84. #pragma message "ATtiny25 has very limited storage. This library could use up to more than 100% of its flash size"
  85. #endif
  86. #define MAX_PIN 5
  87. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B); _FL_DEFPIN(3, 3, B);
  88. _FL_DEFPIN(4, 4, B); _FL_DEFPIN(5, 5, B);
  89. #define HAS_HARDWARE_PIN_SUPPORT 1
  90. #elif defined(__AVR_ATtiny841__) || defined(__AVR_ATtiny441__)
  91. #define MAX_PIN 11
  92. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B);
  93. _FL_DEFPIN(3, 7, A); _FL_DEFPIN(4, 6, A); _FL_DEFPIN(5, 5, A);
  94. _FL_DEFPIN(6, 4, A); _FL_DEFPIN(7, 3, A); _FL_DEFPIN(8, 2, A);
  95. _FL_DEFPIN(9, 1, A); _FL_DEFPIN(10, 0, A); _FL_DEFPIN(11, 3, B);
  96. #define HAS_HARDWARE_PIN_SUPPORT 1
  97. #elif defined(ARDUINO_AVR_DIGISPARK) // digispark pin layout
  98. #define MAX_PIN 5
  99. #define HAS_HARDWARE_PIN_SUPPORT 1
  100. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B);
  101. _FL_DEFPIN(3, 7, A); _FL_DEFPIN(4, 6, A); _FL_DEFPIN(5, 5, A);
  102. #elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  103. #define MAX_PIN 10
  104. _FL_DEFPIN(0, 0, A); _FL_DEFPIN(1, 1, A); _FL_DEFPIN(2, 2, A); _FL_DEFPIN(3, 3, A);
  105. _FL_DEFPIN(4, 4, A); _FL_DEFPIN(5, 5, A); _FL_DEFPIN(6, 6, A); _FL_DEFPIN(7, 7, A);
  106. _FL_DEFPIN(8, 2, B); _FL_DEFPIN(9, 1, B); _FL_DEFPIN(10, 0, B);
  107. #define HAS_HARDWARE_PIN_SUPPORT 1
  108. #elif defined(ARDUINO_AVR_DIGISPARKPRO)
  109. #define MAX_PIN 12
  110. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B); _FL_DEFPIN(3, 5, B);
  111. _FL_DEFPIN(4, 3, B); _FL_DEFPIN(5, 7, A); _FL_DEFPIN(6, 0, A); _FL_DEFPIN(7, 1, A);
  112. _FL_DEFPIN(8, 2, A); _FL_DEFPIN(9, 3, A); _FL_DEFPIN(10, 4, A); _FL_DEFPIN(11, 5, A);
  113. _FL_DEFPIN(12, 6, A);
  114. #elif defined(__AVR_ATtiny167__) || defined(__AVR_ATtiny87__)
  115. #define MAX_PIN 15
  116. _FL_DEFPIN(0, 0, A); _FL_DEFPIN(1, 1, A); _FL_DEFPIN(2, 2, A); _FL_DEFPIN(3, 3, A);
  117. _FL_DEFPIN(4, 4, A); _FL_DEFPIN(5, 5, A); _FL_DEFPIN(6, 6, A); _FL_DEFPIN(7, 7, A);
  118. _FL_DEFPIN(8, 0, B); _FL_DEFPIN(9, 1, B); _FL_DEFPIN(10, 2, B); _FL_DEFPIN(11, 3, B);
  119. _FL_DEFPIN(12, 4, B); _FL_DEFPIN(13, 5, B); _FL_DEFPIN(14, 6, B); _FL_DEFPIN(15, 7, B);
  120. #define SPI_DATA 4
  121. #define SPI_CLOCK 5
  122. #define AVR_HARDWARE_SPI 1
  123. #define HAS_HARDWARE_PIN_SUPPORT 1
  124. #elif defined(ARDUINO_HOODLOADER2) && (defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) || defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__)
  125. #define MAX_PIN 20
  126. _FL_DEFPIN( 0, 0, B); _FL_DEFPIN( 1, 1, B); _FL_DEFPIN( 2, 2, B); _FL_DEFPIN( 3, 3, B);
  127. _FL_DEFPIN( 4, 4, B); _FL_DEFPIN( 5, 5, B); _FL_DEFPIN( 6, 6, B); _FL_DEFPIN( 7, 7, B);
  128. _FL_DEFPIN( 8, 7, C); _FL_DEFPIN( 9, 6, C); _FL_DEFPIN( 10, 5,C); _FL_DEFPIN( 11, 4, C);
  129. _FL_DEFPIN( 12, 2, C); _FL_DEFPIN( 13, 0, D); _FL_DEFPIN( 14, 1, D); _FL_DEFPIN(15, 2, D);
  130. _FL_DEFPIN( 16, 3, D); _FL_DEFPIN( 17, 4, D); _FL_DEFPIN( 18, 5, D); _FL_DEFPIN( 19, 6, D);
  131. _FL_DEFPIN( 20, 7, D);
  132. #define HAS_HARDWARE_PIN_SUPPORT 1
  133. // #define SPI_DATA 2
  134. // #define SPI_CLOCK 1
  135. // #define AVR_HARDWARE_SPI 1
  136. #elif defined(IS_BEAN)
  137. #define MAX_PIN 19
  138. _FL_DEFPIN( 0, 6, D); _FL_DEFPIN( 1, 1, B); _FL_DEFPIN( 2, 2, B); _FL_DEFPIN( 3, 3, B);
  139. _FL_DEFPIN( 4, 4, B); _FL_DEFPIN( 5, 5, B); _FL_DEFPIN( 6, 0, D); _FL_DEFPIN( 7, 7, D);
  140. _FL_DEFPIN( 8, 0, B); _FL_DEFPIN( 9, 1, D); _FL_DEFPIN(10, 2, D); _FL_DEFPIN(11, 3, D);
  141. _FL_DEFPIN(12, 4, D); _FL_DEFPIN(13, 5, D); _FL_DEFPIN(14, 0, C); _FL_DEFPIN(15, 1, C);
  142. _FL_DEFPIN(16, 2, C); _FL_DEFPIN(17, 3, C); _FL_DEFPIN(18, 4, C); _FL_DEFPIN(19, 5, C);
  143. #define SPI_DATA 3
  144. #define SPI_CLOCK 5
  145. #define SPI_SELECT 2
  146. #define AVR_HARDWARE_SPI 1
  147. #define HAS_HARDWARE_PIN_SUPPORT 1
  148. #ifndef __AVR_ATmega8__
  149. #define SPI_UART0_DATA 9
  150. #define SPI_UART0_CLOCK 12
  151. #endif
  152. #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega8__)
  153. #define MAX_PIN 19
  154. _FL_DEFPIN( 0, 0, D); _FL_DEFPIN( 1, 1, D); _FL_DEFPIN( 2, 2, D); _FL_DEFPIN( 3, 3, D);
  155. _FL_DEFPIN( 4, 4, D); _FL_DEFPIN( 5, 5, D); _FL_DEFPIN( 6, 6, D); _FL_DEFPIN( 7, 7, D);
  156. _FL_DEFPIN( 8, 0, B); _FL_DEFPIN( 9, 1, B); _FL_DEFPIN(10, 2, B); _FL_DEFPIN(11, 3, B);
  157. _FL_DEFPIN(12, 4, B); _FL_DEFPIN(13, 5, B); _FL_DEFPIN(14, 0, C); _FL_DEFPIN(15, 1, C);
  158. _FL_DEFPIN(16, 2, C); _FL_DEFPIN(17, 3, C); _FL_DEFPIN(18, 4, C); _FL_DEFPIN(19, 5, C);
  159. #define SPI_DATA 11
  160. #define SPI_CLOCK 13
  161. #define SPI_SELECT 10
  162. #define AVR_HARDWARE_SPI 1
  163. #define HAS_HARDWARE_PIN_SUPPORT 1
  164. #ifndef __AVR_ATmega8__
  165. #define SPI_UART0_DATA 1
  166. #define SPI_UART0_CLOCK 4
  167. #endif
  168. #elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__)
  169. #define MAX_PIN 31
  170. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B); _FL_DEFPIN(3, 3, B);
  171. _FL_DEFPIN(4, 4, B); _FL_DEFPIN(5, 5, B); _FL_DEFPIN(6, 6, B); _FL_DEFPIN(7, 7, B);
  172. _FL_DEFPIN(8, 0, D); _FL_DEFPIN(9, 1, D); _FL_DEFPIN(10, 2, D); _FL_DEFPIN(11, 3, D);
  173. _FL_DEFPIN(12, 4, D); _FL_DEFPIN(13, 5, D); _FL_DEFPIN(14, 6, D); _FL_DEFPIN(15, 7, D);
  174. _FL_DEFPIN(16, 0, C); _FL_DEFPIN(17, 1, C); _FL_DEFPIN(18, 2, C); _FL_DEFPIN(19, 3, C);
  175. _FL_DEFPIN(20, 4, C); _FL_DEFPIN(21, 5, C); _FL_DEFPIN(22, 6, C); _FL_DEFPIN(23, 7, C);
  176. _FL_DEFPIN(24, 0, A); _FL_DEFPIN(25, 1, A); _FL_DEFPIN(26, 2, A); _FL_DEFPIN(27, 3, A);
  177. _FL_DEFPIN(28, 4, A); _FL_DEFPIN(29, 5, A); _FL_DEFPIN(30, 6, A); _FL_DEFPIN(31, 7, A);
  178. #define SPI_DATA 5
  179. #define SPI_CLOCK 7
  180. #define SPI_SELECT 4
  181. #define AVR_HARDWARE_SPI 1
  182. #define HAS_HARDWARE_PIN_SUPPORT 1
  183. #elif defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__)
  184. // AKA the Pinoccio
  185. _FL_DEFPIN( 0, 0, E); _FL_DEFPIN( 1, 1, E); _FL_DEFPIN( 2, 7, B); _FL_DEFPIN( 3, 3, E);
  186. _FL_DEFPIN( 4, 4, E); _FL_DEFPIN( 5, 5, E); _FL_DEFPIN( 6, 2, E); _FL_DEFPIN( 7, 6, E);
  187. _FL_DEFPIN( 8, 5, D); _FL_DEFPIN( 9, 0, B); _FL_DEFPIN(10, 2, B); _FL_DEFPIN(11, 3, B);
  188. _FL_DEFPIN(12, 1, B); _FL_DEFPIN(13, 2, D); _FL_DEFPIN(14, 3, D); _FL_DEFPIN(15, 0, D);
  189. _FL_DEFPIN(16, 1, D); _FL_DEFPIN(17, 4, D); _FL_DEFPIN(18, 7, E); _FL_DEFPIN(19, 6, D);
  190. _FL_DEFPIN(20, 7, D); _FL_DEFPIN(21, 4, B); _FL_DEFPIN(22, 5, B); _FL_DEFPIN(23, 6, B);
  191. _FL_DEFPIN(24, 0, F); _FL_DEFPIN(25, 1, F); _FL_DEFPIN(26, 2, F); _FL_DEFPIN(27, 3, F);
  192. _FL_DEFPIN(28, 4, F); _FL_DEFPIN(29, 5, F); _FL_DEFPIN(30, 6, F); _FL_DEFPIN(31, 7, F);
  193. #define SPI_DATA 10
  194. #define SPI_CLOCK 12
  195. #define SPI_SELECT 9
  196. #define AVR_HARDWARE_SPI 1
  197. #define HAS_HARDWARE_PIN_SUPPORT 1
  198. #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  199. // megas
  200. #define MAX_PIN 69
  201. _FL_DEFPIN(0, 0, E); _FL_DEFPIN(1, 1, E); _FL_DEFPIN(2, 4, E); _FL_DEFPIN(3, 5, E);
  202. _FL_DEFPIN(4, 5, G); _FL_DEFPIN(5, 3, E); _FL_DEFPIN(6, 3, H); _FL_DEFPIN(7, 4, H);
  203. _FL_DEFPIN(8, 5, H); _FL_DEFPIN(9, 6, H); _FL_DEFPIN(10, 4, B); _FL_DEFPIN(11, 5, B);
  204. _FL_DEFPIN(12, 6, B); _FL_DEFPIN(13, 7, B); _FL_DEFPIN(14, 1, J); _FL_DEFPIN(15, 0, J);
  205. _FL_DEFPIN(16, 1, H); _FL_DEFPIN(17, 0, H); _FL_DEFPIN(18, 3, D); _FL_DEFPIN(19, 2, D);
  206. _FL_DEFPIN(20, 1, D); _FL_DEFPIN(21, 0, D); _FL_DEFPIN(22, 0, A); _FL_DEFPIN(23, 1, A);
  207. _FL_DEFPIN(24, 2, A); _FL_DEFPIN(25, 3, A); _FL_DEFPIN(26, 4, A); _FL_DEFPIN(27, 5, A);
  208. _FL_DEFPIN(28, 6, A); _FL_DEFPIN(29, 7, A); _FL_DEFPIN(30, 7, C); _FL_DEFPIN(31, 6, C);
  209. _FL_DEFPIN(32, 5, C); _FL_DEFPIN(33, 4, C); _FL_DEFPIN(34, 3, C); _FL_DEFPIN(35, 2, C);
  210. _FL_DEFPIN(36, 1, C); _FL_DEFPIN(37, 0, C); _FL_DEFPIN(38, 7, D); _FL_DEFPIN(39, 2, G);
  211. _FL_DEFPIN(40, 1, G); _FL_DEFPIN(41, 0, G); _FL_DEFPIN(42, 7, L); _FL_DEFPIN(43, 6, L);
  212. _FL_DEFPIN(44, 5, L); _FL_DEFPIN(45, 4, L); _FL_DEFPIN(46, 3, L); _FL_DEFPIN(47, 2, L);
  213. _FL_DEFPIN(48, 1, L); _FL_DEFPIN(49, 0, L); _FL_DEFPIN(50, 3, B); _FL_DEFPIN(51, 2, B);
  214. _FL_DEFPIN(52, 1, B); _FL_DEFPIN(53, 0, B); _FL_DEFPIN(54, 0, F); _FL_DEFPIN(55, 1, F);
  215. _FL_DEFPIN(56, 2, F); _FL_DEFPIN(57, 3, F); _FL_DEFPIN(58, 4, F); _FL_DEFPIN(59, 5, F);
  216. _FL_DEFPIN(60, 6, F); _FL_DEFPIN(61, 7, F); _FL_DEFPIN(62, 0, K); _FL_DEFPIN(63, 1, K);
  217. _FL_DEFPIN(64, 2, K); _FL_DEFPIN(65, 3, K); _FL_DEFPIN(66, 4, K); _FL_DEFPIN(67, 5, K);
  218. _FL_DEFPIN(68, 6, K); _FL_DEFPIN(69, 7, K);
  219. #define SPI_DATA 51
  220. #define SPI_CLOCK 52
  221. #define SPI_SELECT 53
  222. #define AVR_HARDWARE_SPI 1
  223. #define HAS_HARDWARE_PIN_SUPPORT 1
  224. // Leonardo, teensy, blinkm
  225. #elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
  226. // teensy defs
  227. #define MAX_PIN 23
  228. _FL_DEFPIN(0, 0, B); _FL_DEFPIN(1, 1, B); _FL_DEFPIN(2, 2, B); _FL_DEFPIN(3, 3, B);
  229. _FL_DEFPIN(4, 7, B); _FL_DEFPIN(5, 0, D); _FL_DEFPIN(6, 1, D); _FL_DEFPIN(7, 2, D);
  230. _FL_DEFPIN(8, 3, D); _FL_DEFPIN(9, 6, C); _FL_DEFPIN(10, 7, C); _FL_DEFPIN(11, 6, D);
  231. _FL_DEFPIN(12, 7, D); _FL_DEFPIN(13, 4, B); _FL_DEFPIN(14, 5, B); _FL_DEFPIN(15, 6, B);
  232. _FL_DEFPIN(16, 7, F); _FL_DEFPIN(17, 6, F); _FL_DEFPIN(18, 5, F); _FL_DEFPIN(19, 4, F);
  233. _FL_DEFPIN(20, 1, F); _FL_DEFPIN(21, 0, F); _FL_DEFPIN(22, 4, D); _FL_DEFPIN(23, 5, D);
  234. #define SPI_DATA 2
  235. #define SPI_CLOCK 1
  236. #define SPI_SELECT 0
  237. #define AVR_HARDWARE_SPI 1
  238. #define HAS_HARDWARE_PIN_SUPPORT 1
  239. // PD3/PD5
  240. #define SPI_UART1_DATA 8
  241. #define SPI_UART1_CLOCK 23
  242. #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  243. // teensy++ 2 defs
  244. #define MAX_PIN 45
  245. _FL_DEFPIN(0, 0, D); _FL_DEFPIN(1, 1, D); _FL_DEFPIN(2, 2, D); _FL_DEFPIN(3, 3, D);
  246. _FL_DEFPIN(4, 4, D); _FL_DEFPIN(5, 5, D); _FL_DEFPIN(6, 6, D); _FL_DEFPIN(7, 7, D);
  247. _FL_DEFPIN(8, 0, E); _FL_DEFPIN(9, 1, E); _FL_DEFPIN(10, 0, C); _FL_DEFPIN(11, 1, C);
  248. _FL_DEFPIN(12, 2, C); _FL_DEFPIN(13, 3, C); _FL_DEFPIN(14, 4, C); _FL_DEFPIN(15, 5, C);
  249. _FL_DEFPIN(16, 6, C); _FL_DEFPIN(17, 7, C); _FL_DEFPIN(18, 6, E); _FL_DEFPIN(19, 7, E);
  250. _FL_DEFPIN(20, 0, B); _FL_DEFPIN(21, 1, B); _FL_DEFPIN(22, 2, B); _FL_DEFPIN(23, 3, B);
  251. _FL_DEFPIN(24, 4, B); _FL_DEFPIN(25, 5, B); _FL_DEFPIN(26, 6, B); _FL_DEFPIN(27, 7, B);
  252. _FL_DEFPIN(28, 0, A); _FL_DEFPIN(29, 1, A); _FL_DEFPIN(30, 2, A); _FL_DEFPIN(31, 3, A);
  253. _FL_DEFPIN(32, 4, A); _FL_DEFPIN(33, 5, A); _FL_DEFPIN(34, 6, A); _FL_DEFPIN(35, 7, A);
  254. _FL_DEFPIN(36, 4, E); _FL_DEFPIN(37, 5, E); _FL_DEFPIN(38, 0, F); _FL_DEFPIN(39, 1, F);
  255. _FL_DEFPIN(40, 2, F); _FL_DEFPIN(41, 3, F); _FL_DEFPIN(42, 4, F); _FL_DEFPIN(43, 5, F);
  256. _FL_DEFPIN(44, 6, F); _FL_DEFPIN(45, 7, F);
  257. #define SPI_DATA 22
  258. #define SPI_CLOCK 21
  259. #define SPI_SELECT 20
  260. #define AVR_HARDWARE_SPI 1
  261. #define HAS_HARDWARE_PIN_SUPPORT 1
  262. // PD3/PD5
  263. #define SPI_UART1_DATA 3
  264. #define SPI_UART1_CLOCK 5
  265. #elif defined(__AVR_ATmega32U4__)
  266. // leonard defs
  267. #define MAX_PIN 30
  268. _FL_DEFPIN(0, 2, D); _FL_DEFPIN(1, 3, D); _FL_DEFPIN(2, 1, D); _FL_DEFPIN(3, 0, D);
  269. _FL_DEFPIN(4, 4, D); _FL_DEFPIN(5, 6, C); _FL_DEFPIN(6, 7, D); _FL_DEFPIN(7, 6, E);
  270. _FL_DEFPIN(8, 4, B); _FL_DEFPIN(9, 5, B); _FL_DEFPIN(10, 6, B); _FL_DEFPIN(11, 7, B);
  271. _FL_DEFPIN(12, 6, D); _FL_DEFPIN(13, 7, C); _FL_DEFPIN(14, 3, B); _FL_DEFPIN(15, 1, B);
  272. _FL_DEFPIN(16, 2, B); _FL_DEFPIN(17, 0, B); _FL_DEFPIN(18, 7, F); _FL_DEFPIN(19, 6, F);
  273. _FL_DEFPIN(20, 5, F); _FL_DEFPIN(21, 4, F); _FL_DEFPIN(22, 1, F); _FL_DEFPIN(23, 0, F);
  274. _FL_DEFPIN(24, 4, D); _FL_DEFPIN(25, 7, D); _FL_DEFPIN(26, 4, B); _FL_DEFPIN(27, 5, B);
  275. _FL_DEFPIN(28, 6, B); _FL_DEFPIN(29, 6, D); _FL_DEFPIN(30, 5, D);
  276. #define SPI_DATA 16
  277. #define SPI_CLOCK 15
  278. #define AVR_HARDWARE_SPI 1
  279. #define HAS_HARDWARE_PIN_SUPPORT 1
  280. // PD3/PD5
  281. #define SPI_UART1_DATA 1
  282. #define SPI_UART1_CLOCK 30
  283. #endif
  284. #endif // FASTLED_FORCE_SOFTWARE_PINS
  285. FASTLED_NAMESPACE_END
  286. #endif // __INC_FASTPIN_AVR_H