pin_defs.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630
  1. /*
  2. * pin_defs.h
  3. * optiboot helper defining the default pin assignments (LED, SOFT_UART)
  4. * for the various chips that are supported. This also has some ugly macros
  5. * for selecting among various UARTs and LED possibilities using command-line
  6. * defines like "UART=2 LED=B5"
  7. *
  8. * Copyright 2013-2015 by Bill Westfield.
  9. * Copyright 2010 by Peter Knight.
  10. * This software is licensed under version 2 of the Gnu Public Licence.
  11. * See optiboot.c for details.
  12. */
  13. /*------------------------------------------------------------------------ */
  14. #if defined(__AVR_ATmega168__) \
  15. || defined(__AVR_ATmega168P__) \
  16. || defined(__AVR_ATmega328__) \
  17. || defined(__AVR_ATmega328P__) \
  18. || defined(__AVR_ATmega88) \
  19. || defined(__AVR_ATmega8__) \
  20. || defined(__AVR_ATmega88__)
  21. /*------------------------------------------------------------------------ */
  22. /*
  23. * Onboard LED is connected to pin PB5 in Arduino NG, Diecimila,
  24. * Duemilanove, Uno, Nano, and many other Ardunio-like boards.
  25. */
  26. #if !defined(LED)
  27. #define LED B5
  28. #endif
  29. /* Ports for soft UART */
  30. #if SOFT_UART
  31. #define UART_PORT PORTD
  32. #define UART_PIN PIND
  33. #define UART_DDR DDRD
  34. #define UART_TX_BIT 1
  35. #define UART_RX_BIT 0
  36. #endif
  37. #endif
  38. /*
  39. * Handle devices with up to 4 uarts (eg m1280.) Rather inelegantly.
  40. * Note that mega8/m32 still needs special handling, because ubrr is handled
  41. * differently.
  42. */
  43. #if (SOFT_UART == 0)
  44. #if UART == 0
  45. #if defined(UDR0)
  46. # define UART_SRA UCSR0A
  47. # define UART_SRB UCSR0B
  48. # define UART_SRC UCSR0C
  49. # define UART_SRL UBRR0L
  50. # define UART_UDR UDR0
  51. #elif defined(UDR)
  52. # define UART_SRA UCSRA
  53. # define UART_SRB UCSRB
  54. # define UART_SRC UCSRC
  55. # define UART_SRL UBRRL
  56. # define UART_UDR UDR
  57. #elif defined(LINDAT)
  58. # define LIN_UART 1
  59. # define UART_SRA UCSRA
  60. # define UART_SRB UCSRB
  61. # define UART_SRC UCSRC
  62. # define UART_SRL UBRRL
  63. # define UART_UDR LINDAT
  64. #else
  65. # error UART == 0, but no UART0 on device
  66. #endif
  67. #elif UART == 1
  68. #if !defined(UDR1)
  69. #error UART == 1, but no UART1 on device
  70. #endif
  71. # define UART_SRA UCSR1A
  72. # define UART_SRB UCSR1B
  73. # define UART_SRC UCSR1C
  74. # define UART_SRL UBRR1L
  75. # define UART_UDR UDR1
  76. #elif UART == 2
  77. #if !defined(UDR2)
  78. #error UART == 2, but no UART2 on device
  79. #endif
  80. # define UART_SRA UCSR2A
  81. # define UART_SRB UCSR2B
  82. # define UART_SRC UCSR2C
  83. # define UART_SRL UBRR2L
  84. # define UART_UDR UDR2
  85. #elif UART == 3
  86. #if !defined(UDR3)
  87. #error UART == 3, but no UART3 on device
  88. #endif
  89. # define UART_SRA UCSR3A
  90. # define UART_SRB UCSR3B
  91. # define UART_SRC UCSR3C
  92. # define UART_SRL UBRR3L
  93. # define UART_UDR UDR3
  94. #endif
  95. #endif //end #if SOFT_UART==0
  96. #if defined(__AVR_ATmega8__) \
  97. || defined (__AVR_ATmega32__) \
  98. || defined (__AVR_ATmega16__)
  99. //Name conversion R.Wiersma
  100. #define UCSR0A UCSRA
  101. #define UDR0 UDR
  102. #define UDRE0 UDRE
  103. #define RXC0 RXC
  104. #define TXC0 TXC
  105. #define FE0 FE
  106. #define TIFR1 TIFR
  107. #define WDTCSR WDTCR
  108. #endif
  109. #if defined (__AVR_ATmega32__) \
  110. || defined (__AVR_ATmega16__)
  111. #define WDCE WDTOE
  112. #endif
  113. /*------------------------------------------------------------------------ */
  114. /* Sanguino support (and other 40pin DIP cpus) */
  115. /*------------------------------------------------------------------------ */
  116. /*------------------------------------------------------------------------ */
  117. #if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
  118. /*------------------------------------------------------------------------ */
  119. #if !defined(LED)
  120. #define LED B0
  121. #endif
  122. /* Fix register names */
  123. #if defined(__AVR_ATmega8515__)
  124. #define UCSR0A UCSRA
  125. #define UDR0 UDR
  126. #define UDRE0 UDRE
  127. #define RXC0 RXC
  128. #define FE0 FE
  129. #endif
  130. #define TIFR1 TIFR
  131. #define WDTCSR WDTCR
  132. /* Ports for soft UART */
  133. #if SOFT_UART
  134. #define UART_PORT PORTD
  135. #define UART_PIN PIND
  136. #define UART_DDR DDRD
  137. #define UART_TX_BIT 1
  138. #define UART_RX_BIT 0
  139. #endif
  140. #endif
  141. #if defined(__AVR_ATmega8535__) \
  142. || defined(__AVR_ATmega16__) \
  143. || defined(__AVR_ATmega32__) \
  144. || defined(__AVR_ATmega164A__) \
  145. || defined(__AVR_ATmega164P__) \
  146. || defined(__AVR_ATmega324A__) \
  147. || defined(__AVR_ATmega324P__) \
  148. || defined(__AVR_ATmega324PA__) \
  149. || defined(__AVR_ATmega644__) \
  150. || defined(__AVR_ATmega644P__) \
  151. || defined(__AVR_ATmega1284__) \
  152. || defined(__AVR_ATmega1284P__)
  153. /*------------------------------------------------------------------------ */
  154. #if !defined(LED)
  155. #define LED B0
  156. #endif
  157. #if defined(__AVR_ATmega8535__) \
  158. || defined(__AVR_ATmega16__) \
  159. || defined(__AVR_ATmega32__)
  160. /* Fix register names */
  161. #define UCSR0A UCSRA
  162. #define UDR0 UDR
  163. #define UDRE0 UDRE
  164. #define RXC0 RXC
  165. #define FE0 FE
  166. #define TIFR1 TIFR
  167. #define WDTCSR WDTCR
  168. #endif
  169. #if defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__)
  170. #define WDCE WDTOE
  171. #endif
  172. /* Ports for soft UART */
  173. #if SOFT_UART
  174. #define UART_PORT PORTD
  175. #define UART_PIN PIND
  176. #define UART_DDR DDRD
  177. #define UART_TX_BIT 1
  178. #define UART_RX_BIT 0
  179. #endif
  180. #endif
  181. /*------------------------------------------------------------------------ */
  182. #if defined(__AVR_ATmega324PB__)
  183. /*------------------------------------------------------------------------ */
  184. #if !defined(LED)
  185. #define LED B0
  186. #endif
  187. /* Fix missing register names */
  188. #define MPCM0 MPCM
  189. #define U2X0 U2X
  190. #define UPE0 UPE
  191. #define DOR0 DOR
  192. #define FE0 FE
  193. #define UDRE0 UDRE
  194. #define TXC0 TXC
  195. #define RXC0 RXC
  196. #define TXB80 TXB8
  197. #define RXB80 RXB8
  198. #define UCSZ02 UCSZ2
  199. #define TXEN0 TXEN
  200. #define RXEN0 RXEN
  201. #define UDRIE0 UDRIE
  202. #define TXCIE0 TXCIE
  203. #define RXCIE0 RXCIE
  204. #define UCPOL0 UCPOL
  205. #define UCSZ00 UCSZ0
  206. #define UCSZ01 UCSZ1
  207. #define USBS0 USBS
  208. #define UPM00 UPM0
  209. #define UPM01 UPM1
  210. #define UMSEL00 UMSEL0
  211. #define UMSEL01 UMSEL1
  212. #define MPCM1 MPCM
  213. #define U2X1 U2X
  214. #define UPE1 UPE
  215. #define DOR1 DOR
  216. #define FE1 FE
  217. #define UDRE1 UDRE
  218. #define TXC1 TXC
  219. #define RXC1 RXC
  220. #define TXB81 TXB8
  221. #define RXB81 RXB8
  222. #define UCSZ12 UCSZ2
  223. #define TXEN1 TXEN
  224. #define RXEN1 RXEN
  225. #define UDRIE1 UDRIE
  226. #define TXCIE1 TXCIE
  227. #define RXCIE1 RXCIE
  228. #define UCPOL1 UCPOL
  229. #define UCSZ10 UCSZ0
  230. #define UCSZ11 UCSZ1
  231. #define USBS1 USBS
  232. #define UPM10 UPM0
  233. #define UPM11 UPM1
  234. #define UMSEL10 UMSEL0
  235. #define UMSEL11 UMSEL1
  236. #define MPCM2 MPCM
  237. #define U2X2 U2X
  238. #define UPE2 UPE
  239. #define DOR2 DOR
  240. #define FE2 FE
  241. #define UDRE2 UDRE
  242. #define TXC2 TXC
  243. #define RXC2 RXC
  244. #define TXB82 TXB8
  245. #define RXB82 RXB8
  246. #define UCSZ22 UCSZ2
  247. #define TXEN2 TXEN
  248. #define RXEN2 RXEN
  249. #define UDRIE2 UDRIE
  250. #define TXCIE2 TXCIE
  251. #define RXCIE2 RXCIE
  252. #define UCPOL2 UCPOL
  253. #define UCSZ20 UCSZ0
  254. #define UCSZ21 UCSZ1
  255. #define USBS2 USBS
  256. #define UPM20 UPM0
  257. #define UPM21 UPM1
  258. #define UMSEL20 UMSEL0
  259. #define UMSEL21 UMSEL1
  260. /* Ports for soft UART */
  261. #if SOFT_UART
  262. #define UART_PORT PORTD
  263. #define UART_PIN PIND
  264. #define UART_DDR DDRD
  265. #define UART_TX_BIT 1
  266. #define UART_RX_BIT 0
  267. #endif
  268. #endif
  269. /*------------------------------------------------------------------------ */
  270. #if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
  271. /*------------------------------------------------------------------------ */
  272. #if !defined(LED)
  273. #define LED B5
  274. #endif
  275. #define TIFR1 TIFR
  276. #define WDTCSR WDTCR
  277. //#define MCUSR MCUCSR
  278. //#define SPMCR SPMCSR
  279. /* Ports for soft UART */
  280. #if SOFT_UART
  281. #define UART_PORT PORTE
  282. #define UART_PIN PINE
  283. #define UART_DDR DDRE
  284. #define UART_TX_BIT 1
  285. #define UART_RX_BIT 0
  286. #endif
  287. #endif
  288. /*------------------------------------------------------------------------ */
  289. /* Mega support */
  290. #if defined(__AVR_ATmega640__) \
  291. || defined(__AVR_ATmega1280__) \
  292. || defined(__AVR_ATmega128RFA1__) \
  293. || defined(__AVR_ATmega2560__)
  294. /*------------------------------------------------------------------------ */
  295. /* Onboard LED is connected to pin PB7 on Arduino Mega */
  296. #if !defined(LED)
  297. #define LED B7
  298. #endif
  299. /* Ports for soft UART */
  300. #if SOFT_UART
  301. #define UART_PORT PORTE
  302. #define UART_PIN PINE
  303. #define UART_DDR DDRE
  304. #define UART_TX_BIT 1
  305. #define UART_RX_BIT 0
  306. #endif
  307. #endif
  308. /*------------------------------------------------------------------------ */
  309. #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
  310. /*------------------------------------------------------------------------ */
  311. #if !defined(LED)
  312. #define LED B5
  313. #endif
  314. /* Ports for soft UART */
  315. #if SOFT_UART
  316. #define UART_PORT PORTE
  317. #define UART_PIN PINE
  318. #define UART_DDR DDRE
  319. #define UART_TX_BIT 1
  320. #define UART_RX_BIT 0
  321. #endif
  322. #endif
  323. /*------------------------------------------------------------------------ */
  324. #if defined(__AVR_ATmega169__)
  325. /*------------------------------------------------------------------------ */
  326. #if !defined(LED)
  327. #define LED B5
  328. #endif
  329. /* Fix register names */
  330. #define UCSR0A UCSRA
  331. #define UCSR0B UCSRB
  332. #define UCSR0C UCSRC
  333. #define UBRR0L UBRRL
  334. #define UDR0 UDR
  335. #define UDRE0 UDRE
  336. #define RXC0 RXC
  337. #define FE0 FE
  338. #define WDTCSR WDTCR
  339. #define U2X0 U2X
  340. #define RXEN0 RXEN
  341. #define TXEN0 TXEN
  342. #define UCSZ00 UCSZ0
  343. #define UCSZ01 UCSZ1
  344. /* Ports for soft UART */
  345. #if SOFT_UART
  346. #define UART_PORT PORTE
  347. #define UART_PIN PINE
  348. #define UART_DDR DDRE
  349. #define UART_TX_BIT 1
  350. #define UART_RX_BIT 0
  351. #endif
  352. #endif
  353. /*------------------------------------------------------------------------ */
  354. #if defined(__AVR_ATmega169P__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329P__) \
  355. || defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega649__) \
  356. || defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490P__)
  357. /*------------------------------------------------------------------------ */
  358. #if !defined(LED)
  359. #define LED B5
  360. #endif
  361. /* Fix register names */
  362. #define WDTCSR WDTCR
  363. /* Ports for soft UART */
  364. #if SOFT_UART
  365. #define UART_PORT PORTE
  366. #define UART_PIN PINE
  367. #define UART_DDR DDRE
  368. #define UART_TX_BIT 1
  369. #define UART_RX_BIT 0
  370. #endif
  371. #endif
  372. /*------------------------------------------------------------------------ */
  373. #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
  374. /*------------------------------------------------------------------------ */
  375. #if !defined(LED)
  376. #define LED B5
  377. #endif
  378. /* Ports for soft UART */
  379. #if SOFT_UART
  380. #define UART_PORT PORTE
  381. #define UART_PIN PINE
  382. #define UART_DDR DDRE
  383. #define UART_TX_BIT 1
  384. #define UART_RX_BIT 0
  385. #endif
  386. #endif
  387. /*------------------------------------------------------------------------ */
  388. #if defined(__AVR_ATmega169__)
  389. /*------------------------------------------------------------------------ */
  390. #if !defined(LED)
  391. #define LED B5
  392. #endif
  393. /* Fix register names */
  394. #define UCSR0A UCSRA
  395. #define UCSR0B UCSRB
  396. #define UCSR0C UCSRC
  397. #define UBRR0L UBRRL
  398. #define UDR0 UDR
  399. #define UDRE0 UDRE
  400. #define RXC0 RXC
  401. #define FE0 FE
  402. #define WDTCSR WDTCR
  403. #define U2X0 U2X
  404. #define RXEN0 RXEN
  405. #define TXEN0 TXEN
  406. #define UCSZ00 UCSZ0
  407. #define UCSZ01 UCSZ1
  408. /* Ports for soft UART */
  409. #if SOFT_UART
  410. #define UART_PORT PORTE
  411. #define UART_PIN PINE
  412. #define UART_DDR DDRE
  413. #define UART_TX_BIT 1
  414. #define UART_RX_BIT 0
  415. #endif
  416. #endif
  417. /*------------------------------------------------------------------------ */
  418. #if defined(__AVR_ATmega169P__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329P__) \
  419. || defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega649__) \
  420. || defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490P__)
  421. /*------------------------------------------------------------------------ */
  422. #if !defined(LED)
  423. #define LED B5
  424. #endif
  425. /* Fix register names */
  426. #define WDTCSR WDTCR
  427. /* Ports for soft UART */
  428. #if SOFT_UART
  429. #define UART_PORT PORTE
  430. #define UART_PIN PINE
  431. #define UART_DDR DDRE
  432. #define UART_TX_BIT 1
  433. #define UART_RX_BIT 0
  434. #endif
  435. #endif
  436. /*------------------------------------------------------------------------ */
  437. #if defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) \
  438. || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U6__) \
  439. || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) \
  440. || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
  441. /*------------------------------------------------------------------------ */
  442. /* Fix different register names */
  443. #define MPCM0 MPCM1
  444. #define U2X0 U2X1
  445. #define UPE0 UPE1
  446. #define DOR0 DOR1
  447. #define FE0 FE1
  448. #define UDRE0 UDRE1
  449. #define TXC0 TXC1
  450. #define RXC0 RXC1
  451. #define TXB80 TXB81
  452. #define RXB80 RXB81
  453. #define UCSZ02 UCSZ12
  454. #define TXEN0 TXEN1
  455. #define RXEN0 RXEN1
  456. #define UDRIE0 UDRIE1
  457. #define TXCIE0 TXCIE1
  458. #define RXCIE0 RXCIE1
  459. #define UCPOL0 UCPOL1
  460. #define UCSZ00 UCSZ10
  461. #define UCSZ01 UCSZ11
  462. #define USBS0 USBS1
  463. #define UPM00 UPM10
  464. #define UPM01 UPM11
  465. #define UMSEL00 UMSEL10
  466. #define UMSEL01 UMSEL11
  467. /* Ports for soft UART */
  468. #if SOFT_UART
  469. #define UART_PORT PORTD
  470. #define UART_PIN PIND
  471. #define UART_DDR DDRD
  472. #define UART_TX_BIT 3
  473. #define UART_RX_BIT 2
  474. #endif
  475. /*------------------------------------------------------------------------ */
  476. #if defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)
  477. /*------------------------------------------------------------------------ */
  478. #if !defined(LED)
  479. #define LED D5 // because of Arduino Uno USB-MCU TXLED
  480. #endif
  481. #endif // AtmegaXYu2
  482. /*------------------------------------------------------------------------ */
  483. #if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
  484. /*------------------------------------------------------------------------ */
  485. #if !defined(LED)
  486. #define LED C7 // because of Arduino Micro LED_BUILTIN (D13)
  487. #endif
  488. #endif // AtmegaXYu4
  489. /*------------------------------------------------------------------------ */
  490. #if defined(__AVR_ATmega32U6__)
  491. /*------------------------------------------------------------------------ */
  492. #if !defined(LED)
  493. #define LED C6 // because of PWM (OSC3A)
  494. #endif
  495. #endif // AtmegaXYu6
  496. /*------------------------------------------------------------------------ */
  497. #if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) \
  498. || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
  499. /*------------------------------------------------------------------------ */
  500. #if !defined(LED)
  501. #define LED C6 // because of PWM (OSC3A)
  502. #endif
  503. #endif // At90usbXYz6/7
  504. #endif // usbmcus
  505. /*------------------------------------------------------------------------ */
  506. #if defined(__AVR_ATtiny1634__)
  507. /*------------------------------------------------------------------------ */
  508. /* LED is on C0 */
  509. #if !defined(LED)
  510. #define LED C0
  511. #endif
  512. #define TIFR1 TIFR
  513. #if SOFT_UART
  514. #define UART_PORT PORTA
  515. #define UART_PIN PINA
  516. #define UART_DDR DDRA
  517. #define UART_TX_BIT 2
  518. #define UART_RX_BIT 3
  519. #endif
  520. #endif
  521. /*------------------------------------------------------------------------ */
  522. #if defined(__AVR_ATtiny841__)
  523. /*------------------------------------------------------------------------ */
  524. /* LED is on B2 */
  525. #if !defined(LED)
  526. #define LED B2
  527. #endif
  528. #if SOFT_UART
  529. #define UART_PORT PORTA
  530. #define UART_PIN PINA
  531. #define UART_DDR DDRA
  532. #define UART_TX_BIT 2
  533. #define UART_RX_BIT 3
  534. #endif
  535. #endif
  536. /*------------------------------------------------------------------------ */
  537. #if defined(__AVR_ATtiny441__)
  538. /*------------------------------------------------------------------------ */
  539. /* LED is on B2 */
  540. #if !defined(LED)
  541. #define LED B2
  542. #endif
  543. #if SOFT_UART
  544. #define UART_PORT PORTA
  545. #define UART_PIN PINA
  546. #define UART_DDR DDRA
  547. #define UART_TX_BIT 2
  548. #define UART_RX_BIT 3
  549. #endif
  550. #endif
  551. /*------------------------------------------------------------------------ */
  552. #if defined(__AVR_ATtiny84__)
  553. /*------------------------------------------------------------------------ */
  554. /* LED is on B2 */
  555. #if !defined(LED)
  556. #define LED B2
  557. #endif
  558. #if SOFT_UART
  559. #define UART_PORT PORTA
  560. #define UART_PIN PINA
  561. #define UART_DDR DDRA
  562. #define UART_TX_BIT 1
  563. #define UART_RX_BIT 2
  564. #endif
  565. #endif
  566. /*------------------------------------------------------------------------ */
  567. #if defined(__AVR_ATtiny44__)
  568. /*------------------------------------------------------------------------ */
  569. /* LED is on B2 */
  570. #if !defined(LED)
  571. #define LED B2
  572. #endif
  573. #if SOFT_UART
  574. #define UART_PORT PORTA
  575. #define UART_PIN PINA
  576. #define UART_DDR DDRA
  577. #define UART_TX_BIT 1
  578. #define UART_RX_BIT 2
  579. #endif
  580. #endif
  581. /*------------------------------------------------------------------------ */
  582. #if defined(__AVR_ATtiny85__)
  583. /*------------------------------------------------------------------------ */
  584. /* LED is on B2 */
  585. #if !defined(LED)
  586. #define LED B2
  587. #endif
  588. #if SOFT_UART
  589. #define UART_PORT PORTB
  590. #define UART_PIN PINB
  591. #define UART_DDR DDRB
  592. #define UART_TX_BIT 0
  593. #define UART_RX_BIT 1
  594. #endif
  595. #endif
  596. /*------------------------------------------------------------------------ */
  597. #if defined(__AVR_ATtiny45__)
  598. /*------------------------------------------------------------------------ */
  599. /* LED is on B2 */
  600. #if !defined(LED)
  601. #define LED B2
  602. #endif
  603. #if SOFT_UART
  604. #define UART_PORT PORTB
  605. #define UART_PIN PINB
  606. #define UART_DDR DDRB
  607. #define UART_TX_BIT 0
  608. #define UART_RX_BIT 1
  609. #endif
  610. #endif
  611. /*------------------------------------------------------------------------ */
  612. #if defined(__AVR_ATtiny861__)
  613. /*------------------------------------------------------------------------ */
  614. /* LED is on B2 */
  615. #if !defined(LED)
  616. #define LED B3
  617. #endif
  618. #if SOFT_UART
  619. #define UART_PORT PORTA
  620. #define UART_PIN PINA
  621. #define UART_DDR DDRA
  622. #define UART_TX_BIT 6
  623. #define UART_RX_BIT 7
  624. #endif
  625. #endif
  626. /*------------------------------------------------------------------------ */
  627. #if defined(__AVR_ATtiny461__)
  628. /*------------------------------------------------------------------------ */
  629. /* LED is on B2 */
  630. #if !defined(LED)
  631. #define LED B3
  632. #endif
  633. #if SOFT_UART
  634. #define UART_PORT PORTA
  635. #define UART_PIN PINA
  636. #define UART_DDR DDRA
  637. #define UART_TX_BIT 6
  638. #define UART_RX_BIT 7
  639. #endif
  640. #endif
  641. /*------------------------------------------------------------------------ */
  642. #if defined(__AVR_ATtiny88__)
  643. /*------------------------------------------------------------------------ */
  644. /* LED is on B2 */
  645. #if !defined(LED)
  646. #define LED B5
  647. #endif
  648. #if SOFT_UART
  649. #define UART_PORT PORTD
  650. #define UART_PIN PIND
  651. #define UART_DDR DDRD
  652. #define UART_TX_BIT 6
  653. #define UART_RX_BIT 7
  654. #endif
  655. #endif
  656. /*------------------------------------------------------------------------ */
  657. #if defined(__AVR_ATtiny48__)
  658. /*------------------------------------------------------------------------ */
  659. /* LED is on B2 */
  660. #if !defined(LED)
  661. #define LED B5
  662. #endif
  663. #if SOFT_UART
  664. #define UART_PORT PORTD
  665. #define UART_PIN PIND
  666. #define UART_DDR DDRD
  667. #define UART_TX_BIT 6
  668. #define UART_RX_BIT 7
  669. #endif
  670. #endif
  671. /*------------------------------------------------------------------------ */
  672. #if defined(__AVR_ATtiny167__)
  673. /*------------------------------------------------------------------------ */
  674. /* LED is on B2 */
  675. #if !defined(LED)
  676. #define LED A3
  677. #endif
  678. #endif
  679. /*------------------------------------------------------------------------ */
  680. #if defined(__AVR_ATtiny87__)
  681. /*------------------------------------------------------------------------ */
  682. /* LED is on B2 */
  683. #if !defined(LED)
  684. #define LED A3
  685. #endif
  686. #endif
  687. /*------------------------------------------------------------------------ */
  688. #if defined(__AVR_ATtiny828__)
  689. /*------------------------------------------------------------------------ */
  690. /* LED is on B2 */
  691. #if !defined(LED)
  692. #define LED B0
  693. #endif
  694. #define UDRE0 UDRE
  695. #define FE0 FE
  696. #define RXC0 RXC
  697. #define UCSZ00 UCSZ0
  698. #define UCSZ01 UCSZ1
  699. #define TXEN0 TXEN
  700. #define RXEN0 RXEN
  701. #define U2X0 U2X
  702. #if SOFT_UART
  703. #define UART_PORT PORTA
  704. #define UART_PIN PINA
  705. #define UART_DDR DDRA
  706. #define UART_TX_BIT 2
  707. #define UART_RX_BIT 3
  708. #endif
  709. #endif
  710. /*
  711. * A bunch of macros to enable the LED to be specified as "B5" for bit 5
  712. * of port B, and similar.
  713. * We define symbols for all the legal combination of port/bit on a chip,
  714. * and do pre-processor tests to see if there's a match. This ends up
  715. * being very verbose, but it is pretty easy to generate semi-automatically.
  716. * (We wouldn't need this if the preprocessor could do string compares.)
  717. */
  718. // Symbols for each PortA bit.
  719. #define A0 0x100
  720. #define A1 0x101
  721. #define A2 0x102
  722. #define A3 0x103
  723. #define A4 0x104
  724. #define A5 0x105
  725. #define A6 0x106
  726. #define A7 0x107
  727. // If there is no PORTA on this chip, don't allow these to be used
  728. // (and indicate the error by redefining LED)
  729. #if !defined(PORTA)
  730. #if LED >= A0 && LED <= A7
  731. #undef LED
  732. #define LED -1
  733. #endif
  734. #endif
  735. #define B0 0x200
  736. #define B1 0x201
  737. #define B2 0x202
  738. #define B3 0x203
  739. #define B4 0x204
  740. #define B5 0x205
  741. #define B6 0x206
  742. #define B7 0x207
  743. #if !defined(PORTB)
  744. #if LED >= B0 && LED <= B7
  745. #undef LED
  746. #define LED -1
  747. #endif
  748. #endif
  749. #define C0 0x300
  750. #define C1 0x301
  751. #define C2 0x302
  752. #define C3 0x303
  753. #define C4 0x304
  754. #define C5 0x305
  755. #define C6 0x306
  756. #define C7 0x307
  757. #if !(defined(PORTC))
  758. #if LED >= C0 && LED <= C7
  759. #undef LED
  760. #define LED -1
  761. #endif
  762. #endif
  763. #define D0 0x400
  764. #define D1 0x401
  765. #define D2 0x402
  766. #define D3 0x403
  767. #define D4 0x404
  768. #define D5 0x405
  769. #define D6 0x406
  770. #define D7 0x407
  771. #if !(defined(PORTD))
  772. #if LED >= D0 && LED <= D7
  773. #undef LED
  774. #define LED -1
  775. #endif
  776. #endif
  777. #define E0 0x500
  778. #define E1 0x501
  779. #define E2 0x502
  780. #define E3 0x503
  781. #define E4 0x504
  782. #define E5 0x505
  783. #define E6 0x506
  784. #define E7 0x507
  785. #if !(defined(PORTE))
  786. #if LED >= E0 && LED <= E7
  787. #undef LED
  788. #define LED -1
  789. #endif
  790. #endif
  791. #define F0 0x600
  792. #define F1 0x601
  793. #define F2 0x602
  794. #define F3 0x603
  795. #define F4 0x604
  796. #define F5 0x605
  797. #define F6 0x606
  798. #define F7 0x607
  799. #if !(defined(PORTF))
  800. #if LED >= F0 && LED <= F7
  801. #undef LED
  802. #define LED -1
  803. #endif
  804. #endif
  805. #define G0 0x700
  806. #define G1 0x701
  807. #define G2 0x702
  808. #define G3 0x703
  809. #define G4 0x704
  810. #define G5 0x705
  811. #define G6 0x706
  812. #define G7 0x707
  813. #if !defined(PORTG)
  814. #if LED >= G0 && LED <= G7
  815. #undef LED
  816. #define LED -1
  817. #endif
  818. #endif
  819. #define H0 0x800
  820. #define H1 0x801
  821. #define H2 0x802
  822. #define H3 0x803
  823. #define H4 0x804
  824. #define H5 0x805
  825. #define H6 0x806
  826. #define H7 0x807
  827. #if !(defined(PORTH))
  828. #if LED >= H0 && LED <= H7
  829. #undef LED
  830. #define LED -1
  831. #endif
  832. #endif
  833. #define J0 0xA00
  834. #define J1 0xA01
  835. #define J2 0xA02
  836. #define J3 0xA03
  837. #define J4 0xA04
  838. #define J5 0xA05
  839. #define J6 0xA06
  840. #define J7 0xA07
  841. #if !(defined(PORTJ))
  842. #if LED >= J0 && LED <= J7
  843. #undef LED
  844. #define LED -1
  845. #endif
  846. #endif
  847. #define K0 0xB00
  848. #define K1 0xB01
  849. #define K2 0xB02
  850. #define K3 0xB03
  851. #define K4 0xB04
  852. #define K5 0xB05
  853. #define K6 0xB06
  854. #define K7 0xB07
  855. #if !(defined(PORTK))
  856. #if LED >= K0 && LED <= K7
  857. #undef LED
  858. #define LED -1
  859. #endif
  860. #endif
  861. #define L0 0xC00
  862. #define L1 0xC01
  863. #define L2 0xC02
  864. #define L3 0xC03
  865. #define L4 0xC04
  866. #define L5 0xC05
  867. #define L6 0xC06
  868. #define L7 0xC07
  869. #if !(defined(PORTL))
  870. #if LED >= L0 && LED <= L7
  871. #undef LED
  872. #define LED -1
  873. #endif
  874. #endif
  875. /*
  876. * A statement like "#if LED == B0" will evaluate (in the preprocessor)
  877. * to #if C0 == B0, and then to #if 0x301 == 0x201
  878. */
  879. #if LED == B0
  880. #define LED_NAME "B0"
  881. #undef LED
  882. #define LED_DDR DDRB
  883. #define LED_PORT PORTB
  884. #define LED_PIN PINB
  885. #define LED PINB0
  886. #elif LED == B1
  887. #define LED_NAME "B1"
  888. #undef LED
  889. #define LED_DDR DDRB
  890. #define LED_PORT PORTB
  891. #define LED_PIN PINB
  892. #define LED PINB1
  893. #elif LED == B2
  894. #define LED_NAME "B2"
  895. #undef LED
  896. #define LED_DDR DDRB
  897. #define LED_PORT PORTB
  898. #define LED_PIN PINB
  899. #define LED PINB2
  900. #elif LED == B3
  901. #define LED_NAME "B3"
  902. #undef LED
  903. #define LED_DDR DDRB
  904. #define LED_PORT PORTB
  905. #define LED_PIN PINB
  906. #define LED PINB3
  907. #elif LED == B4
  908. #define LED_NAME "B4"
  909. #undef LED
  910. #define LED_DDR DDRB
  911. #define LED_PORT PORTB
  912. #define LED_PIN PINB
  913. #define LED PINB4
  914. #elif LED == B5
  915. #define LED_NAME "B5"
  916. #undef LED
  917. #define LED_DDR DDRB
  918. #define LED_PORT PORTB
  919. #define LED_PIN PINB
  920. #define LED PINB5
  921. #elif LED == B6
  922. #define LED_NAME "B6"
  923. #undef LED
  924. #define LED_DDR DDRB
  925. #define LED_PORT PORTB
  926. #define LED_PIN PINB
  927. #define LED PINB6
  928. #elif LED == B7
  929. #define LED_NAME "B7"
  930. #undef LED
  931. #define LED_DDR DDRB
  932. #define LED_PORT PORTB
  933. #define LED_PIN PINB
  934. #define LED PINB7
  935. #elif LED == C0
  936. #define LED_NAME "C0"
  937. #undef LED
  938. #define LED_DDR DDRC
  939. #define LED_PORT PORTC
  940. #define LED_PIN PINC
  941. #define LED PINC0
  942. #elif LED == C1
  943. #define LED_NAME "C1"
  944. #undef LED
  945. #define LED_DDR DDRC
  946. #define LED_PORT PORTC
  947. #define LED_PIN PINC
  948. #define LED PINC1
  949. #elif LED == C2
  950. #define LED_NAME "C2"
  951. #undef LED
  952. #define LED_DDR DDRC
  953. #define LED_PORT PORTC
  954. #define LED_PIN PINC
  955. #define LED PINC2
  956. #elif LED == C3
  957. #define LED_NAME "C3"
  958. #undef LED
  959. #define LED_DDR DDRC
  960. #define LED_PORT PORTC
  961. #define LED_PIN PINC
  962. #define LED PINC3
  963. #elif LED == C4
  964. #define LED_NAME "C4"
  965. #undef LED
  966. #define LED_DDR DDRC
  967. #define LED_PORT PORTC
  968. #define LED_PIN PINC
  969. #define LED PINC4
  970. #elif LED == C5
  971. #define LED_NAME "C5"
  972. #undef LED
  973. #define LED_DDR DDRC
  974. #define LED_PORT PORTC
  975. #define LED_PIN PINC
  976. #define LED PINC5
  977. #elif LED == C6
  978. #define LED_NAME "C6"
  979. #undef LED
  980. #define LED_DDR DDRC
  981. #define LED_PORT PORTC
  982. #define LED_PIN PINC
  983. #define LED PINC6
  984. #elif LED == C7
  985. #define LED_NAME "C7"
  986. #undef LED
  987. #define LED_DDR DDRC
  988. #define LED_PORT PORTC
  989. #define LED_PIN PINC
  990. #define LED PINC7
  991. #elif LED == D0
  992. #define LED_NAME "D0"
  993. #undef LED
  994. #define LED_DDR DDRD
  995. #define LED_PORT PORTD
  996. #define LED_PIN PIND
  997. #define LED PIND0
  998. #elif LED == D1
  999. #define LED_NAME "D1"
  1000. #undef LED
  1001. #define LED_DDR DDRD
  1002. #define LED_PORT PORTD
  1003. #define LED_PIN PIND
  1004. #define LED PIND1
  1005. #elif LED == D2
  1006. #define LED_NAME "D2"
  1007. #undef LED
  1008. #define LED_DDR DDRD
  1009. #define LED_PORT PORTD
  1010. #define LED_PIN PIND
  1011. #define LED PIND2
  1012. #elif LED == D3
  1013. #define LED_NAME "D3"
  1014. #undef LED
  1015. #define LED_DDR DDRD
  1016. #define LED_PORT PORTD
  1017. #define LED_PIN PIND
  1018. #define LED PIND3
  1019. #elif LED == D4
  1020. #define LED_NAME "D4"
  1021. #undef LED
  1022. #define LED_DDR DDRD
  1023. #define LED_PORT PORTD
  1024. #define LED_PIN PIND
  1025. #define LED PIND4
  1026. #elif LED == D5
  1027. #define LED_NAME "D5"
  1028. #undef LED
  1029. #define LED_DDR DDRD
  1030. #define LED_PORT PORTD
  1031. #define LED_PIN PIND
  1032. #define LED PIND5
  1033. #elif LED == D6
  1034. #define LED_NAME "D6"
  1035. #undef LED
  1036. #define LED_DDR DDRD
  1037. #define LED_PORT PORTD
  1038. #define LED_PIN PIND
  1039. #define LED PIND6
  1040. #elif LED == D7
  1041. #define LED_NAME "D7"
  1042. #undef LED
  1043. #define LED_DDR DDRD
  1044. #define LED_PORT PORTD
  1045. #define LED_PIN PIND
  1046. #define LED PIND7
  1047. #elif LED == E0
  1048. #define LED_NAME "E0"
  1049. #undef LED
  1050. #define LED_DDR DDRE
  1051. #define LED_PORT PORTE
  1052. #define LED_PIN PINE
  1053. #define LED PINE0
  1054. #elif LED == E1
  1055. #define LED_NAME "E1"
  1056. #undef LED
  1057. #define LED_DDR DDRE
  1058. #define LED_PORT PORTE
  1059. #define LED_PIN PINE
  1060. #define LED PINE1
  1061. #elif LED == E2
  1062. #define LED_NAME "E2"
  1063. #undef LED
  1064. #define LED_DDR DDRE
  1065. #define LED_PORT PORTE
  1066. #define LED_PIN PINE
  1067. #define LED PINE2
  1068. #elif LED == E3
  1069. #define LED_NAME "E3"
  1070. #undef LED
  1071. #define LED_DDR DDRE
  1072. #define LED_PORT PORTE
  1073. #define LED_PIN PINE
  1074. #define LED PINE3
  1075. #elif LED == E4
  1076. #define LED_NAME "E4"
  1077. #undef LED
  1078. #define LED_DDR DDRE
  1079. #define LED_PORT PORTE
  1080. #define LED_PIN PINE
  1081. #define LED PINE4
  1082. #elif LED == E5
  1083. #define LED_NAME "E5"
  1084. #undef LED
  1085. #define LED_DDR DDRE
  1086. #define LED_PORT PORTE
  1087. #define LED_PIN PINE
  1088. #define LED PINE5
  1089. #elif LED == E6
  1090. #define LED_NAME "E6"
  1091. #undef LED
  1092. #define LED_DDR DDRE
  1093. #define LED_PORT PORTE
  1094. #define LED_PIN PINE
  1095. #define LED PINE6
  1096. #elif LED == E7
  1097. #define LED_NAME "E7"
  1098. #undef LED
  1099. #define LED_DDR DDRE
  1100. #define LED_PORT PORTE
  1101. #define LED_PIN PINE
  1102. #define LED PINE7
  1103. #elif LED == F0
  1104. #define LED_NAME "F0"
  1105. #undef LED
  1106. #define LED_DDR DDRF
  1107. #define LED_PORT PORTF
  1108. #define LED_PIN PINF
  1109. #define LED PINF0
  1110. #elif LED == F1
  1111. #define LED_NAME "F1"
  1112. #undef LED
  1113. #define LED_DDR DDRF
  1114. #define LED_PORT PORTF
  1115. #define LED_PIN PINF
  1116. #define LED PINF1
  1117. #elif LED == F2
  1118. #define LED_NAME "F2"
  1119. #undef LED
  1120. #define LED_DDR DDRF
  1121. #define LED_PORT PORTF
  1122. #define LED_PIN PINF
  1123. #define LED PINF2
  1124. #elif LED == F3
  1125. #define LED_NAME "F3"
  1126. #undef LED
  1127. #define LED_DDR DDRF
  1128. #define LED_PORT PORTF
  1129. #define LED_PIN PINF
  1130. #define LED PINF3
  1131. #elif LED == F4
  1132. #define LED_NAME "F4"
  1133. #undef LED
  1134. #define LED_DDR DDRF
  1135. #define LED_PORT PORTF
  1136. #define LED_PIN PINF
  1137. #define LED PINF4
  1138. #elif LED == F5
  1139. #define LED_NAME "F5"
  1140. #undef LED
  1141. #define LED_DDR DDRF
  1142. #define LED_PORT PORTF
  1143. #define LED_PIN PINF
  1144. #define LED PINF5
  1145. #elif LED == F6
  1146. #define LED_NAME "F6"
  1147. #undef LED
  1148. #define LED_DDR DDRF
  1149. #define LED_PORT PORTF
  1150. #define LED_PIN PINF
  1151. #define LED PINF6
  1152. #elif LED == F7
  1153. #define LED_NAME "F7"
  1154. #undef LED
  1155. #define LED_DDR DDRF
  1156. #define LED_PORT PORTF
  1157. #define LED_PIN PINF
  1158. #define LED PINF7
  1159. #elif LED == G0
  1160. #define LED_NAME "G0"
  1161. #undef LED
  1162. #define LED_DDR DDRG
  1163. #define LED_PORT PORTG
  1164. #define LED_PIN PING
  1165. #define LED PING0
  1166. #elif LED == G1
  1167. #define LED_NAME "G1"
  1168. #undef LED
  1169. #define LED_DDR DDRG
  1170. #define LED_PORT PORTG
  1171. #define LED_PIN PING
  1172. #define LED PING1
  1173. #elif LED == G2
  1174. #define LED_NAME "G2"
  1175. #undef LED
  1176. #define LED_DDR DDRG
  1177. #define LED_PORT PORTG
  1178. #define LED_PIN PING
  1179. #define LED PING2
  1180. #elif LED == G3
  1181. #define LED_NAME "G3"
  1182. #undef LED
  1183. #define LED_DDR DDRG
  1184. #define LED_PORT PORTG
  1185. #define LED_PIN PING
  1186. #define LED PING3
  1187. #elif LED == G4
  1188. #define LED_NAME "G4"
  1189. #undef LED
  1190. #define LED_DDR DDRG
  1191. #define LED_PORT PORTG
  1192. #define LED_PIN PING
  1193. #define LED PING4
  1194. #elif LED == G5
  1195. #define LED_NAME "G5"
  1196. #undef LED
  1197. #define LED_DDR DDRG
  1198. #define LED_PORT PORTG
  1199. #define LED_PIN PING
  1200. #define LED PING5
  1201. #elif LED == G6
  1202. #define LED_NAME "G6"
  1203. #undef LED
  1204. #define LED_DDR DDRG
  1205. #define LED_PORT PORTG
  1206. #define LED_PIN PING
  1207. #define LED PING6
  1208. #elif LED == G7
  1209. #define LED_NAME "G7"
  1210. #undef LED
  1211. #define LED_DDR DDRG
  1212. #define LED_PORT PORTG
  1213. #define LED_PIN PING
  1214. #define LED PING7
  1215. #elif LED == H0
  1216. #define LED_NAME "H0"
  1217. #undef LED
  1218. #define LED_DDR DDRH
  1219. #define LED_PORT PORTH
  1220. #define LED_PIN PINH
  1221. #define LED PINH0
  1222. #elif LED == H1
  1223. #define LED_NAME "H1"
  1224. #undef LED
  1225. #define LED_DDR DDRH
  1226. #define LED_PORT PORTH
  1227. #define LED_PIN PINH
  1228. #define LED PINH1
  1229. #elif LED == H2
  1230. #define LED_NAME "H2"
  1231. #undef LED
  1232. #define LED_DDR DDRH
  1233. #define LED_PORT PORTH
  1234. #define LED_PIN PINH
  1235. #define LED PINH2
  1236. #elif LED == H3
  1237. #define LED_NAME "H3"
  1238. #undef LED
  1239. #define LED_DDR DDRH
  1240. #define LED_PORT PORTH
  1241. #define LED_PIN PINH
  1242. #define LED PINH3
  1243. #elif LED == H4
  1244. #define LED_NAME "H4"
  1245. #undef LED
  1246. #define LED_DDR DDRH
  1247. #define LED_PORT PORTH
  1248. #define LED_PIN PINH
  1249. #define LED PINH4
  1250. #elif LED == H5
  1251. #define LED_NAME "H5"
  1252. #undef LED
  1253. #define LED_DDR DDRH
  1254. #define LED_PORT PORTH
  1255. #define LED_PIN PINH
  1256. #define LED PINH5
  1257. #elif LED == H6
  1258. #define LED_NAME "H6"
  1259. #undef LED
  1260. #define LED_DDR DDRH
  1261. #define LED_PORT PORTH
  1262. #define LED_PIN PINH
  1263. #define LED PINH6
  1264. #elif LED == H7
  1265. #define LED_NAME "H7"
  1266. #undef LED
  1267. #define LED_DDR DDRH
  1268. #define LED_PORT PORTH
  1269. #define LED_PIN PINH
  1270. #define LED PINH7
  1271. #elif LED == J0
  1272. #define LED_NAME "J0"
  1273. #undef LED
  1274. #define LED_DDR DDRJ
  1275. #define LED_PORT PORTJ
  1276. #define LED_PIN PINJ
  1277. #define LED PINJ0
  1278. #elif LED == J1
  1279. #define LED_NAME "J1"
  1280. #undef LED
  1281. #define LED_DDR DDRJ
  1282. #define LED_PORT PORTJ
  1283. #define LED_PIN PINJ
  1284. #define LED PINJ1
  1285. #elif LED == J2
  1286. #define LED_NAME "J2"
  1287. #undef LED
  1288. #define LED_DDR DDRJ
  1289. #define LED_PORT PORTJ
  1290. #define LED_PIN PINJ
  1291. #define LED PINJ2
  1292. #elif LED == J3
  1293. #define LED_NAME "J3"
  1294. #undef LED
  1295. #define LED_DDR DDRJ
  1296. #define LED_PORT PORTJ
  1297. #define LED_PIN PINJ
  1298. #define LED PINJ3
  1299. #elif LED == J4
  1300. #define LED_NAME "J4"
  1301. #undef LED
  1302. #define LED_DDR DDRJ
  1303. #define LED_PORT PORTJ
  1304. #define LED_PIN PINJ
  1305. #define LED PINJ4
  1306. #elif LED == J5
  1307. #define LED_NAME "J5"
  1308. #undef LED
  1309. #define LED_DDR DDRJ
  1310. #define LED_PORT PORTJ
  1311. #define LED_PIN PINJ
  1312. #define LED PINJ5
  1313. #elif LED == J6
  1314. #define LED_NAME "J6"
  1315. #undef LED
  1316. #define LED_DDR DDRJ
  1317. #define LED_PORT PORTJ
  1318. #define LED_PIN PINJ
  1319. #define LED PINJ6
  1320. #elif LED == J7
  1321. #define LED_NAME "J7"
  1322. #undef LED
  1323. #define LED_DDR DDRJ
  1324. #define LED_PORT PORTJ
  1325. #define LED_PIN PINJ
  1326. #define LED PINJ7
  1327. #elif LED == K0
  1328. #define LED_NAME "K0"
  1329. #undef LED
  1330. #define LED_DDR DDRK
  1331. #define LED_PORT PORTK
  1332. #define LED_PIN PINK
  1333. #define LED PINK0
  1334. #elif LED == K1
  1335. #define LED_NAME "K1"
  1336. #undef LED
  1337. #define LED_DDR DDRK
  1338. #define LED_PORT PORTK
  1339. #define LED_PIN PINK
  1340. #define LED PINK1
  1341. #elif LED == K2
  1342. #define LED_NAME "K2"
  1343. #undef LED
  1344. #define LED_DDR DDRK
  1345. #define LED_PORT PORTK
  1346. #define LED_PIN PINK
  1347. #define LED PINK2
  1348. #elif LED == K3
  1349. #define LED_NAME "K3"
  1350. #undef LED
  1351. #define LED_DDR DDRK
  1352. #define LED_PORT PORTK
  1353. #define LED_PIN PINK
  1354. #define LED PINK3
  1355. #elif LED == K4
  1356. #define LED_NAME "K4"
  1357. #undef LED
  1358. #define LED_DDR DDRK
  1359. #define LED_PORT PORTK
  1360. #define LED_PIN PINK
  1361. #define LED PINK4
  1362. #elif LED == K5
  1363. #define LED_NAME "K5"
  1364. #undef LED
  1365. #define LED_DDR DDRK
  1366. #define LED_PORT PORTK
  1367. #define LED_PIN PINK
  1368. #define LED PINK5
  1369. #elif LED == K6
  1370. #define LED_NAME "K6"
  1371. #undef LED
  1372. #define LED_DDR DDRK
  1373. #define LED_PORT PORTK
  1374. #define LED_PIN PINK
  1375. #define LED PINK6
  1376. #elif LED == K7
  1377. #define LED_NAME "K7"
  1378. #undef LED
  1379. #define LED_DDR DDRK
  1380. #define LED_PORT PORTK
  1381. #define LED_PIN PINK
  1382. #define LED PINK7
  1383. #elif LED == L0
  1384. #define LED_NAME "L0"
  1385. #undef LED
  1386. #define LED_DDR DDRL
  1387. #define LED_PORT PORTL
  1388. #define LED_PIN PINL
  1389. #define LED PINL0
  1390. #elif LED == L1
  1391. #define LED_NAME "L1"
  1392. #undef LED
  1393. #define LED_DDR DDRL
  1394. #define LED_PORT PORTL
  1395. #define LED_PIN PINL
  1396. #define LED PINL1
  1397. #elif LED == L2
  1398. #define LED_NAME "L2"
  1399. #undef LED
  1400. #define LED_DDR DDRL
  1401. #define LED_PORT PORTL
  1402. #define LED_PIN PINL
  1403. #define LED PINL2
  1404. #elif LED == L3
  1405. #define LED_NAME "L3"
  1406. #undef LED
  1407. #define LED_DDR DDRL
  1408. #define LED_PORT PORTL
  1409. #define LED_PIN PINL
  1410. #define LED PINL3
  1411. #elif LED == L4
  1412. #define LED_NAME "L4"
  1413. #undef LED
  1414. #define LED_DDR DDRL
  1415. #define LED_PORT PORTL
  1416. #define LED_PIN PINL
  1417. #define LED PINL4
  1418. #elif LED == L5
  1419. #define LED_NAME "L5"
  1420. #undef LED
  1421. #define LED_DDR DDRL
  1422. #define LED_PORT PORTL
  1423. #define LED_PIN PINL
  1424. #define LED PINL5
  1425. #elif LED == L6
  1426. #define LED_NAME "L6"
  1427. #undef LED
  1428. #define LED_DDR DDRL
  1429. #define LED_PORT PORTL
  1430. #define LED_PIN PINL
  1431. #define LED PINL6
  1432. #elif LED == L7
  1433. #define LED_NAME "L7"
  1434. #undef LED
  1435. #define LED_DDR DDRL
  1436. #define LED_PORT PORTL
  1437. #define LED_PIN PINL
  1438. #define LED PINL7
  1439. #elif LED == A0
  1440. #define LED_NAME "A0"
  1441. #undef LED
  1442. #define LED_DDR DDRA
  1443. #define LED_PORT PORTA
  1444. #define LED_PIN PINA
  1445. #define LED PINA0
  1446. #elif LED == A1
  1447. #define LED_NAME "A1"
  1448. #undef LED
  1449. #define LED_DDR DDRA
  1450. #define LED_PORT PORTA
  1451. #define LED_PIN PINA
  1452. #define LED PINA1
  1453. #elif LED == A2
  1454. #define LED_NAME "A2"
  1455. #undef LED
  1456. #define LED_DDR DDRA
  1457. #define LED_PORT PORTA
  1458. #define LED_PIN PINA
  1459. #define LED PINA2
  1460. #elif LED == A3
  1461. #define LED_NAME "A3"
  1462. #undef LED
  1463. #define LED_DDR DDRA
  1464. #define LED_PORT PORTA
  1465. #define LED_PIN PINA
  1466. #define LED PINA3
  1467. #elif LED == A4
  1468. #define LED_NAME "A4"
  1469. #undef LED
  1470. #define LED_DDR DDRA
  1471. #define LED_PORT PORTA
  1472. #define LED_PIN PINA
  1473. #define LED PINA4
  1474. #elif LED == A5
  1475. #define LED_NAME "A5"
  1476. #undef LED
  1477. #define LED_DDR DDRA
  1478. #define LED_PORT PORTA
  1479. #define LED_PIN PINA
  1480. #define LED PINA5
  1481. #elif LED == A6
  1482. #define LED_NAME "A6"
  1483. #undef LED
  1484. #define LED_DDR DDRA
  1485. #define LED_PORT PORTA
  1486. #define LED_PIN PINA
  1487. #define LED PINA6
  1488. #elif LED == A7
  1489. #define LED_NAME "A7"
  1490. #undef LED
  1491. #define LED_DDR DDRA
  1492. #define LED_PORT PORTA
  1493. #define LED_PIN PINA
  1494. #define LED PINA7
  1495. #else
  1496. // Stop compilation right away, so we don't get more errors.
  1497. #if LED == -1
  1498. #error Unrecognized LED name. Should be like "B5"
  1499. // Stop compilation right away, so we don't get more errors.
  1500. #pragma GCC diagnostic warning "-Wfatal-errors"
  1501. #error Nonexistent LED PORT. Check datasheet.
  1502. #endif
  1503. #pragma GCC diagnostic warning "-Wfatal-errors"
  1504. #error Unrecognized LED name. Should be like "B5"
  1505. #endif
  1506. #ifdef RS485
  1507. #include "pins_rs485.h"
  1508. #endif
  1509. #if SOFT_UART && defined(SOFTTX) && defined(SOFTRX)
  1510. #include "pins_softuart.h"
  1511. #endif