io_atmega2560.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. //io_atmega2560.h
  2. #ifndef _IO_ATMEGA2560
  3. #define _IO_ATMEGA2560
  4. #define __PIN_P0 PINE
  5. #define __PIN_P1 PINE
  6. #define __PIN_P2 PINE
  7. #define __PIN_P3 PINE
  8. #define __PIN_P4 PING
  9. #define __PIN_P5 PINE
  10. #define __PIN_P6 PINH
  11. #define __PIN_P7 PINH
  12. #define __PIN_P8 PINH
  13. #define __PIN_P9 PINH
  14. #define __PIN_P10 PINB
  15. #define __PIN_P11 PINB
  16. #define __PIN_P12 PINB
  17. #define __PIN_P13 PINB
  18. #define __PIN_P14 PINJ
  19. #define __PIN_P15 PINJ
  20. #define __PIN_P16 PINH
  21. #define __PIN_P17 PINH
  22. #define __PIN_P18 PIND
  23. #define __PIN_P19 PIND
  24. #define __PIN_P20 PIND
  25. #define __PIN_P21 PIND
  26. #define __PIN_P22 PINA
  27. #define __PIN_P23 PINA
  28. #define __PIN_P24 PINA
  29. #define __PIN_P25 PINA
  30. #define __PIN_P26 PINA
  31. #define __PIN_P27 PINA
  32. #define __PIN_P28 PINA
  33. #define __PIN_P29 PINA
  34. #define __PIN_P30 PINC
  35. #define __PIN_P31 PINC
  36. #define __PIN_P32 PINC
  37. #define __PIN_P33 PINC
  38. #define __PIN_P34 PINC
  39. #define __PIN_P35 PINC
  40. #define __PIN_P36 PINC
  41. #define __PIN_P37 PINC
  42. #define __PIN_P38 PIND
  43. #define __PIN_P39 PING
  44. #define __PIN_P40 PING
  45. #define __PIN_P41 PING
  46. #define __PIN_P42 PINL
  47. #define __PIN_P43 PINL
  48. #define __PIN_P44 PINL
  49. #define __PIN_P45 PINL
  50. #define __PIN_P46 PINL
  51. #define __PIN_P47 PINL
  52. #define __PIN_P48 PINL
  53. #define __PIN_P49 PINL
  54. #define __PIN_P50 PINB
  55. #define __PIN_P51 PINB
  56. #define __PIN_P52 PINB
  57. #define __PIN_P53 PINB
  58. #define __PIN_P54 PINF
  59. #define __PIN_P55 PINF
  60. #define __PIN_P56 PINF
  61. #define __PIN_P57 PINF
  62. #define __PIN_P58 PINF
  63. #define __PIN_P59 PINF
  64. #define __PIN_P60 PINF
  65. #define __PIN_P61 PINF
  66. #define __PIN_P62 PINK
  67. #define __PIN_P63 PINK
  68. #define __PIN_P64 PINK
  69. #define __PIN_P65 PINK
  70. #define __PIN_P66 PINK
  71. #define __PIN_P67 PINK
  72. #define __PIN_P68 PINK
  73. #define __PIN_P69 PINK
  74. #define __PIN_P70 PING
  75. #define __PIN_P71 PING
  76. #define __PIN_P72 PINJ
  77. #define __PIN_P73 PINJ
  78. #define __PIN_P74 PINJ
  79. #define __PIN_P75 PINJ
  80. #define __PIN_P76 PINJ
  81. #define __PIN_P77 PINJ
  82. #define __PIN_P78 PINE
  83. #define __PIN_P79 PINE
  84. #define __PIN_P80 PINE
  85. #define __PIN_P81 PIND
  86. #define __PIN_P82 PIND
  87. #define __PIN_P83 PIND
  88. #define __PIN_P84 PINH
  89. #define __PIN_P85 PINH
  90. #define __PORT_P0 PORTE
  91. #define __PORT_P1 PORTE
  92. #define __PORT_P2 PORTE
  93. #define __PORT_P3 PORTE
  94. #define __PORT_P4 PORTG
  95. #define __PORT_P5 PORTE
  96. #define __PORT_P6 PORTH
  97. #define __PORT_P7 PORTH
  98. #define __PORT_P8 PORTH
  99. #define __PORT_P9 PORTH
  100. #define __PORT_P10 PORTB
  101. #define __PORT_P11 PORTB
  102. #define __PORT_P12 PORTB
  103. #define __PORT_P13 PORTB
  104. #define __PORT_P14 PORTJ
  105. #define __PORT_P15 PORTJ
  106. #define __PORT_P16 PORTH
  107. #define __PORT_P17 PORTH
  108. #define __PORT_P18 PORTD
  109. #define __PORT_P19 PORTD
  110. #define __PORT_P20 PORTD
  111. #define __PORT_P21 PORTD
  112. #define __PORT_P22 PORTA
  113. #define __PORT_P23 PORTA
  114. #define __PORT_P24 PORTA
  115. #define __PORT_P25 PORTA
  116. #define __PORT_P26 PORTA
  117. #define __PORT_P27 PORTA
  118. #define __PORT_P28 PORTA
  119. #define __PORT_P29 PORTA
  120. #define __PORT_P30 PORTC
  121. #define __PORT_P31 PORTC
  122. #define __PORT_P32 PORTC
  123. #define __PORT_P33 PORTC
  124. #define __PORT_P34 PORTC
  125. #define __PORT_P35 PORTC
  126. #define __PORT_P36 PORTC
  127. #define __PORT_P37 PORTC
  128. #define __PORT_P38 PORTD
  129. #define __PORT_P39 PORTG
  130. #define __PORT_P40 PORTG
  131. #define __PORT_P41 PORTG
  132. #define __PORT_P42 PORTL
  133. #define __PORT_P43 PORTL
  134. #define __PORT_P44 PORTL
  135. #define __PORT_P45 PORTL
  136. #define __PORT_P46 PORTL
  137. #define __PORT_P47 PORTL
  138. #define __PORT_P48 PORTL
  139. #define __PORT_P49 PORTL
  140. #define __PORT_P50 PORTB
  141. #define __PORT_P51 PORTB
  142. #define __PORT_P52 PORTB
  143. #define __PORT_P53 PORTB
  144. #define __PORT_P54 PORTF
  145. #define __PORT_P55 PORTF
  146. #define __PORT_P56 PORTF
  147. #define __PORT_P57 PORTF
  148. #define __PORT_P58 PORTF
  149. #define __PORT_P59 PORTF
  150. #define __PORT_P60 PORTF
  151. #define __PORT_P61 PORTF
  152. #define __PORT_P62 PORTK
  153. #define __PORT_P63 PORTK
  154. #define __PORT_P64 PORTK
  155. #define __PORT_P65 PORTK
  156. #define __PORT_P66 PORTK
  157. #define __PORT_P67 PORTK
  158. #define __PORT_P68 PORTK
  159. #define __PORT_P69 PORTK
  160. #define __PORT_P70 PORTG
  161. #define __PORT_P71 PORTG
  162. #define __PORT_P72 PORTJ
  163. #define __PORT_P73 PORTJ
  164. #define __PORT_P74 PORTJ
  165. #define __PORT_P75 PORTJ
  166. #define __PORT_P76 PORTJ
  167. #define __PORT_P77 PORTJ
  168. #define __PORT_P78 PORTE
  169. #define __PORT_P79 PORTE
  170. #define __PORT_P80 PORTE
  171. #define __PORT_P81 PORTD
  172. #define __PORT_P82 PORTD
  173. #define __PORT_P83 PORTD
  174. #define __PORT_P84 PORTH
  175. #define __PORT_P85 PORTH
  176. #define __DDR_P0 DDRE
  177. #define __DDR_P1 DDRE
  178. #define __DDR_P2 DDRE
  179. #define __DDR_P3 DDRE
  180. #define __DDR_P4 DDRG
  181. #define __DDR_P5 DDRE
  182. #define __DDR_P6 DDRH
  183. #define __DDR_P7 DDRH
  184. #define __DDR_P8 DDRH
  185. #define __DDR_P9 DDRH
  186. #define __DDR_P10 DDRB
  187. #define __DDR_P11 DDRB
  188. #define __DDR_P12 DDRB
  189. #define __DDR_P13 DDRB
  190. #define __DDR_P14 DDRJ
  191. #define __DDR_P15 DDRJ
  192. #define __DDR_P16 DDRH
  193. #define __DDR_P17 DDRH
  194. #define __DDR_P18 DDRD
  195. #define __DDR_P19 DDRD
  196. #define __DDR_P20 DDRD
  197. #define __DDR_P21 DDRD
  198. #define __DDR_P22 DDRA
  199. #define __DDR_P23 DDRA
  200. #define __DDR_P24 DDRA
  201. #define __DDR_P25 DDRA
  202. #define __DDR_P26 DDRA
  203. #define __DDR_P27 DDRA
  204. #define __DDR_P28 DDRA
  205. #define __DDR_P29 DDRA
  206. #define __DDR_P30 DDRC
  207. #define __DDR_P31 DDRC
  208. #define __DDR_P32 DDRC
  209. #define __DDR_P33 DDRC
  210. #define __DDR_P34 DDRC
  211. #define __DDR_P35 DDRC
  212. #define __DDR_P36 DDRC
  213. #define __DDR_P37 DDRC
  214. #define __DDR_P38 DDRD
  215. #define __DDR_P39 DDRG
  216. #define __DDR_P40 DDRG
  217. #define __DDR_P41 DDRG
  218. #define __DDR_P42 DDRL
  219. #define __DDR_P43 DDRL
  220. #define __DDR_P44 DDRL
  221. #define __DDR_P45 DDRL
  222. #define __DDR_P46 DDRL
  223. #define __DDR_P47 DDRL
  224. #define __DDR_P48 DDRL
  225. #define __DDR_P49 DDRL
  226. #define __DDR_P50 DDRB
  227. #define __DDR_P51 DDRB
  228. #define __DDR_P52 DDRB
  229. #define __DDR_P53 DDRB
  230. #define __DDR_P54 DDRF
  231. #define __DDR_P55 DDRF
  232. #define __DDR_P56 DDRF
  233. #define __DDR_P57 DDRF
  234. #define __DDR_P58 DDRF
  235. #define __DDR_P59 DDRF
  236. #define __DDR_P60 DDRF
  237. #define __DDR_P61 DDRF
  238. #define __DDR_P62 DDRK
  239. #define __DDR_P63 DDRK
  240. #define __DDR_P64 DDRK
  241. #define __DDR_P65 DDRK
  242. #define __DDR_P66 DDRK
  243. #define __DDR_P67 DDRK
  244. #define __DDR_P68 DDRK
  245. #define __DDR_P69 DDRK
  246. #define __DDR_P70 DDRG
  247. #define __DDR_P71 DDRG
  248. #define __DDR_P72 DDRJ
  249. #define __DDR_P73 DDRJ
  250. #define __DDR_P74 DDRJ
  251. #define __DDR_P75 DDRJ
  252. #define __DDR_P76 DDRJ
  253. #define __DDR_P77 DDRJ
  254. #define __DDR_P78 DDRE
  255. #define __DDR_P79 DDRE
  256. #define __DDR_P80 DDRE
  257. #define __DDR_P81 DDRD
  258. #define __DDR_P82 DDRD
  259. #define __DDR_P83 DDRD
  260. #define __DDR_P84 DDRH
  261. #define __DDR_P85 DDRH
  262. #define __BIT_P0 0
  263. #define __BIT_P1 1
  264. #define __BIT_P2 4
  265. #define __BIT_P3 5
  266. #define __BIT_P4 5
  267. #define __BIT_P5 3
  268. #define __BIT_P6 3
  269. #define __BIT_P7 4
  270. #define __BIT_P8 5
  271. #define __BIT_P9 6
  272. #define __BIT_P10 4
  273. #define __BIT_P11 5
  274. #define __BIT_P12 6
  275. #define __BIT_P13 7
  276. #define __BIT_P14 1
  277. #define __BIT_P15 0
  278. #define __BIT_P16 0
  279. #define __BIT_P17 1
  280. #define __BIT_P18 3
  281. #define __BIT_P19 2
  282. #define __BIT_P20 1
  283. #define __BIT_P21 0
  284. #define __BIT_P22 0
  285. #define __BIT_P23 1
  286. #define __BIT_P24 2
  287. #define __BIT_P25 3
  288. #define __BIT_P26 4
  289. #define __BIT_P27 5
  290. #define __BIT_P28 6
  291. #define __BIT_P29 7
  292. #define __BIT_P30 7
  293. #define __BIT_P31 6
  294. #define __BIT_P32 5
  295. #define __BIT_P33 4
  296. #define __BIT_P34 3
  297. #define __BIT_P35 2
  298. #define __BIT_P36 1
  299. #define __BIT_P37 0
  300. #define __BIT_P38 7
  301. #define __BIT_P39 2
  302. #define __BIT_P40 1
  303. #define __BIT_P41 0
  304. #define __BIT_P42 7
  305. #define __BIT_P43 6
  306. #define __BIT_P44 5
  307. #define __BIT_P45 4
  308. #define __BIT_P46 3
  309. #define __BIT_P47 2
  310. #define __BIT_P48 1
  311. #define __BIT_P49 0
  312. #define __BIT_P50 3
  313. #define __BIT_P51 2
  314. #define __BIT_P52 1
  315. #define __BIT_P53 0
  316. #define __BIT_P54 0
  317. #define __BIT_P55 1
  318. #define __BIT_P56 2
  319. #define __BIT_P57 3
  320. #define __BIT_P58 4
  321. #define __BIT_P59 5
  322. #define __BIT_P60 6
  323. #define __BIT_P61 7
  324. #define __BIT_P62 0
  325. #define __BIT_P63 1
  326. #define __BIT_P64 2
  327. #define __BIT_P65 3
  328. #define __BIT_P66 4
  329. #define __BIT_P67 5
  330. #define __BIT_P68 6
  331. #define __BIT_P69 7
  332. #define __BIT_P70 4
  333. #define __BIT_P71 3
  334. #define __BIT_P72 2
  335. #define __BIT_P73 3
  336. #define __BIT_P74 7
  337. #define __BIT_P75 4
  338. #define __BIT_P76 5
  339. #define __BIT_P77 6
  340. #define __BIT_P78 2
  341. #define __BIT_P79 6
  342. #define __BIT_P80 7
  343. #define __BIT_P81 4
  344. #define __BIT_P82 5
  345. #define __BIT_P83 6
  346. #define __BIT_P84 2
  347. #define __BIT_P85 7
  348. #define __BIT(pin) __BIT_P##pin
  349. #define __MSK(pin) (1 << __BIT(pin))
  350. #define __PIN(pin) __PIN_P##pin
  351. #define __PORT(pin) __PORT_P##pin
  352. #define __DDR(pin) __DDR_P##pin
  353. #define PIN(pin) __PIN(pin)
  354. #define PORT(pin) __PORT(pin)
  355. #define DDR(pin) __DDR(pin)
  356. #define PIN_INP(pin) DDR(pin) &= ~__MSK(pin)
  357. #define PIN_OUT(pin) DDR(pin) |= __MSK(pin)
  358. #define PIN_CLR(pin) PORT(pin) &= ~__MSK(pin)
  359. #define PIN_SET(pin) PORT(pin) |= __MSK(pin)
  360. #define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin);
  361. #define PIN_GET(pin) (PIN(pin) & __MSK(pin))
  362. #define PIN_INQ(pin) (PORT(pin) & __MSK(pin))
  363. #endif //_IO_ATMEGA2560