Teensy 4.1 core updated for 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.

1997 lines
66KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * 1. The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * 2. If the Software is incorporated into a build system that allows
  17. * selection among a list of target devices, then similar target
  18. * devices manufactured by PJRC.COM must be included in the list of
  19. * target devices and selectable in the same manner.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. #ifndef _core_pins_h_
  31. #define _core_pins_h_
  32. #include "kinetis.h"
  33. #include "pins_arduino.h"
  34. #define HIGH 1
  35. #define LOW 0
  36. #define INPUT 0
  37. #define OUTPUT 1
  38. #define INPUT_PULLUP 2
  39. #define INPUT_PULLDOWN 3
  40. #define OUTPUT_OPENDRAIN 4
  41. #define LSBFIRST 0
  42. #define MSBFIRST 1
  43. #define _BV(n) (1<<(n))
  44. #define CHANGE 4
  45. #define FALLING 2
  46. #define RISING 3
  47. // Pin Arduino
  48. // 0 B16 RXD
  49. // 1 B17 TXD
  50. // 2 D0
  51. // 3 A12 FTM1_CH0
  52. // 4 A13 FTM1_CH1
  53. // 5 D7 FTM0_CH7 OC0B/T1
  54. // 6 D4 FTM0_CH4 OC0A
  55. // 7 D2
  56. // 8 D3 ICP1
  57. // 9 C3 FTM0_CH2 OC1A
  58. // 10 C4 FTM0_CH3 SS/OC1B
  59. // 11 C6 MOSI/OC2A
  60. // 12 C7 MISO
  61. // 13 C5 SCK
  62. // 14 D1
  63. // 15 C0
  64. // 16 B0 (FTM1_CH0)
  65. // 17 B1 (FTM1_CH1)
  66. // 18 B3 SDA
  67. // 19 B2 SCL
  68. // 20 D5 FTM0_CH5
  69. // 21 D6 FTM0_CH6
  70. // 22 C1 FTM0_CH0
  71. // 23 C2 FTM0_CH1
  72. // 24 A5 (FTM0_CH2)
  73. // 25 B19
  74. // 26 E1
  75. // 27 C9
  76. // 28 C8
  77. // 29 C10
  78. // 30 C11
  79. // 31 E0
  80. // 32 B18
  81. // 33 A4 (FTM0_CH1)
  82. // (34) analog only
  83. // (35) analog only
  84. // (36) analog only
  85. // (37) analog only
  86. // not available to user:
  87. // A0 FTM0_CH5 SWD Clock
  88. // A1 FTM0_CH6 USB ID
  89. // A2 FTM0_CH7 SWD Trace
  90. // A3 FTM0_CH0 SWD Data
  91. #if defined(__MK20DX128__)
  92. #define CORE_NUM_TOTAL_PINS 34
  93. #define CORE_NUM_DIGITAL 34
  94. #define CORE_NUM_INTERRUPT 34
  95. #define CORE_NUM_ANALOG 14
  96. #define CORE_NUM_PWM 10
  97. #elif defined(__MK20DX256__)
  98. #define CORE_NUM_TOTAL_PINS 34
  99. #define CORE_NUM_DIGITAL 34
  100. #define CORE_NUM_INTERRUPT 34
  101. #define CORE_NUM_ANALOG 21
  102. #define CORE_NUM_PWM 12
  103. #elif defined(__MKL26Z64__)
  104. #define CORE_NUM_TOTAL_PINS 27
  105. #define CORE_NUM_DIGITAL 27
  106. #define CORE_NUM_INTERRUPT 24 // really only 18, but 6 "holes"
  107. #define CORE_NUM_ANALOG 13
  108. #define CORE_NUM_PWM 10
  109. #elif defined(__MK64FX512__)
  110. #define CORE_NUM_TOTAL_PINS 64
  111. #define CORE_NUM_DIGITAL 64
  112. #define CORE_NUM_INTERRUPT 64
  113. #define CORE_NUM_ANALOG 27
  114. #define CORE_NUM_PWM 20
  115. #elif defined(__MK66FX1M0__)
  116. #define CORE_NUM_TOTAL_PINS 64
  117. #define CORE_NUM_DIGITAL 64
  118. #define CORE_NUM_INTERRUPT 64
  119. #define CORE_NUM_ANALOG 25
  120. #define CORE_NUM_PWM 22
  121. #endif
  122. #if defined(__MK20DX128__) || defined(__MK20DX256__)
  123. #define CORE_PIN0_BIT 16
  124. #define CORE_PIN1_BIT 17
  125. #define CORE_PIN2_BIT 0
  126. #define CORE_PIN3_BIT 12
  127. #define CORE_PIN4_BIT 13
  128. #define CORE_PIN5_BIT 7
  129. #define CORE_PIN6_BIT 4
  130. #define CORE_PIN7_BIT 2
  131. #define CORE_PIN8_BIT 3
  132. #define CORE_PIN9_BIT 3
  133. #define CORE_PIN10_BIT 4
  134. #define CORE_PIN11_BIT 6
  135. #define CORE_PIN12_BIT 7
  136. #define CORE_PIN13_BIT 5
  137. #define CORE_PIN14_BIT 1
  138. #define CORE_PIN15_BIT 0
  139. #define CORE_PIN16_BIT 0
  140. #define CORE_PIN17_BIT 1
  141. #define CORE_PIN18_BIT 3
  142. #define CORE_PIN19_BIT 2
  143. #define CORE_PIN20_BIT 5
  144. #define CORE_PIN21_BIT 6
  145. #define CORE_PIN22_BIT 1
  146. #define CORE_PIN23_BIT 2
  147. #define CORE_PIN24_BIT 5
  148. #define CORE_PIN25_BIT 19
  149. #define CORE_PIN26_BIT 1
  150. #define CORE_PIN27_BIT 9
  151. #define CORE_PIN28_BIT 8
  152. #define CORE_PIN29_BIT 10
  153. #define CORE_PIN30_BIT 11
  154. #define CORE_PIN31_BIT 0
  155. #define CORE_PIN32_BIT 18
  156. #define CORE_PIN33_BIT 4
  157. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  158. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  159. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  160. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  161. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  162. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  163. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  164. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  165. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  166. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  167. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  168. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  169. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  170. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  171. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  172. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  173. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  174. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  175. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  176. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  177. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  178. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  179. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  180. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  181. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  182. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  183. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  184. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  185. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  186. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  187. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  188. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  189. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  190. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  191. #define CORE_PIN0_PORTREG GPIOB_PDOR
  192. #define CORE_PIN1_PORTREG GPIOB_PDOR
  193. #define CORE_PIN2_PORTREG GPIOD_PDOR
  194. #define CORE_PIN3_PORTREG GPIOA_PDOR
  195. #define CORE_PIN4_PORTREG GPIOA_PDOR
  196. #define CORE_PIN5_PORTREG GPIOD_PDOR
  197. #define CORE_PIN6_PORTREG GPIOD_PDOR
  198. #define CORE_PIN7_PORTREG GPIOD_PDOR
  199. #define CORE_PIN8_PORTREG GPIOD_PDOR
  200. #define CORE_PIN9_PORTREG GPIOC_PDOR
  201. #define CORE_PIN10_PORTREG GPIOC_PDOR
  202. #define CORE_PIN11_PORTREG GPIOC_PDOR
  203. #define CORE_PIN12_PORTREG GPIOC_PDOR
  204. #define CORE_PIN13_PORTREG GPIOC_PDOR
  205. #define CORE_PIN14_PORTREG GPIOD_PDOR
  206. #define CORE_PIN15_PORTREG GPIOC_PDOR
  207. #define CORE_PIN16_PORTREG GPIOB_PDOR
  208. #define CORE_PIN17_PORTREG GPIOB_PDOR
  209. #define CORE_PIN18_PORTREG GPIOB_PDOR
  210. #define CORE_PIN19_PORTREG GPIOB_PDOR
  211. #define CORE_PIN20_PORTREG GPIOD_PDOR
  212. #define CORE_PIN21_PORTREG GPIOD_PDOR
  213. #define CORE_PIN22_PORTREG GPIOC_PDOR
  214. #define CORE_PIN23_PORTREG GPIOC_PDOR
  215. #define CORE_PIN24_PORTREG GPIOA_PDOR
  216. #define CORE_PIN25_PORTREG GPIOB_PDOR
  217. #define CORE_PIN26_PORTREG GPIOE_PDOR
  218. #define CORE_PIN27_PORTREG GPIOC_PDOR
  219. #define CORE_PIN28_PORTREG GPIOC_PDOR
  220. #define CORE_PIN29_PORTREG GPIOC_PDOR
  221. #define CORE_PIN30_PORTREG GPIOC_PDOR
  222. #define CORE_PIN31_PORTREG GPIOE_PDOR
  223. #define CORE_PIN32_PORTREG GPIOB_PDOR
  224. #define CORE_PIN33_PORTREG GPIOA_PDOR
  225. #define CORE_PIN0_PORTSET GPIOB_PSOR
  226. #define CORE_PIN1_PORTSET GPIOB_PSOR
  227. #define CORE_PIN2_PORTSET GPIOD_PSOR
  228. #define CORE_PIN3_PORTSET GPIOA_PSOR
  229. #define CORE_PIN4_PORTSET GPIOA_PSOR
  230. #define CORE_PIN5_PORTSET GPIOD_PSOR
  231. #define CORE_PIN6_PORTSET GPIOD_PSOR
  232. #define CORE_PIN7_PORTSET GPIOD_PSOR
  233. #define CORE_PIN8_PORTSET GPIOD_PSOR
  234. #define CORE_PIN9_PORTSET GPIOC_PSOR
  235. #define CORE_PIN10_PORTSET GPIOC_PSOR
  236. #define CORE_PIN11_PORTSET GPIOC_PSOR
  237. #define CORE_PIN12_PORTSET GPIOC_PSOR
  238. #define CORE_PIN13_PORTSET GPIOC_PSOR
  239. #define CORE_PIN14_PORTSET GPIOD_PSOR
  240. #define CORE_PIN15_PORTSET GPIOC_PSOR
  241. #define CORE_PIN16_PORTSET GPIOB_PSOR
  242. #define CORE_PIN17_PORTSET GPIOB_PSOR
  243. #define CORE_PIN18_PORTSET GPIOB_PSOR
  244. #define CORE_PIN19_PORTSET GPIOB_PSOR
  245. #define CORE_PIN20_PORTSET GPIOD_PSOR
  246. #define CORE_PIN21_PORTSET GPIOD_PSOR
  247. #define CORE_PIN22_PORTSET GPIOC_PSOR
  248. #define CORE_PIN23_PORTSET GPIOC_PSOR
  249. #define CORE_PIN24_PORTSET GPIOA_PSOR
  250. #define CORE_PIN25_PORTSET GPIOB_PSOR
  251. #define CORE_PIN26_PORTSET GPIOE_PSOR
  252. #define CORE_PIN27_PORTSET GPIOC_PSOR
  253. #define CORE_PIN28_PORTSET GPIOC_PSOR
  254. #define CORE_PIN29_PORTSET GPIOC_PSOR
  255. #define CORE_PIN30_PORTSET GPIOC_PSOR
  256. #define CORE_PIN31_PORTSET GPIOE_PSOR
  257. #define CORE_PIN32_PORTSET GPIOB_PSOR
  258. #define CORE_PIN33_PORTSET GPIOA_PSOR
  259. #define CORE_PIN0_PORTCLEAR GPIOB_PCOR
  260. #define CORE_PIN1_PORTCLEAR GPIOB_PCOR
  261. #define CORE_PIN2_PORTCLEAR GPIOD_PCOR
  262. #define CORE_PIN3_PORTCLEAR GPIOA_PCOR
  263. #define CORE_PIN4_PORTCLEAR GPIOA_PCOR
  264. #define CORE_PIN5_PORTCLEAR GPIOD_PCOR
  265. #define CORE_PIN6_PORTCLEAR GPIOD_PCOR
  266. #define CORE_PIN7_PORTCLEAR GPIOD_PCOR
  267. #define CORE_PIN8_PORTCLEAR GPIOD_PCOR
  268. #define CORE_PIN9_PORTCLEAR GPIOC_PCOR
  269. #define CORE_PIN10_PORTCLEAR GPIOC_PCOR
  270. #define CORE_PIN11_PORTCLEAR GPIOC_PCOR
  271. #define CORE_PIN12_PORTCLEAR GPIOC_PCOR
  272. #define CORE_PIN13_PORTCLEAR GPIOC_PCOR
  273. #define CORE_PIN14_PORTCLEAR GPIOD_PCOR
  274. #define CORE_PIN15_PORTCLEAR GPIOC_PCOR
  275. #define CORE_PIN16_PORTCLEAR GPIOB_PCOR
  276. #define CORE_PIN17_PORTCLEAR GPIOB_PCOR
  277. #define CORE_PIN18_PORTCLEAR GPIOB_PCOR
  278. #define CORE_PIN19_PORTCLEAR GPIOB_PCOR
  279. #define CORE_PIN20_PORTCLEAR GPIOD_PCOR
  280. #define CORE_PIN21_PORTCLEAR GPIOD_PCOR
  281. #define CORE_PIN22_PORTCLEAR GPIOC_PCOR
  282. #define CORE_PIN23_PORTCLEAR GPIOC_PCOR
  283. #define CORE_PIN24_PORTCLEAR GPIOA_PCOR
  284. #define CORE_PIN25_PORTCLEAR GPIOB_PCOR
  285. #define CORE_PIN26_PORTCLEAR GPIOE_PCOR
  286. #define CORE_PIN27_PORTCLEAR GPIOC_PCOR
  287. #define CORE_PIN28_PORTCLEAR GPIOC_PCOR
  288. #define CORE_PIN29_PORTCLEAR GPIOC_PCOR
  289. #define CORE_PIN30_PORTCLEAR GPIOC_PCOR
  290. #define CORE_PIN31_PORTCLEAR GPIOE_PCOR
  291. #define CORE_PIN32_PORTCLEAR GPIOB_PCOR
  292. #define CORE_PIN33_PORTCLEAR GPIOA_PCOR
  293. #define CORE_PIN0_DDRREG GPIOB_PDDR
  294. #define CORE_PIN1_DDRREG GPIOB_PDDR
  295. #define CORE_PIN2_DDRREG GPIOD_PDDR
  296. #define CORE_PIN3_DDRREG GPIOA_PDDR
  297. #define CORE_PIN4_DDRREG GPIOA_PDDR
  298. #define CORE_PIN5_DDRREG GPIOD_PDDR
  299. #define CORE_PIN6_DDRREG GPIOD_PDDR
  300. #define CORE_PIN7_DDRREG GPIOD_PDDR
  301. #define CORE_PIN8_DDRREG GPIOD_PDDR
  302. #define CORE_PIN9_DDRREG GPIOC_PDDR
  303. #define CORE_PIN10_DDRREG GPIOC_PDDR
  304. #define CORE_PIN11_DDRREG GPIOC_PDDR
  305. #define CORE_PIN12_DDRREG GPIOC_PDDR
  306. #define CORE_PIN13_DDRREG GPIOC_PDDR
  307. #define CORE_PIN14_DDRREG GPIOD_PDDR
  308. #define CORE_PIN15_DDRREG GPIOC_PDDR
  309. #define CORE_PIN16_DDRREG GPIOB_PDDR
  310. #define CORE_PIN17_DDRREG GPIOB_PDDR
  311. #define CORE_PIN18_DDRREG GPIOB_PDDR
  312. #define CORE_PIN19_DDRREG GPIOB_PDDR
  313. #define CORE_PIN20_DDRREG GPIOD_PDDR
  314. #define CORE_PIN21_DDRREG GPIOD_PDDR
  315. #define CORE_PIN22_DDRREG GPIOC_PDDR
  316. #define CORE_PIN23_DDRREG GPIOC_PDDR
  317. #define CORE_PIN24_DDRREG GPIOA_PDDR
  318. #define CORE_PIN25_DDRREG GPIOB_PDDR
  319. #define CORE_PIN26_DDRREG GPIOE_PDDR
  320. #define CORE_PIN27_DDRREG GPIOC_PDDR
  321. #define CORE_PIN28_DDRREG GPIOC_PDDR
  322. #define CORE_PIN29_DDRREG GPIOC_PDDR
  323. #define CORE_PIN30_DDRREG GPIOC_PDDR
  324. #define CORE_PIN31_DDRREG GPIOE_PDDR
  325. #define CORE_PIN32_DDRREG GPIOB_PDDR
  326. #define CORE_PIN33_DDRREG GPIOA_PDDR
  327. #define CORE_PIN0_PINREG GPIOB_PDIR
  328. #define CORE_PIN1_PINREG GPIOB_PDIR
  329. #define CORE_PIN2_PINREG GPIOD_PDIR
  330. #define CORE_PIN3_PINREG GPIOA_PDIR
  331. #define CORE_PIN4_PINREG GPIOA_PDIR
  332. #define CORE_PIN5_PINREG GPIOD_PDIR
  333. #define CORE_PIN6_PINREG GPIOD_PDIR
  334. #define CORE_PIN7_PINREG GPIOD_PDIR
  335. #define CORE_PIN8_PINREG GPIOD_PDIR
  336. #define CORE_PIN9_PINREG GPIOC_PDIR
  337. #define CORE_PIN10_PINREG GPIOC_PDIR
  338. #define CORE_PIN11_PINREG GPIOC_PDIR
  339. #define CORE_PIN12_PINREG GPIOC_PDIR
  340. #define CORE_PIN13_PINREG GPIOC_PDIR
  341. #define CORE_PIN14_PINREG GPIOD_PDIR
  342. #define CORE_PIN15_PINREG GPIOC_PDIR
  343. #define CORE_PIN16_PINREG GPIOB_PDIR
  344. #define CORE_PIN17_PINREG GPIOB_PDIR
  345. #define CORE_PIN18_PINREG GPIOB_PDIR
  346. #define CORE_PIN19_PINREG GPIOB_PDIR
  347. #define CORE_PIN20_PINREG GPIOD_PDIR
  348. #define CORE_PIN21_PINREG GPIOD_PDIR
  349. #define CORE_PIN22_PINREG GPIOC_PDIR
  350. #define CORE_PIN23_PINREG GPIOC_PDIR
  351. #define CORE_PIN24_PINREG GPIOA_PDIR
  352. #define CORE_PIN25_PINREG GPIOB_PDIR
  353. #define CORE_PIN26_PINREG GPIOE_PDIR
  354. #define CORE_PIN27_PINREG GPIOC_PDIR
  355. #define CORE_PIN28_PINREG GPIOC_PDIR
  356. #define CORE_PIN29_PINREG GPIOC_PDIR
  357. #define CORE_PIN30_PINREG GPIOC_PDIR
  358. #define CORE_PIN31_PINREG GPIOE_PDIR
  359. #define CORE_PIN32_PINREG GPIOB_PDIR
  360. #define CORE_PIN33_PINREG GPIOA_PDIR
  361. #define CORE_PIN0_CONFIG PORTB_PCR16
  362. #define CORE_PIN1_CONFIG PORTB_PCR17
  363. #define CORE_PIN2_CONFIG PORTD_PCR0
  364. #define CORE_PIN3_CONFIG PORTA_PCR12
  365. #define CORE_PIN4_CONFIG PORTA_PCR13
  366. #define CORE_PIN5_CONFIG PORTD_PCR7
  367. #define CORE_PIN6_CONFIG PORTD_PCR4
  368. #define CORE_PIN7_CONFIG PORTD_PCR2
  369. #define CORE_PIN8_CONFIG PORTD_PCR3
  370. #define CORE_PIN9_CONFIG PORTC_PCR3
  371. #define CORE_PIN10_CONFIG PORTC_PCR4
  372. #define CORE_PIN11_CONFIG PORTC_PCR6
  373. #define CORE_PIN12_CONFIG PORTC_PCR7
  374. #define CORE_PIN13_CONFIG PORTC_PCR5
  375. #define CORE_PIN14_CONFIG PORTD_PCR1
  376. #define CORE_PIN15_CONFIG PORTC_PCR0
  377. #define CORE_PIN16_CONFIG PORTB_PCR0
  378. #define CORE_PIN17_CONFIG PORTB_PCR1
  379. #define CORE_PIN18_CONFIG PORTB_PCR3
  380. #define CORE_PIN19_CONFIG PORTB_PCR2
  381. #define CORE_PIN20_CONFIG PORTD_PCR5
  382. #define CORE_PIN21_CONFIG PORTD_PCR6
  383. #define CORE_PIN22_CONFIG PORTC_PCR1
  384. #define CORE_PIN23_CONFIG PORTC_PCR2
  385. #define CORE_PIN24_CONFIG PORTA_PCR5
  386. #define CORE_PIN25_CONFIG PORTB_PCR19
  387. #define CORE_PIN26_CONFIG PORTE_PCR1
  388. #define CORE_PIN27_CONFIG PORTC_PCR9
  389. #define CORE_PIN28_CONFIG PORTC_PCR8
  390. #define CORE_PIN29_CONFIG PORTC_PCR10
  391. #define CORE_PIN30_CONFIG PORTC_PCR11
  392. #define CORE_PIN31_CONFIG PORTE_PCR0
  393. #define CORE_PIN32_CONFIG PORTB_PCR18
  394. #define CORE_PIN33_CONFIG PORTA_PCR4
  395. #define CORE_ADC0_PIN 14
  396. #define CORE_ADC1_PIN 15
  397. #define CORE_ADC2_PIN 16
  398. #define CORE_ADC3_PIN 17
  399. #define CORE_ADC4_PIN 18
  400. #define CORE_ADC5_PIN 19
  401. #define CORE_ADC6_PIN 20
  402. #define CORE_ADC7_PIN 21
  403. #define CORE_ADC8_PIN 22
  404. #define CORE_ADC9_PIN 23
  405. #define CORE_ADC10_PIN 34
  406. #define CORE_ADC11_PIN 35
  407. #define CORE_ADC12_PIN 36
  408. #define CORE_ADC13_PIN 37
  409. #define CORE_RXD0_PIN 0
  410. #define CORE_TXD0_PIN 1
  411. #define CORE_RXD1_PIN 9
  412. #define CORE_TXD1_PIN 10
  413. #define CORE_RXD2_PIN 7
  414. #define CORE_TXD2_PIN 8
  415. #define CORE_INT0_PIN 0
  416. #define CORE_INT1_PIN 1
  417. #define CORE_INT2_PIN 2
  418. #define CORE_INT3_PIN 3
  419. #define CORE_INT4_PIN 4
  420. #define CORE_INT5_PIN 5
  421. #define CORE_INT6_PIN 6
  422. #define CORE_INT7_PIN 7
  423. #define CORE_INT8_PIN 8
  424. #define CORE_INT9_PIN 9
  425. #define CORE_INT10_PIN 10
  426. #define CORE_INT11_PIN 11
  427. #define CORE_INT12_PIN 12
  428. #define CORE_INT13_PIN 13
  429. #define CORE_INT14_PIN 14
  430. #define CORE_INT15_PIN 15
  431. #define CORE_INT16_PIN 16
  432. #define CORE_INT17_PIN 17
  433. #define CORE_INT18_PIN 18
  434. #define CORE_INT19_PIN 19
  435. #define CORE_INT20_PIN 20
  436. #define CORE_INT21_PIN 21
  437. #define CORE_INT22_PIN 22
  438. #define CORE_INT23_PIN 23
  439. #define CORE_INT24_PIN 24
  440. #define CORE_INT25_PIN 25
  441. #define CORE_INT26_PIN 26
  442. #define CORE_INT27_PIN 27
  443. #define CORE_INT28_PIN 28
  444. #define CORE_INT29_PIN 29
  445. #define CORE_INT30_PIN 30
  446. #define CORE_INT31_PIN 31
  447. #define CORE_INT32_PIN 32
  448. #define CORE_INT33_PIN 33
  449. #define CORE_INT_EVERY_PIN 1
  450. #elif defined(__MKL26Z64__)
  451. #define CORE_PIN0_BIT 16
  452. #define CORE_PIN1_BIT 17
  453. #define CORE_PIN2_BIT 0
  454. #define CORE_PIN3_BIT 1
  455. #define CORE_PIN4_BIT 2
  456. #define CORE_PIN5_BIT 7
  457. #define CORE_PIN6_BIT 4
  458. #define CORE_PIN7_BIT 2
  459. #define CORE_PIN8_BIT 3
  460. #define CORE_PIN9_BIT 3
  461. #define CORE_PIN10_BIT 4
  462. #define CORE_PIN11_BIT 6
  463. #define CORE_PIN12_BIT 7
  464. #define CORE_PIN13_BIT 5
  465. #define CORE_PIN14_BIT 1
  466. #define CORE_PIN15_BIT 0
  467. #define CORE_PIN16_BIT 0
  468. #define CORE_PIN17_BIT 1
  469. #define CORE_PIN18_BIT 3
  470. #define CORE_PIN19_BIT 2
  471. #define CORE_PIN20_BIT 5
  472. #define CORE_PIN21_BIT 6
  473. #define CORE_PIN22_BIT 1
  474. #define CORE_PIN23_BIT 2
  475. #define CORE_PIN24_BIT 20
  476. #define CORE_PIN25_BIT 21
  477. #define CORE_PIN26_BIT 30
  478. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  479. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  480. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  481. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  482. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  483. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  484. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  485. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  486. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  487. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  488. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  489. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  490. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  491. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  492. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  493. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  494. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  495. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  496. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  497. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  498. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  499. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  500. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  501. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  502. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  503. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  504. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  505. #define CORE_PIN0_PORTREG FGPIOB_PDOR
  506. #define CORE_PIN1_PORTREG FGPIOB_PDOR
  507. #define CORE_PIN2_PORTREG FGPIOD_PDOR
  508. #define CORE_PIN3_PORTREG FGPIOA_PDOR
  509. #define CORE_PIN4_PORTREG FGPIOA_PDOR
  510. #define CORE_PIN5_PORTREG FGPIOD_PDOR
  511. #define CORE_PIN6_PORTREG FGPIOD_PDOR
  512. #define CORE_PIN7_PORTREG FGPIOD_PDOR
  513. #define CORE_PIN8_PORTREG FGPIOD_PDOR
  514. #define CORE_PIN9_PORTREG FGPIOC_PDOR
  515. #define CORE_PIN10_PORTREG FGPIOC_PDOR
  516. #define CORE_PIN11_PORTREG FGPIOC_PDOR
  517. #define CORE_PIN12_PORTREG FGPIOC_PDOR
  518. #define CORE_PIN13_PORTREG FGPIOC_PDOR
  519. #define CORE_PIN14_PORTREG FGPIOD_PDOR
  520. #define CORE_PIN15_PORTREG FGPIOC_PDOR
  521. #define CORE_PIN16_PORTREG FGPIOB_PDOR
  522. #define CORE_PIN17_PORTREG FGPIOB_PDOR
  523. #define CORE_PIN18_PORTREG FGPIOB_PDOR
  524. #define CORE_PIN19_PORTREG FGPIOB_PDOR
  525. #define CORE_PIN20_PORTREG FGPIOD_PDOR
  526. #define CORE_PIN21_PORTREG FGPIOD_PDOR
  527. #define CORE_PIN22_PORTREG FGPIOC_PDOR
  528. #define CORE_PIN23_PORTREG FGPIOC_PDOR
  529. #define CORE_PIN24_PORTREG FGPIOE_PDOR
  530. #define CORE_PIN25_PORTREG FGPIOE_PDOR
  531. #define CORE_PIN26_PORTREG FGPIOE_PDOR
  532. #define CORE_PIN0_PORTSET FGPIOB_PSOR
  533. #define CORE_PIN1_PORTSET FGPIOB_PSOR
  534. #define CORE_PIN2_PORTSET FGPIOD_PSOR
  535. #define CORE_PIN3_PORTSET FGPIOA_PSOR
  536. #define CORE_PIN4_PORTSET FGPIOA_PSOR
  537. #define CORE_PIN5_PORTSET FGPIOD_PSOR
  538. #define CORE_PIN6_PORTSET FGPIOD_PSOR
  539. #define CORE_PIN7_PORTSET FGPIOD_PSOR
  540. #define CORE_PIN8_PORTSET FGPIOD_PSOR
  541. #define CORE_PIN9_PORTSET FGPIOC_PSOR
  542. #define CORE_PIN10_PORTSET FGPIOC_PSOR
  543. #define CORE_PIN11_PORTSET FGPIOC_PSOR
  544. #define CORE_PIN12_PORTSET FGPIOC_PSOR
  545. #define CORE_PIN13_PORTSET FGPIOC_PSOR
  546. #define CORE_PIN14_PORTSET FGPIOD_PSOR
  547. #define CORE_PIN15_PORTSET FGPIOC_PSOR
  548. #define CORE_PIN16_PORTSET FGPIOB_PSOR
  549. #define CORE_PIN17_PORTSET FGPIOB_PSOR
  550. #define CORE_PIN18_PORTSET FGPIOB_PSOR
  551. #define CORE_PIN19_PORTSET FGPIOB_PSOR
  552. #define CORE_PIN20_PORTSET FGPIOD_PSOR
  553. #define CORE_PIN21_PORTSET FGPIOD_PSOR
  554. #define CORE_PIN22_PORTSET FGPIOC_PSOR
  555. #define CORE_PIN23_PORTSET FGPIOC_PSOR
  556. #define CORE_PIN24_PORTSET FGPIOE_PSOR
  557. #define CORE_PIN25_PORTSET FGPIOE_PSOR
  558. #define CORE_PIN26_PORTSET FGPIOE_PSOR
  559. #define CORE_PIN0_PORTCLEAR FGPIOB_PCOR
  560. #define CORE_PIN1_PORTCLEAR FGPIOB_PCOR
  561. #define CORE_PIN2_PORTCLEAR FGPIOD_PCOR
  562. #define CORE_PIN3_PORTCLEAR FGPIOA_PCOR
  563. #define CORE_PIN4_PORTCLEAR FGPIOA_PCOR
  564. #define CORE_PIN5_PORTCLEAR FGPIOD_PCOR
  565. #define CORE_PIN6_PORTCLEAR FGPIOD_PCOR
  566. #define CORE_PIN7_PORTCLEAR FGPIOD_PCOR
  567. #define CORE_PIN8_PORTCLEAR FGPIOD_PCOR
  568. #define CORE_PIN9_PORTCLEAR FGPIOC_PCOR
  569. #define CORE_PIN10_PORTCLEAR FGPIOC_PCOR
  570. #define CORE_PIN11_PORTCLEAR FGPIOC_PCOR
  571. #define CORE_PIN12_PORTCLEAR FGPIOC_PCOR
  572. #define CORE_PIN13_PORTCLEAR FGPIOC_PCOR
  573. #define CORE_PIN14_PORTCLEAR FGPIOD_PCOR
  574. #define CORE_PIN15_PORTCLEAR FGPIOC_PCOR
  575. #define CORE_PIN16_PORTCLEAR FGPIOB_PCOR
  576. #define CORE_PIN17_PORTCLEAR FGPIOB_PCOR
  577. #define CORE_PIN18_PORTCLEAR FGPIOB_PCOR
  578. #define CORE_PIN19_PORTCLEAR FGPIOB_PCOR
  579. #define CORE_PIN20_PORTCLEAR FGPIOD_PCOR
  580. #define CORE_PIN21_PORTCLEAR FGPIOD_PCOR
  581. #define CORE_PIN22_PORTCLEAR FGPIOC_PCOR
  582. #define CORE_PIN23_PORTCLEAR FGPIOC_PCOR
  583. #define CORE_PIN24_PORTCLEAR FGPIOE_PCOR
  584. #define CORE_PIN25_PORTCLEAR FGPIOE_PCOR
  585. #define CORE_PIN26_PORTCLEAR FGPIOE_PCOR
  586. #define CORE_PIN0_DDRREG FGPIOB_PDDR
  587. #define CORE_PIN1_DDRREG FGPIOB_PDDR
  588. #define CORE_PIN2_DDRREG FGPIOD_PDDR
  589. #define CORE_PIN3_DDRREG FGPIOA_PDDR
  590. #define CORE_PIN4_DDRREG FGPIOA_PDDR
  591. #define CORE_PIN5_DDRREG FGPIOD_PDDR
  592. #define CORE_PIN6_DDRREG FGPIOD_PDDR
  593. #define CORE_PIN7_DDRREG FGPIOD_PDDR
  594. #define CORE_PIN8_DDRREG FGPIOD_PDDR
  595. #define CORE_PIN9_DDRREG FGPIOC_PDDR
  596. #define CORE_PIN10_DDRREG FGPIOC_PDDR
  597. #define CORE_PIN11_DDRREG FGPIOC_PDDR
  598. #define CORE_PIN12_DDRREG FGPIOC_PDDR
  599. #define CORE_PIN13_DDRREG FGPIOC_PDDR
  600. #define CORE_PIN14_DDRREG FGPIOD_PDDR
  601. #define CORE_PIN15_DDRREG FGPIOC_PDDR
  602. #define CORE_PIN16_DDRREG FGPIOB_PDDR
  603. #define CORE_PIN17_DDRREG FGPIOB_PDDR
  604. #define CORE_PIN18_DDRREG FGPIOB_PDDR
  605. #define CORE_PIN19_DDRREG FGPIOB_PDDR
  606. #define CORE_PIN20_DDRREG FGPIOD_PDDR
  607. #define CORE_PIN21_DDRREG FGPIOD_PDDR
  608. #define CORE_PIN22_DDRREG FGPIOC_PDDR
  609. #define CORE_PIN23_DDRREG FGPIOC_PDDR
  610. #define CORE_PIN24_DDRREG FGPIOE_PDDR
  611. #define CORE_PIN25_DDRREG FGPIOE_PDDR
  612. #define CORE_PIN26_DDRREG FGPIOE_PDDR
  613. #define CORE_PIN0_PINREG FGPIOB_PDIR
  614. #define CORE_PIN1_PINREG FGPIOB_PDIR
  615. #define CORE_PIN2_PINREG FGPIOD_PDIR
  616. #define CORE_PIN3_PINREG FGPIOA_PDIR
  617. #define CORE_PIN4_PINREG FGPIOA_PDIR
  618. #define CORE_PIN5_PINREG FGPIOD_PDIR
  619. #define CORE_PIN6_PINREG FGPIOD_PDIR
  620. #define CORE_PIN7_PINREG FGPIOD_PDIR
  621. #define CORE_PIN8_PINREG FGPIOD_PDIR
  622. #define CORE_PIN9_PINREG FGPIOC_PDIR
  623. #define CORE_PIN10_PINREG FGPIOC_PDIR
  624. #define CORE_PIN11_PINREG FGPIOC_PDIR
  625. #define CORE_PIN12_PINREG FGPIOC_PDIR
  626. #define CORE_PIN13_PINREG FGPIOC_PDIR
  627. #define CORE_PIN14_PINREG FGPIOD_PDIR
  628. #define CORE_PIN15_PINREG FGPIOC_PDIR
  629. #define CORE_PIN16_PINREG FGPIOB_PDIR
  630. #define CORE_PIN17_PINREG FGPIOB_PDIR
  631. #define CORE_PIN18_PINREG FGPIOB_PDIR
  632. #define CORE_PIN19_PINREG FGPIOB_PDIR
  633. #define CORE_PIN20_PINREG FGPIOD_PDIR
  634. #define CORE_PIN21_PINREG FGPIOD_PDIR
  635. #define CORE_PIN22_PINREG FGPIOC_PDIR
  636. #define CORE_PIN23_PINREG FGPIOC_PDIR
  637. #define CORE_PIN24_PINREG FGPIOE_PDIR
  638. #define CORE_PIN25_PINREG FGPIOE_PDIR
  639. #define CORE_PIN26_PINREG FGPIOE_PDIR
  640. #define CORE_PIN0_CONFIG PORTB_PCR16
  641. #define CORE_PIN1_CONFIG PORTB_PCR17
  642. #define CORE_PIN2_CONFIG PORTD_PCR0
  643. #define CORE_PIN3_CONFIG PORTA_PCR1
  644. #define CORE_PIN4_CONFIG PORTA_PCR2
  645. #define CORE_PIN5_CONFIG PORTD_PCR7
  646. #define CORE_PIN6_CONFIG PORTD_PCR4
  647. #define CORE_PIN7_CONFIG PORTD_PCR2
  648. #define CORE_PIN8_CONFIG PORTD_PCR3
  649. #define CORE_PIN9_CONFIG PORTC_PCR3
  650. #define CORE_PIN10_CONFIG PORTC_PCR4
  651. #define CORE_PIN11_CONFIG PORTC_PCR6
  652. #define CORE_PIN12_CONFIG PORTC_PCR7
  653. #define CORE_PIN13_CONFIG PORTC_PCR5
  654. #define CORE_PIN14_CONFIG PORTD_PCR1
  655. #define CORE_PIN15_CONFIG PORTC_PCR0
  656. #define CORE_PIN16_CONFIG PORTB_PCR0
  657. #define CORE_PIN17_CONFIG PORTB_PCR1
  658. #define CORE_PIN18_CONFIG PORTB_PCR3
  659. #define CORE_PIN19_CONFIG PORTB_PCR2
  660. #define CORE_PIN20_CONFIG PORTD_PCR5
  661. #define CORE_PIN21_CONFIG PORTD_PCR6
  662. #define CORE_PIN22_CONFIG PORTC_PCR1
  663. #define CORE_PIN23_CONFIG PORTC_PCR2
  664. #define CORE_PIN24_CONFIG PORTE_PCR20
  665. #define CORE_PIN25_CONFIG PORTE_PCR21
  666. #define CORE_PIN26_CONFIG PORTE_PCR30
  667. #define CORE_ADC0_PIN 14
  668. #define CORE_ADC1_PIN 15
  669. #define CORE_ADC2_PIN 16
  670. #define CORE_ADC3_PIN 17
  671. #define CORE_ADC4_PIN 18
  672. #define CORE_ADC5_PIN 19
  673. #define CORE_ADC6_PIN 20
  674. #define CORE_ADC7_PIN 21
  675. #define CORE_ADC8_PIN 22
  676. #define CORE_ADC9_PIN 23
  677. #define CORE_ADC10_PIN 24
  678. #define CORE_ADC11_PIN 25
  679. #define CORE_ADC12_PIN 26
  680. #define CORE_RXD0_PIN 0
  681. #define CORE_TXD0_PIN 1
  682. #define CORE_RXD1_PIN 9
  683. #define CORE_TXD1_PIN 10
  684. #define CORE_RXD2_PIN 7
  685. #define CORE_TXD2_PIN 8
  686. #define CORE_INT2_PIN 2
  687. #define CORE_INT3_PIN 3
  688. #define CORE_INT4_PIN 4
  689. #define CORE_INT5_PIN 5
  690. #define CORE_INT6_PIN 6
  691. #define CORE_INT7_PIN 7
  692. #define CORE_INT8_PIN 8
  693. #define CORE_INT9_PIN 9
  694. #define CORE_INT10_PIN 10
  695. #define CORE_INT11_PIN 11
  696. #define CORE_INT12_PIN 12
  697. #define CORE_INT13_PIN 13
  698. #define CORE_INT14_PIN 14
  699. #define CORE_INT15_PIN 15
  700. #define CORE_INT20_PIN 20
  701. #define CORE_INT21_PIN 21
  702. #define CORE_INT22_PIN 22
  703. #define CORE_INT23_PIN 23
  704. #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
  705. #define CORE_PIN0_BIT 16
  706. #define CORE_PIN1_BIT 17
  707. #define CORE_PIN2_BIT 0
  708. #define CORE_PIN3_BIT 12
  709. #define CORE_PIN4_BIT 13
  710. #define CORE_PIN5_BIT 7
  711. #define CORE_PIN6_BIT 4
  712. #define CORE_PIN7_BIT 2
  713. #define CORE_PIN8_BIT 3
  714. #define CORE_PIN9_BIT 3
  715. #define CORE_PIN10_BIT 4
  716. #define CORE_PIN11_BIT 6
  717. #define CORE_PIN12_BIT 7
  718. #define CORE_PIN13_BIT 5
  719. #define CORE_PIN14_BIT 1
  720. #define CORE_PIN15_BIT 0
  721. #define CORE_PIN16_BIT 0
  722. #define CORE_PIN17_BIT 1
  723. #define CORE_PIN18_BIT 3
  724. #define CORE_PIN19_BIT 2
  725. #define CORE_PIN20_BIT 5
  726. #define CORE_PIN21_BIT 6
  727. #define CORE_PIN22_BIT 1
  728. #define CORE_PIN23_BIT 2
  729. #define CORE_PIN24_BIT 26
  730. #define CORE_PIN25_BIT 5
  731. #define CORE_PIN26_BIT 14
  732. #define CORE_PIN27_BIT 15
  733. #define CORE_PIN28_BIT 16
  734. #define CORE_PIN29_BIT 18
  735. #define CORE_PIN30_BIT 19
  736. #define CORE_PIN31_BIT 10
  737. #define CORE_PIN32_BIT 11
  738. #define CORE_PIN33_BIT 24
  739. #define CORE_PIN34_BIT 25
  740. #define CORE_PIN35_BIT 8
  741. #define CORE_PIN36_BIT 9
  742. #define CORE_PIN37_BIT 10
  743. #define CORE_PIN38_BIT 11
  744. #define CORE_PIN39_BIT 17
  745. #define CORE_PIN40_BIT 28
  746. #define CORE_PIN41_BIT 29
  747. #define CORE_PIN42_BIT 26
  748. #define CORE_PIN43_BIT 20
  749. #define CORE_PIN44_BIT 22
  750. #define CORE_PIN45_BIT 23
  751. #define CORE_PIN46_BIT 21
  752. #define CORE_PIN47_BIT 8
  753. #define CORE_PIN48_BIT 9
  754. #define CORE_PIN49_BIT 4
  755. #define CORE_PIN50_BIT 5
  756. #define CORE_PIN51_BIT 14
  757. #define CORE_PIN52_BIT 13
  758. #define CORE_PIN53_BIT 12
  759. #define CORE_PIN54_BIT 15
  760. #define CORE_PIN55_BIT 11
  761. #define CORE_PIN56_BIT 10
  762. #define CORE_PIN57_BIT 11
  763. #define CORE_PIN58_BIT 0
  764. #define CORE_PIN59_BIT 1
  765. #define CORE_PIN60_BIT 2
  766. #define CORE_PIN61_BIT 3
  767. #define CORE_PIN62_BIT 4
  768. #define CORE_PIN63_BIT 5
  769. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  770. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  771. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  772. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  773. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  774. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  775. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  776. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  777. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  778. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  779. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  780. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  781. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  782. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  783. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  784. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  785. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  786. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  787. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  788. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  789. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  790. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  791. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  792. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  793. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  794. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  795. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  796. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  797. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  798. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  799. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  800. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  801. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  802. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  803. #define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
  804. #define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
  805. #define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
  806. #define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
  807. #define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
  808. #define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))
  809. #define CORE_PIN40_BITMASK (1<<(CORE_PIN40_BIT))
  810. #define CORE_PIN41_BITMASK (1<<(CORE_PIN41_BIT))
  811. #define CORE_PIN42_BITMASK (1<<(CORE_PIN42_BIT))
  812. #define CORE_PIN43_BITMASK (1<<(CORE_PIN43_BIT))
  813. #define CORE_PIN44_BITMASK (1<<(CORE_PIN44_BIT))
  814. #define CORE_PIN45_BITMASK (1<<(CORE_PIN45_BIT))
  815. #define CORE_PIN46_BITMASK (1<<(CORE_PIN46_BIT))
  816. #define CORE_PIN47_BITMASK (1<<(CORE_PIN47_BIT))
  817. #define CORE_PIN48_BITMASK (1<<(CORE_PIN48_BIT))
  818. #define CORE_PIN49_BITMASK (1<<(CORE_PIN49_BIT))
  819. #define CORE_PIN50_BITMASK (1<<(CORE_PIN50_BIT))
  820. #define CORE_PIN51_BITMASK (1<<(CORE_PIN51_BIT))
  821. #define CORE_PIN52_BITMASK (1<<(CORE_PIN52_BIT))
  822. #define CORE_PIN53_BITMASK (1<<(CORE_PIN53_BIT))
  823. #define CORE_PIN54_BITMASK (1<<(CORE_PIN54_BIT))
  824. #define CORE_PIN55_BITMASK (1<<(CORE_PIN55_BIT))
  825. #define CORE_PIN56_BITMASK (1<<(CORE_PIN56_BIT))
  826. #define CORE_PIN57_BITMASK (1<<(CORE_PIN57_BIT))
  827. #define CORE_PIN58_BITMASK (1<<(CORE_PIN58_BIT))
  828. #define CORE_PIN59_BITMASK (1<<(CORE_PIN59_BIT))
  829. #define CORE_PIN60_BITMASK (1<<(CORE_PIN60_BIT))
  830. #define CORE_PIN61_BITMASK (1<<(CORE_PIN61_BIT))
  831. #define CORE_PIN62_BITMASK (1<<(CORE_PIN62_BIT))
  832. #define CORE_PIN63_BITMASK (1<<(CORE_PIN63_BIT))
  833. #define CORE_PIN0_PORTREG GPIOB_PDOR
  834. #define CORE_PIN1_PORTREG GPIOB_PDOR
  835. #define CORE_PIN2_PORTREG GPIOD_PDOR
  836. #define CORE_PIN3_PORTREG GPIOA_PDOR
  837. #define CORE_PIN4_PORTREG GPIOA_PDOR
  838. #define CORE_PIN5_PORTREG GPIOD_PDOR
  839. #define CORE_PIN6_PORTREG GPIOD_PDOR
  840. #define CORE_PIN7_PORTREG GPIOD_PDOR
  841. #define CORE_PIN8_PORTREG GPIOD_PDOR
  842. #define CORE_PIN9_PORTREG GPIOC_PDOR
  843. #define CORE_PIN10_PORTREG GPIOC_PDOR
  844. #define CORE_PIN11_PORTREG GPIOC_PDOR
  845. #define CORE_PIN12_PORTREG GPIOC_PDOR
  846. #define CORE_PIN13_PORTREG GPIOC_PDOR
  847. #define CORE_PIN14_PORTREG GPIOD_PDOR
  848. #define CORE_PIN15_PORTREG GPIOC_PDOR
  849. #define CORE_PIN16_PORTREG GPIOB_PDOR
  850. #define CORE_PIN17_PORTREG GPIOB_PDOR
  851. #define CORE_PIN18_PORTREG GPIOB_PDOR
  852. #define CORE_PIN19_PORTREG GPIOB_PDOR
  853. #define CORE_PIN20_PORTREG GPIOD_PDOR
  854. #define CORE_PIN21_PORTREG GPIOD_PDOR
  855. #define CORE_PIN22_PORTREG GPIOC_PDOR
  856. #define CORE_PIN23_PORTREG GPIOC_PDOR
  857. #define CORE_PIN24_PORTREG GPIOE_PDOR
  858. #define CORE_PIN25_PORTREG GPIOA_PDOR
  859. #define CORE_PIN26_PORTREG GPIOA_PDOR
  860. #define CORE_PIN27_PORTREG GPIOA_PDOR
  861. #define CORE_PIN28_PORTREG GPIOA_PDOR
  862. #define CORE_PIN29_PORTREG GPIOB_PDOR
  863. #define CORE_PIN30_PORTREG GPIOB_PDOR
  864. #define CORE_PIN31_PORTREG GPIOB_PDOR
  865. #define CORE_PIN32_PORTREG GPIOB_PDOR
  866. #define CORE_PIN33_PORTREG GPIOE_PDOR
  867. #define CORE_PIN34_PORTREG GPIOE_PDOR
  868. #define CORE_PIN35_PORTREG GPIOC_PDOR
  869. #define CORE_PIN36_PORTREG GPIOC_PDOR
  870. #define CORE_PIN37_PORTREG GPIOC_PDOR
  871. #define CORE_PIN38_PORTREG GPIOC_PDOR
  872. #define CORE_PIN39_PORTREG GPIOA_PDOR
  873. #define CORE_PIN40_PORTREG GPIOA_PDOR
  874. #define CORE_PIN41_PORTREG GPIOA_PDOR
  875. #define CORE_PIN42_PORTREG GPIOA_PDOR
  876. #define CORE_PIN43_PORTREG GPIOB_PDOR
  877. #define CORE_PIN44_PORTREG GPIOB_PDOR
  878. #define CORE_PIN45_PORTREG GPIOB_PDOR
  879. #define CORE_PIN46_PORTREG GPIOB_PDOR
  880. #define CORE_PIN47_PORTREG GPIOD_PDOR
  881. #define CORE_PIN48_PORTREG GPIOD_PDOR
  882. #define CORE_PIN49_PORTREG GPIOB_PDOR
  883. #define CORE_PIN50_PORTREG GPIOB_PDOR
  884. #define CORE_PIN51_PORTREG GPIOD_PDOR
  885. #define CORE_PIN52_PORTREG GPIOD_PDOR
  886. #define CORE_PIN53_PORTREG GPIOD_PDOR
  887. #define CORE_PIN54_PORTREG GPIOD_PDOR
  888. #define CORE_PIN55_PORTREG GPIOD_PDOR
  889. #define CORE_PIN56_PORTREG GPIOE_PDOR
  890. #define CORE_PIN57_PORTREG GPIOE_PDOR
  891. #define CORE_PIN58_PORTREG GPIOE_PDOR
  892. #define CORE_PIN59_PORTREG GPIOE_PDOR
  893. #define CORE_PIN60_PORTREG GPIOE_PDOR
  894. #define CORE_PIN61_PORTREG GPIOE_PDOR
  895. #define CORE_PIN62_PORTREG GPIOE_PDOR
  896. #define CORE_PIN63_PORTREG GPIOE_PDOR
  897. #define CORE_PIN0_PORTSET GPIOB_PSOR
  898. #define CORE_PIN1_PORTSET GPIOB_PSOR
  899. #define CORE_PIN2_PORTSET GPIOD_PSOR
  900. #define CORE_PIN3_PORTSET GPIOA_PSOR
  901. #define CORE_PIN4_PORTSET GPIOA_PSOR
  902. #define CORE_PIN5_PORTSET GPIOD_PSOR
  903. #define CORE_PIN6_PORTSET GPIOD_PSOR
  904. #define CORE_PIN7_PORTSET GPIOD_PSOR
  905. #define CORE_PIN8_PORTSET GPIOD_PSOR
  906. #define CORE_PIN9_PORTSET GPIOC_PSOR
  907. #define CORE_PIN10_PORTSET GPIOC_PSOR
  908. #define CORE_PIN11_PORTSET GPIOC_PSOR
  909. #define CORE_PIN12_PORTSET GPIOC_PSOR
  910. #define CORE_PIN13_PORTSET GPIOC_PSOR
  911. #define CORE_PIN14_PORTSET GPIOD_PSOR
  912. #define CORE_PIN15_PORTSET GPIOC_PSOR
  913. #define CORE_PIN16_PORTSET GPIOB_PSOR
  914. #define CORE_PIN17_PORTSET GPIOB_PSOR
  915. #define CORE_PIN18_PORTSET GPIOB_PSOR
  916. #define CORE_PIN19_PORTSET GPIOB_PSOR
  917. #define CORE_PIN20_PORTSET GPIOD_PSOR
  918. #define CORE_PIN21_PORTSET GPIOD_PSOR
  919. #define CORE_PIN22_PORTSET GPIOC_PSOR
  920. #define CORE_PIN23_PORTSET GPIOC_PSOR
  921. #define CORE_PIN24_PORTSET GPIOE_PSOR
  922. #define CORE_PIN25_PORTSET GPIOA_PSOR
  923. #define CORE_PIN26_PORTSET GPIOA_PSOR
  924. #define CORE_PIN27_PORTSET GPIOA_PSOR
  925. #define CORE_PIN28_PORTSET GPIOA_PSOR
  926. #define CORE_PIN29_PORTSET GPIOB_PSOR
  927. #define CORE_PIN30_PORTSET GPIOB_PSOR
  928. #define CORE_PIN31_PORTSET GPIOB_PSOR
  929. #define CORE_PIN32_PORTSET GPIOB_PSOR
  930. #define CORE_PIN33_PORTSET GPIOE_PSOR
  931. #define CORE_PIN34_PORTSET GPIOE_PSOR
  932. #define CORE_PIN35_PORTSET GPIOC_PSOR
  933. #define CORE_PIN36_PORTSET GPIOC_PSOR
  934. #define CORE_PIN37_PORTSET GPIOC_PSOR
  935. #define CORE_PIN38_PORTSET GPIOC_PSOR
  936. #define CORE_PIN39_PORTSET GPIOA_PSOR
  937. #define CORE_PIN40_PORTSET GPIOA_PSOR
  938. #define CORE_PIN41_PORTSET GPIOA_PSOR
  939. #define CORE_PIN42_PORTSET GPIOA_PSOR
  940. #define CORE_PIN43_PORTSET GPIOB_PSOR
  941. #define CORE_PIN44_PORTSET GPIOB_PSOR
  942. #define CORE_PIN45_PORTSET GPIOB_PSOR
  943. #define CORE_PIN46_PORTSET GPIOB_PSOR
  944. #define CORE_PIN47_PORTSET GPIOD_PSOR
  945. #define CORE_PIN48_PORTSET GPIOD_PSOR
  946. #define CORE_PIN49_PORTSET GPIOB_PSOR
  947. #define CORE_PIN50_PORTSET GPIOB_PSOR
  948. #define CORE_PIN51_PORTSET GPIOD_PSOR
  949. #define CORE_PIN52_PORTSET GPIOD_PSOR
  950. #define CORE_PIN53_PORTSET GPIOD_PSOR
  951. #define CORE_PIN54_PORTSET GPIOD_PSOR
  952. #define CORE_PIN55_PORTSET GPIOD_PSOR
  953. #define CORE_PIN56_PORTSET GPIOE_PSOR
  954. #define CORE_PIN57_PORTSET GPIOE_PSOR
  955. #define CORE_PIN58_PORTSET GPIOE_PSOR
  956. #define CORE_PIN59_PORTSET GPIOE_PSOR
  957. #define CORE_PIN60_PORTSET GPIOE_PSOR
  958. #define CORE_PIN61_PORTSET GPIOE_PSOR
  959. #define CORE_PIN62_PORTSET GPIOE_PSOR
  960. #define CORE_PIN63_PORTSET GPIOE_PSOR
  961. #define CORE_PIN0_PORTCLEAR GPIOB_PCOR
  962. #define CORE_PIN1_PORTCLEAR GPIOB_PCOR
  963. #define CORE_PIN2_PORTCLEAR GPIOD_PCOR
  964. #define CORE_PIN3_PORTCLEAR GPIOA_PCOR
  965. #define CORE_PIN4_PORTCLEAR GPIOA_PCOR
  966. #define CORE_PIN5_PORTCLEAR GPIOD_PCOR
  967. #define CORE_PIN6_PORTCLEAR GPIOD_PCOR
  968. #define CORE_PIN7_PORTCLEAR GPIOD_PCOR
  969. #define CORE_PIN8_PORTCLEAR GPIOD_PCOR
  970. #define CORE_PIN9_PORTCLEAR GPIOC_PCOR
  971. #define CORE_PIN10_PORTCLEAR GPIOC_PCOR
  972. #define CORE_PIN11_PORTCLEAR GPIOC_PCOR
  973. #define CORE_PIN12_PORTCLEAR GPIOC_PCOR
  974. #define CORE_PIN13_PORTCLEAR GPIOC_PCOR
  975. #define CORE_PIN14_PORTCLEAR GPIOD_PCOR
  976. #define CORE_PIN15_PORTCLEAR GPIOC_PCOR
  977. #define CORE_PIN16_PORTCLEAR GPIOB_PCOR
  978. #define CORE_PIN17_PORTCLEAR GPIOB_PCOR
  979. #define CORE_PIN18_PORTCLEAR GPIOB_PCOR
  980. #define CORE_PIN19_PORTCLEAR GPIOB_PCOR
  981. #define CORE_PIN20_PORTCLEAR GPIOD_PCOR
  982. #define CORE_PIN21_PORTCLEAR GPIOD_PCOR
  983. #define CORE_PIN22_PORTCLEAR GPIOC_PCOR
  984. #define CORE_PIN23_PORTCLEAR GPIOC_PCOR
  985. #define CORE_PIN24_PORTCLEAR GPIOE_PCOR
  986. #define CORE_PIN25_PORTCLEAR GPIOA_PCOR
  987. #define CORE_PIN26_PORTCLEAR GPIOA_PCOR
  988. #define CORE_PIN27_PORTCLEAR GPIOA_PCOR
  989. #define CORE_PIN28_PORTCLEAR GPIOA_PCOR
  990. #define CORE_PIN29_PORTCLEAR GPIOB_PCOR
  991. #define CORE_PIN30_PORTCLEAR GPIOB_PCOR
  992. #define CORE_PIN31_PORTCLEAR GPIOB_PCOR
  993. #define CORE_PIN32_PORTCLEAR GPIOB_PCOR
  994. #define CORE_PIN33_PORTCLEAR GPIOE_PCOR
  995. #define CORE_PIN34_PORTCLEAR GPIOE_PCOR
  996. #define CORE_PIN35_PORTCLEAR GPIOC_PCOR
  997. #define CORE_PIN36_PORTCLEAR GPIOC_PCOR
  998. #define CORE_PIN37_PORTCLEAR GPIOC_PCOR
  999. #define CORE_PIN38_PORTCLEAR GPIOC_PCOR
  1000. #define CORE_PIN39_PORTCLEAR GPIOA_PCOR
  1001. #define CORE_PIN40_PORTCLEAR GPIOA_PCOR
  1002. #define CORE_PIN41_PORTCLEAR GPIOA_PCOR
  1003. #define CORE_PIN42_PORTCLEAR GPIOA_PCOR
  1004. #define CORE_PIN43_PORTCLEAR GPIOB_PCOR
  1005. #define CORE_PIN44_PORTCLEAR GPIOB_PCOR
  1006. #define CORE_PIN45_PORTCLEAR GPIOB_PCOR
  1007. #define CORE_PIN46_PORTCLEAR GPIOB_PCOR
  1008. #define CORE_PIN47_PORTCLEAR GPIOD_PCOR
  1009. #define CORE_PIN48_PORTCLEAR GPIOD_PCOR
  1010. #define CORE_PIN49_PORTCLEAR GPIOB_PCOR
  1011. #define CORE_PIN50_PORTCLEAR GPIOB_PCOR
  1012. #define CORE_PIN51_PORTCLEAR GPIOD_PCOR
  1013. #define CORE_PIN52_PORTCLEAR GPIOD_PCOR
  1014. #define CORE_PIN53_PORTCLEAR GPIOD_PCOR
  1015. #define CORE_PIN54_PORTCLEAR GPIOD_PCOR
  1016. #define CORE_PIN55_PORTCLEAR GPIOD_PCOR
  1017. #define CORE_PIN56_PORTCLEAR GPIOE_PCOR
  1018. #define CORE_PIN57_PORTCLEAR GPIOE_PCOR
  1019. #define CORE_PIN58_PORTCLEAR GPIOE_PCOR
  1020. #define CORE_PIN59_PORTCLEAR GPIOE_PCOR
  1021. #define CORE_PIN60_PORTCLEAR GPIOE_PCOR
  1022. #define CORE_PIN61_PORTCLEAR GPIOE_PCOR
  1023. #define CORE_PIN62_PORTCLEAR GPIOE_PCOR
  1024. #define CORE_PIN63_PORTCLEAR GPIOE_PCOR
  1025. #define CORE_PIN0_DDRREG GPIOB_PDDR
  1026. #define CORE_PIN1_DDRREG GPIOB_PDDR
  1027. #define CORE_PIN2_DDRREG GPIOD_PDDR
  1028. #define CORE_PIN3_DDRREG GPIOA_PDDR
  1029. #define CORE_PIN4_DDRREG GPIOA_PDDR
  1030. #define CORE_PIN5_DDRREG GPIOD_PDDR
  1031. #define CORE_PIN6_DDRREG GPIOD_PDDR
  1032. #define CORE_PIN7_DDRREG GPIOD_PDDR
  1033. #define CORE_PIN8_DDRREG GPIOD_PDDR
  1034. #define CORE_PIN9_DDRREG GPIOC_PDDR
  1035. #define CORE_PIN10_DDRREG GPIOC_PDDR
  1036. #define CORE_PIN11_DDRREG GPIOC_PDDR
  1037. #define CORE_PIN12_DDRREG GPIOC_PDDR
  1038. #define CORE_PIN13_DDRREG GPIOC_PDDR
  1039. #define CORE_PIN14_DDRREG GPIOD_PDDR
  1040. #define CORE_PIN15_DDRREG GPIOC_PDDR
  1041. #define CORE_PIN16_DDRREG GPIOB_PDDR
  1042. #define CORE_PIN17_DDRREG GPIOB_PDDR
  1043. #define CORE_PIN18_DDRREG GPIOB_PDDR
  1044. #define CORE_PIN19_DDRREG GPIOB_PDDR
  1045. #define CORE_PIN20_DDRREG GPIOD_PDDR
  1046. #define CORE_PIN21_DDRREG GPIOD_PDDR
  1047. #define CORE_PIN22_DDRREG GPIOC_PDDR
  1048. #define CORE_PIN23_DDRREG GPIOC_PDDR
  1049. #define CORE_PIN24_DDRREG GPIOE_PDDR
  1050. #define CORE_PIN25_DDRREG GPIOA_PDDR
  1051. #define CORE_PIN26_DDRREG GPIOA_PDDR
  1052. #define CORE_PIN27_DDRREG GPIOA_PDDR
  1053. #define CORE_PIN28_DDRREG GPIOA_PDDR
  1054. #define CORE_PIN29_DDRREG GPIOB_PDDR
  1055. #define CORE_PIN30_DDRREG GPIOB_PDDR
  1056. #define CORE_PIN31_DDRREG GPIOB_PDDR
  1057. #define CORE_PIN32_DDRREG GPIOB_PDDR
  1058. #define CORE_PIN33_DDRREG GPIOE_PDDR
  1059. #define CORE_PIN34_DDRREG GPIOE_PDDR
  1060. #define CORE_PIN35_DDRREG GPIOC_PDDR
  1061. #define CORE_PIN36_DDRREG GPIOC_PDDR
  1062. #define CORE_PIN37_DDRREG GPIOC_PDDR
  1063. #define CORE_PIN38_DDRREG GPIOC_PDDR
  1064. #define CORE_PIN39_DDRREG GPIOA_PDDR
  1065. #define CORE_PIN40_DDRREG GPIOA_PDDR
  1066. #define CORE_PIN41_DDRREG GPIOA_PDDR
  1067. #define CORE_PIN42_DDRREG GPIOA_PDDR
  1068. #define CORE_PIN43_DDRREG GPIOB_PDDR
  1069. #define CORE_PIN44_DDRREG GPIOB_PDDR
  1070. #define CORE_PIN45_DDRREG GPIOB_PDDR
  1071. #define CORE_PIN46_DDRREG GPIOB_PDDR
  1072. #define CORE_PIN47_DDRREG GPIOD_PDDR
  1073. #define CORE_PIN48_DDRREG GPIOD_PDDR
  1074. #define CORE_PIN49_DDRREG GPIOB_PDDR
  1075. #define CORE_PIN50_DDRREG GPIOB_PDDR
  1076. #define CORE_PIN51_DDRREG GPIOD_PDDR
  1077. #define CORE_PIN52_DDRREG GPIOD_PDDR
  1078. #define CORE_PIN53_DDRREG GPIOD_PDDR
  1079. #define CORE_PIN54_DDRREG GPIOD_PDDR
  1080. #define CORE_PIN55_DDRREG GPIOD_PDDR
  1081. #define CORE_PIN56_DDRREG GPIOE_PDDR
  1082. #define CORE_PIN57_DDRREG GPIOE_PDDR
  1083. #define CORE_PIN58_DDRREG GPIOE_PDDR
  1084. #define CORE_PIN59_DDRREG GPIOE_PDDR
  1085. #define CORE_PIN60_DDRREG GPIOE_PDDR
  1086. #define CORE_PIN61_DDRREG GPIOE_PDDR
  1087. #define CORE_PIN62_DDRREG GPIOE_PDDR
  1088. #define CORE_PIN63_DDRREG GPIOE_PDDR
  1089. #define CORE_PIN0_PINREG GPIOB_PDIR
  1090. #define CORE_PIN1_PINREG GPIOB_PDIR
  1091. #define CORE_PIN2_PINREG GPIOD_PDIR
  1092. #define CORE_PIN3_PINREG GPIOA_PDIR
  1093. #define CORE_PIN4_PINREG GPIOA_PDIR
  1094. #define CORE_PIN5_PINREG GPIOD_PDIR
  1095. #define CORE_PIN6_PINREG GPIOD_PDIR
  1096. #define CORE_PIN7_PINREG GPIOD_PDIR
  1097. #define CORE_PIN8_PINREG GPIOD_PDIR
  1098. #define CORE_PIN9_PINREG GPIOC_PDIR
  1099. #define CORE_PIN10_PINREG GPIOC_PDIR
  1100. #define CORE_PIN11_PINREG GPIOC_PDIR
  1101. #define CORE_PIN12_PINREG GPIOC_PDIR
  1102. #define CORE_PIN13_PINREG GPIOC_PDIR
  1103. #define CORE_PIN14_PINREG GPIOD_PDIR
  1104. #define CORE_PIN15_PINREG GPIOC_PDIR
  1105. #define CORE_PIN16_PINREG GPIOB_PDIR
  1106. #define CORE_PIN17_PINREG GPIOB_PDIR
  1107. #define CORE_PIN18_PINREG GPIOB_PDIR
  1108. #define CORE_PIN19_PINREG GPIOB_PDIR
  1109. #define CORE_PIN20_PINREG GPIOD_PDIR
  1110. #define CORE_PIN21_PINREG GPIOD_PDIR
  1111. #define CORE_PIN22_PINREG GPIOC_PDIR
  1112. #define CORE_PIN23_PINREG GPIOC_PDIR
  1113. #define CORE_PIN24_PINREG GPIOE_PDIR
  1114. #define CORE_PIN25_PINREG GPIOA_PDIR
  1115. #define CORE_PIN26_PINREG GPIOA_PDIR
  1116. #define CORE_PIN27_PINREG GPIOA_PDIR
  1117. #define CORE_PIN28_PINREG GPIOA_PDIR
  1118. #define CORE_PIN29_PINREG GPIOB_PDIR
  1119. #define CORE_PIN30_PINREG GPIOB_PDIR
  1120. #define CORE_PIN31_PINREG GPIOB_PDIR
  1121. #define CORE_PIN32_PINREG GPIOB_PDIR
  1122. #define CORE_PIN33_PINREG GPIOE_PDIR
  1123. #define CORE_PIN34_PINREG GPIOE_PDIR
  1124. #define CORE_PIN35_PINREG GPIOC_PDIR
  1125. #define CORE_PIN36_PINREG GPIOC_PDIR
  1126. #define CORE_PIN37_PINREG GPIOC_PDIR
  1127. #define CORE_PIN38_PINREG GPIOC_PDIR
  1128. #define CORE_PIN39_PINREG GPIOA_PDIR
  1129. #define CORE_PIN40_PINREG GPIOA_PDIR
  1130. #define CORE_PIN41_PINREG GPIOA_PDIR
  1131. #define CORE_PIN42_PINREG GPIOA_PDIR
  1132. #define CORE_PIN43_PINREG GPIOB_PDIR
  1133. #define CORE_PIN44_PINREG GPIOB_PDIR
  1134. #define CORE_PIN45_PINREG GPIOB_PDIR
  1135. #define CORE_PIN46_PINREG GPIOB_PDIR
  1136. #define CORE_PIN47_PINREG GPIOD_PDIR
  1137. #define CORE_PIN48_PINREG GPIOD_PDIR
  1138. #define CORE_PIN49_PINREG GPIOB_PDIR
  1139. #define CORE_PIN50_PINREG GPIOB_PDIR
  1140. #define CORE_PIN51_PINREG GPIOD_PDIR
  1141. #define CORE_PIN52_PINREG GPIOD_PDIR
  1142. #define CORE_PIN53_PINREG GPIOD_PDIR
  1143. #define CORE_PIN54_PINREG GPIOD_PDIR
  1144. #define CORE_PIN55_PINREG GPIOD_PDIR
  1145. #define CORE_PIN56_PINREG GPIOE_PDIR
  1146. #define CORE_PIN57_PINREG GPIOE_PDIR
  1147. #define CORE_PIN58_PINREG GPIOE_PDIR
  1148. #define CORE_PIN59_PINREG GPIOE_PDIR
  1149. #define CORE_PIN60_PINREG GPIOE_PDIR
  1150. #define CORE_PIN61_PINREG GPIOE_PDIR
  1151. #define CORE_PIN62_PINREG GPIOE_PDIR
  1152. #define CORE_PIN63_PINREG GPIOE_PDIR
  1153. #define CORE_PIN0_CONFIG PORTB_PCR16
  1154. #define CORE_PIN1_CONFIG PORTB_PCR17
  1155. #define CORE_PIN2_CONFIG PORTD_PCR0
  1156. #define CORE_PIN3_CONFIG PORTA_PCR12
  1157. #define CORE_PIN4_CONFIG PORTA_PCR13
  1158. #define CORE_PIN5_CONFIG PORTD_PCR7
  1159. #define CORE_PIN6_CONFIG PORTD_PCR4
  1160. #define CORE_PIN7_CONFIG PORTD_PCR2
  1161. #define CORE_PIN8_CONFIG PORTD_PCR3
  1162. #define CORE_PIN9_CONFIG PORTC_PCR3
  1163. #define CORE_PIN10_CONFIG PORTC_PCR4
  1164. #define CORE_PIN11_CONFIG PORTC_PCR6
  1165. #define CORE_PIN12_CONFIG PORTC_PCR7
  1166. #define CORE_PIN13_CONFIG PORTC_PCR5
  1167. #define CORE_PIN14_CONFIG PORTD_PCR1
  1168. #define CORE_PIN15_CONFIG PORTC_PCR0
  1169. #define CORE_PIN16_CONFIG PORTB_PCR0
  1170. #define CORE_PIN17_CONFIG PORTB_PCR1
  1171. #define CORE_PIN18_CONFIG PORTB_PCR3
  1172. #define CORE_PIN19_CONFIG PORTB_PCR2
  1173. #define CORE_PIN20_CONFIG PORTD_PCR5
  1174. #define CORE_PIN21_CONFIG PORTD_PCR6
  1175. #define CORE_PIN22_CONFIG PORTC_PCR1
  1176. #define CORE_PIN23_CONFIG PORTC_PCR2
  1177. #define CORE_PIN24_CONFIG PORTE_PCR26
  1178. #define CORE_PIN25_CONFIG PORTA_PCR5
  1179. #define CORE_PIN26_CONFIG PORTA_PCR14
  1180. #define CORE_PIN27_CONFIG PORTA_PCR15
  1181. #define CORE_PIN28_CONFIG PORTA_PCR16
  1182. #define CORE_PIN29_CONFIG PORTB_PCR18
  1183. #define CORE_PIN30_CONFIG PORTB_PCR19
  1184. #define CORE_PIN31_CONFIG PORTB_PCR10
  1185. #define CORE_PIN32_CONFIG PORTB_PCR11
  1186. #define CORE_PIN33_CONFIG PORTE_PCR24
  1187. #define CORE_PIN34_CONFIG PORTE_PCR25
  1188. #define CORE_PIN35_CONFIG PORTC_PCR8
  1189. #define CORE_PIN36_CONFIG PORTC_PCR9
  1190. #define CORE_PIN37_CONFIG PORTC_PCR10
  1191. #define CORE_PIN38_CONFIG PORTC_PCR11
  1192. #define CORE_PIN39_CONFIG PORTA_PCR17
  1193. #define CORE_PIN40_CONFIG PORTA_PCR28
  1194. #define CORE_PIN41_CONFIG PORTA_PCR29
  1195. #define CORE_PIN42_CONFIG PORTA_PCR26
  1196. #define CORE_PIN43_CONFIG PORTB_PCR20
  1197. #define CORE_PIN44_CONFIG PORTB_PCR22
  1198. #define CORE_PIN45_CONFIG PORTB_PCR23
  1199. #define CORE_PIN46_CONFIG PORTB_PCR21
  1200. #define CORE_PIN47_CONFIG PORTD_PCR8
  1201. #define CORE_PIN48_CONFIG PORTD_PCR9
  1202. #define CORE_PIN49_CONFIG PORTB_PCR4
  1203. #define CORE_PIN50_CONFIG PORTB_PCR5
  1204. #define CORE_PIN51_CONFIG PORTD_PCR14
  1205. #define CORE_PIN52_CONFIG PORTD_PCR13
  1206. #define CORE_PIN53_CONFIG PORTD_PCR12
  1207. #define CORE_PIN54_CONFIG PORTD_PCR15
  1208. #define CORE_PIN55_CONFIG PORTD_PCR11
  1209. #define CORE_PIN56_CONFIG PORTE_PCR10
  1210. #define CORE_PIN57_CONFIG PORTE_PCR11
  1211. #define CORE_PIN58_CONFIG PORTE_PCR0
  1212. #define CORE_PIN59_CONFIG PORTE_PCR1
  1213. #define CORE_PIN60_CONFIG PORTE_PCR2
  1214. #define CORE_PIN61_CONFIG PORTE_PCR3
  1215. #define CORE_PIN62_CONFIG PORTE_PCR4
  1216. #define CORE_PIN63_CONFIG PORTE_PCR5
  1217. #define CORE_ADC0_PIN 14
  1218. #define CORE_ADC1_PIN 15
  1219. #define CORE_ADC2_PIN 16
  1220. #define CORE_ADC3_PIN 17
  1221. #define CORE_ADC4_PIN 18
  1222. #define CORE_ADC5_PIN 19
  1223. #define CORE_ADC6_PIN 20
  1224. #define CORE_ADC7_PIN 21
  1225. #define CORE_ADC8_PIN 22
  1226. #define CORE_ADC9_PIN 23
  1227. #define CORE_ADC10_PIN 40
  1228. #define CORE_ADC11_PIN 41
  1229. #define CORE_ADC12_PIN 31
  1230. #define CORE_ADC13_PIN 32
  1231. #define CORE_ADC14_PIN 33
  1232. #define CORE_ADC15_PIN 34
  1233. #define CORE_ADC16_PIN 35
  1234. #define CORE_ADC17_PIN 36
  1235. #define CORE_ADC18_PIN 37
  1236. #define CORE_ADC19_PIN 38
  1237. #define CORE_ADC20_PIN 39
  1238. #define CORE_RXD0_PIN 0
  1239. #define CORE_TXD0_PIN 1
  1240. #define CORE_RXD1_PIN 9
  1241. #define CORE_TXD1_PIN 10
  1242. #define CORE_RXD2_PIN 7
  1243. #define CORE_TXD2_PIN 8
  1244. #define CORE_RXD3_PIN 31
  1245. #define CORE_TXD3_PIN 32
  1246. #define CORE_RXD4_PIN 34
  1247. #define CORE_TXD4_PIN 33
  1248. #define CORE_INT0_PIN 0
  1249. #define CORE_INT1_PIN 1
  1250. #define CORE_INT2_PIN 2
  1251. #define CORE_INT3_PIN 3
  1252. #define CORE_INT4_PIN 4
  1253. #define CORE_INT5_PIN 5
  1254. #define CORE_INT6_PIN 6
  1255. #define CORE_INT7_PIN 7
  1256. #define CORE_INT8_PIN 8
  1257. #define CORE_INT9_PIN 9
  1258. #define CORE_INT10_PIN 10
  1259. #define CORE_INT11_PIN 11
  1260. #define CORE_INT12_PIN 12
  1261. #define CORE_INT13_PIN 13
  1262. #define CORE_INT14_PIN 14
  1263. #define CORE_INT15_PIN 15
  1264. #define CORE_INT16_PIN 16
  1265. #define CORE_INT17_PIN 17
  1266. #define CORE_INT18_PIN 18
  1267. #define CORE_INT19_PIN 19
  1268. #define CORE_INT20_PIN 20
  1269. #define CORE_INT21_PIN 21
  1270. #define CORE_INT22_PIN 22
  1271. #define CORE_INT23_PIN 23
  1272. #define CORE_INT24_PIN 24
  1273. #define CORE_INT25_PIN 25
  1274. #define CORE_INT26_PIN 26
  1275. #define CORE_INT27_PIN 27
  1276. #define CORE_INT28_PIN 28
  1277. #define CORE_INT29_PIN 29
  1278. #define CORE_INT30_PIN 30
  1279. #define CORE_INT31_PIN 31
  1280. #define CORE_INT32_PIN 32
  1281. #define CORE_INT33_PIN 33
  1282. #define CORE_INT34_PIN 34
  1283. #define CORE_INT35_PIN 35
  1284. #define CORE_INT36_PIN 36
  1285. #define CORE_INT37_PIN 37
  1286. #define CORE_INT38_PIN 38
  1287. #define CORE_INT39_PIN 39
  1288. #define CORE_INT40_PIN 40
  1289. #define CORE_INT41_PIN 41
  1290. #define CORE_INT42_PIN 42
  1291. #define CORE_INT43_PIN 43
  1292. #define CORE_INT44_PIN 44
  1293. #define CORE_INT45_PIN 45
  1294. #define CORE_INT46_PIN 46
  1295. #define CORE_INT47_PIN 47
  1296. #define CORE_INT48_PIN 48
  1297. #define CORE_INT49_PIN 49
  1298. #define CORE_INT50_PIN 50
  1299. #define CORE_INT51_PIN 51
  1300. #define CORE_INT52_PIN 52
  1301. #define CORE_INT53_PIN 53
  1302. #define CORE_INT54_PIN 54
  1303. #define CORE_INT55_PIN 55
  1304. #define CORE_INT56_PIN 56
  1305. #define CORE_INT57_PIN 57
  1306. #define CORE_INT58_PIN 58
  1307. #define CORE_INT59_PIN 59
  1308. #define CORE_INT60_PIN 60
  1309. #define CORE_INT61_PIN 61
  1310. #define CORE_INT62_PIN 62
  1311. #define CORE_INT63_PIN 63
  1312. #define CORE_INT_EVERY_PIN 1
  1313. #endif
  1314. #ifdef __cplusplus
  1315. extern "C" {
  1316. #endif
  1317. void digitalWrite(uint8_t pin, uint8_t val);
  1318. static inline void digitalWriteFast(uint8_t pin, uint8_t val) __attribute__((always_inline, unused));
  1319. static inline void digitalWriteFast(uint8_t pin, uint8_t val)
  1320. {
  1321. if (__builtin_constant_p(pin)) {
  1322. if (val) {
  1323. if (pin == 0) {
  1324. CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
  1325. } else if (pin == 1) {
  1326. CORE_PIN1_PORTSET = CORE_PIN1_BITMASK;
  1327. } else if (pin == 2) {
  1328. CORE_PIN2_PORTSET = CORE_PIN2_BITMASK;
  1329. } else if (pin == 3) {
  1330. CORE_PIN3_PORTSET = CORE_PIN3_BITMASK;
  1331. } else if (pin == 4) {
  1332. CORE_PIN4_PORTSET = CORE_PIN4_BITMASK;
  1333. } else if (pin == 5) {
  1334. CORE_PIN5_PORTSET = CORE_PIN5_BITMASK;
  1335. } else if (pin == 6) {
  1336. CORE_PIN6_PORTSET = CORE_PIN6_BITMASK;
  1337. } else if (pin == 7) {
  1338. CORE_PIN7_PORTSET = CORE_PIN7_BITMASK;
  1339. } else if (pin == 8) {
  1340. CORE_PIN8_PORTSET = CORE_PIN8_BITMASK;
  1341. } else if (pin == 9) {
  1342. CORE_PIN9_PORTSET = CORE_PIN9_BITMASK;
  1343. } else if (pin == 10) {
  1344. CORE_PIN10_PORTSET = CORE_PIN10_BITMASK;
  1345. } else if (pin == 11) {
  1346. CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
  1347. } else if (pin == 12) {
  1348. CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
  1349. } else if (pin == 13) {
  1350. CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
  1351. } else if (pin == 14) {
  1352. CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
  1353. } else if (pin == 15) {
  1354. CORE_PIN15_PORTSET = CORE_PIN15_BITMASK;
  1355. } else if (pin == 16) {
  1356. CORE_PIN16_PORTSET = CORE_PIN16_BITMASK;
  1357. } else if (pin == 17) {
  1358. CORE_PIN17_PORTSET = CORE_PIN17_BITMASK;
  1359. } else if (pin == 18) {
  1360. CORE_PIN18_PORTSET = CORE_PIN18_BITMASK;
  1361. } else if (pin == 19) {
  1362. CORE_PIN19_PORTSET = CORE_PIN19_BITMASK;
  1363. } else if (pin == 20) {
  1364. CORE_PIN20_PORTSET = CORE_PIN20_BITMASK;
  1365. } else if (pin == 21) {
  1366. CORE_PIN21_PORTSET = CORE_PIN21_BITMASK;
  1367. } else if (pin == 22) {
  1368. CORE_PIN22_PORTSET = CORE_PIN22_BITMASK;
  1369. } else if (pin == 23) {
  1370. CORE_PIN23_PORTSET = CORE_PIN23_BITMASK;
  1371. } else if (pin == 24) {
  1372. CORE_PIN24_PORTSET = CORE_PIN24_BITMASK;
  1373. } else if (pin == 25) {
  1374. CORE_PIN25_PORTSET = CORE_PIN25_BITMASK;
  1375. } else if (pin == 26) {
  1376. CORE_PIN26_PORTSET = CORE_PIN26_BITMASK;
  1377. }
  1378. #if defined(CORE_PIN27_PORTSET)
  1379. else if (pin == 27) {
  1380. CORE_PIN27_PORTSET = CORE_PIN27_BITMASK;
  1381. } else if (pin == 28) {
  1382. CORE_PIN28_PORTSET = CORE_PIN28_BITMASK;
  1383. } else if (pin == 29) {
  1384. CORE_PIN29_PORTSET = CORE_PIN29_BITMASK;
  1385. } else if (pin == 30) {
  1386. CORE_PIN30_PORTSET = CORE_PIN30_BITMASK;
  1387. } else if (pin == 31) {
  1388. CORE_PIN31_PORTSET = CORE_PIN31_BITMASK;
  1389. } else if (pin == 32) {
  1390. CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
  1391. } else if (pin == 33) {
  1392. CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
  1393. }
  1394. #endif
  1395. #if defined(CORE_PIN34_PORTSET)
  1396. else if (pin == 34) {
  1397. CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
  1398. } else if (pin == 35) {
  1399. CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
  1400. } else if (pin == 36) {
  1401. CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
  1402. } else if (pin == 37) {
  1403. CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
  1404. } else if (pin == 38) {
  1405. CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
  1406. } else if (pin == 39) {
  1407. CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
  1408. } else if (pin == 40) {
  1409. CORE_PIN40_PORTSET = CORE_PIN40_BITMASK;
  1410. } else if (pin == 41) {
  1411. CORE_PIN41_PORTSET = CORE_PIN41_BITMASK;
  1412. } else if (pin == 42) {
  1413. CORE_PIN42_PORTSET = CORE_PIN42_BITMASK;
  1414. } else if (pin == 43) {
  1415. CORE_PIN43_PORTSET = CORE_PIN43_BITMASK;
  1416. } else if (pin == 44) {
  1417. CORE_PIN44_PORTSET = CORE_PIN44_BITMASK;
  1418. } else if (pin == 45) {
  1419. CORE_PIN45_PORTSET = CORE_PIN45_BITMASK;
  1420. } else if (pin == 46) {
  1421. CORE_PIN46_PORTSET = CORE_PIN46_BITMASK;
  1422. } else if (pin == 47) {
  1423. CORE_PIN47_PORTSET = CORE_PIN47_BITMASK;
  1424. } else if (pin == 48) {
  1425. CORE_PIN48_PORTSET = CORE_PIN48_BITMASK;
  1426. } else if (pin == 49) {
  1427. CORE_PIN49_PORTSET = CORE_PIN49_BITMASK;
  1428. } else if (pin == 50) {
  1429. CORE_PIN50_PORTSET = CORE_PIN50_BITMASK;
  1430. } else if (pin == 51) {
  1431. CORE_PIN51_PORTSET = CORE_PIN51_BITMASK;
  1432. } else if (pin == 52) {
  1433. CORE_PIN52_PORTSET = CORE_PIN52_BITMASK;
  1434. } else if (pin == 53) {
  1435. CORE_PIN53_PORTSET = CORE_PIN53_BITMASK;
  1436. } else if (pin == 54) {
  1437. CORE_PIN54_PORTSET = CORE_PIN54_BITMASK;
  1438. } else if (pin == 55) {
  1439. CORE_PIN55_PORTSET = CORE_PIN55_BITMASK;
  1440. } else if (pin == 56) {
  1441. CORE_PIN56_PORTSET = CORE_PIN56_BITMASK;
  1442. } else if (pin == 57) {
  1443. CORE_PIN57_PORTSET = CORE_PIN57_BITMASK;
  1444. } else if (pin == 58) {
  1445. CORE_PIN58_PORTSET = CORE_PIN58_BITMASK;
  1446. } else if (pin == 59) {
  1447. CORE_PIN59_PORTSET = CORE_PIN59_BITMASK;
  1448. } else if (pin == 60) {
  1449. CORE_PIN60_PORTSET = CORE_PIN60_BITMASK;
  1450. } else if (pin == 61) {
  1451. CORE_PIN61_PORTSET = CORE_PIN61_BITMASK;
  1452. } else if (pin == 62) {
  1453. CORE_PIN62_PORTSET = CORE_PIN62_BITMASK;
  1454. } else if (pin == 63) {
  1455. CORE_PIN63_PORTSET = CORE_PIN63_BITMASK;
  1456. }
  1457. #endif
  1458. } else {
  1459. if (pin == 0) {
  1460. CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;
  1461. } else if (pin == 1) {
  1462. CORE_PIN1_PORTCLEAR = CORE_PIN1_BITMASK;
  1463. } else if (pin == 2) {
  1464. CORE_PIN2_PORTCLEAR = CORE_PIN2_BITMASK;
  1465. } else if (pin == 3) {
  1466. CORE_PIN3_PORTCLEAR = CORE_PIN3_BITMASK;
  1467. } else if (pin == 4) {
  1468. CORE_PIN4_PORTCLEAR = CORE_PIN4_BITMASK;
  1469. } else if (pin == 5) {
  1470. CORE_PIN5_PORTCLEAR = CORE_PIN5_BITMASK;
  1471. } else if (pin == 6) {
  1472. CORE_PIN6_PORTCLEAR = CORE_PIN6_BITMASK;
  1473. } else if (pin == 7) {
  1474. CORE_PIN7_PORTCLEAR = CORE_PIN7_BITMASK;
  1475. } else if (pin == 8) {
  1476. CORE_PIN8_PORTCLEAR = CORE_PIN8_BITMASK;
  1477. } else if (pin == 9) {
  1478. CORE_PIN9_PORTCLEAR = CORE_PIN9_BITMASK;
  1479. } else if (pin == 10) {
  1480. CORE_PIN10_PORTCLEAR = CORE_PIN10_BITMASK;
  1481. } else if (pin == 11) {
  1482. CORE_PIN11_PORTCLEAR = CORE_PIN11_BITMASK;
  1483. } else if (pin == 12) {
  1484. CORE_PIN12_PORTCLEAR = CORE_PIN12_BITMASK;
  1485. } else if (pin == 13) {
  1486. CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
  1487. } else if (pin == 14) {
  1488. CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
  1489. } else if (pin == 15) {
  1490. CORE_PIN15_PORTCLEAR = CORE_PIN15_BITMASK;
  1491. } else if (pin == 16) {
  1492. CORE_PIN16_PORTCLEAR = CORE_PIN16_BITMASK;
  1493. } else if (pin == 17) {
  1494. CORE_PIN17_PORTCLEAR = CORE_PIN17_BITMASK;
  1495. } else if (pin == 18) {
  1496. CORE_PIN18_PORTCLEAR = CORE_PIN18_BITMASK;
  1497. } else if (pin == 19) {
  1498. CORE_PIN19_PORTCLEAR = CORE_PIN19_BITMASK;
  1499. } else if (pin == 20) {
  1500. CORE_PIN20_PORTCLEAR = CORE_PIN20_BITMASK;
  1501. } else if (pin == 21) {
  1502. CORE_PIN21_PORTCLEAR = CORE_PIN21_BITMASK;
  1503. } else if (pin == 22) {
  1504. CORE_PIN22_PORTCLEAR = CORE_PIN22_BITMASK;
  1505. } else if (pin == 23) {
  1506. CORE_PIN23_PORTCLEAR = CORE_PIN23_BITMASK;
  1507. } else if (pin == 24) {
  1508. CORE_PIN24_PORTCLEAR = CORE_PIN24_BITMASK;
  1509. } else if (pin == 25) {
  1510. CORE_PIN25_PORTCLEAR = CORE_PIN25_BITMASK;
  1511. } else if (pin == 26) {
  1512. CORE_PIN26_PORTCLEAR = CORE_PIN26_BITMASK;
  1513. }
  1514. #if defined(CORE_PIN27_PORTCLEAR)
  1515. else if (pin == 27) {
  1516. CORE_PIN27_PORTCLEAR = CORE_PIN27_BITMASK;
  1517. } else if (pin == 28) {
  1518. CORE_PIN28_PORTCLEAR = CORE_PIN28_BITMASK;
  1519. } else if (pin == 29) {
  1520. CORE_PIN29_PORTCLEAR = CORE_PIN29_BITMASK;
  1521. } else if (pin == 30) {
  1522. CORE_PIN30_PORTCLEAR = CORE_PIN30_BITMASK;
  1523. } else if (pin == 31) {
  1524. CORE_PIN31_PORTCLEAR = CORE_PIN31_BITMASK;
  1525. } else if (pin == 32) {
  1526. CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
  1527. } else if (pin == 33) {
  1528. CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
  1529. }
  1530. #endif
  1531. #if defined(CORE_PIN34_PORTCLEAR)
  1532. else if (pin == 34) {
  1533. CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
  1534. } else if (pin == 35) {
  1535. CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
  1536. } else if (pin == 36) {
  1537. CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
  1538. } else if (pin == 37) {
  1539. CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
  1540. } else if (pin == 38) {
  1541. CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
  1542. } else if (pin == 39) {
  1543. CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
  1544. } else if (pin == 40) {
  1545. CORE_PIN40_PORTCLEAR = CORE_PIN40_BITMASK;
  1546. } else if (pin == 41) {
  1547. CORE_PIN41_PORTCLEAR = CORE_PIN41_BITMASK;
  1548. } else if (pin == 42) {
  1549. CORE_PIN42_PORTCLEAR = CORE_PIN42_BITMASK;
  1550. } else if (pin == 43) {
  1551. CORE_PIN43_PORTCLEAR = CORE_PIN43_BITMASK;
  1552. } else if (pin == 44) {
  1553. CORE_PIN44_PORTCLEAR = CORE_PIN44_BITMASK;
  1554. } else if (pin == 45) {
  1555. CORE_PIN45_PORTCLEAR = CORE_PIN45_BITMASK;
  1556. } else if (pin == 46) {
  1557. CORE_PIN46_PORTCLEAR = CORE_PIN46_BITMASK;
  1558. } else if (pin == 47) {
  1559. CORE_PIN47_PORTCLEAR = CORE_PIN47_BITMASK;
  1560. } else if (pin == 48) {
  1561. CORE_PIN48_PORTCLEAR = CORE_PIN48_BITMASK;
  1562. } else if (pin == 49) {
  1563. CORE_PIN49_PORTCLEAR = CORE_PIN49_BITMASK;
  1564. } else if (pin == 50) {
  1565. CORE_PIN50_PORTCLEAR = CORE_PIN50_BITMASK;
  1566. } else if (pin == 51) {
  1567. CORE_PIN51_PORTCLEAR = CORE_PIN51_BITMASK;
  1568. } else if (pin == 52) {
  1569. CORE_PIN52_PORTCLEAR = CORE_PIN52_BITMASK;
  1570. } else if (pin == 53) {
  1571. CORE_PIN53_PORTCLEAR = CORE_PIN53_BITMASK;
  1572. } else if (pin == 54) {
  1573. CORE_PIN54_PORTCLEAR = CORE_PIN54_BITMASK;
  1574. } else if (pin == 55) {
  1575. CORE_PIN55_PORTCLEAR = CORE_PIN55_BITMASK;
  1576. } else if (pin == 56) {
  1577. CORE_PIN56_PORTCLEAR = CORE_PIN56_BITMASK;
  1578. } else if (pin == 57) {
  1579. CORE_PIN57_PORTCLEAR = CORE_PIN57_BITMASK;
  1580. } else if (pin == 58) {
  1581. CORE_PIN58_PORTCLEAR = CORE_PIN58_BITMASK;
  1582. } else if (pin == 59) {
  1583. CORE_PIN59_PORTCLEAR = CORE_PIN59_BITMASK;
  1584. } else if (pin == 60) {
  1585. CORE_PIN60_PORTCLEAR = CORE_PIN60_BITMASK;
  1586. } else if (pin == 61) {
  1587. CORE_PIN61_PORTCLEAR = CORE_PIN61_BITMASK;
  1588. } else if (pin == 62) {
  1589. CORE_PIN62_PORTCLEAR = CORE_PIN62_BITMASK;
  1590. } else if (pin == 63) {
  1591. CORE_PIN63_PORTCLEAR = CORE_PIN63_BITMASK;
  1592. }
  1593. #endif
  1594. }
  1595. } else {
  1596. if (val) {
  1597. *portSetRegister(pin) = digitalPinToBitMask(pin);
  1598. } else {
  1599. *portClearRegister(pin) = digitalPinToBitMask(pin);
  1600. }
  1601. }
  1602. }
  1603. uint8_t digitalRead(uint8_t pin);
  1604. static inline uint8_t digitalReadFast(uint8_t pin) __attribute__((always_inline, unused));
  1605. static inline uint8_t digitalReadFast(uint8_t pin)
  1606. {
  1607. if (__builtin_constant_p(pin)) {
  1608. if (pin == 0) {
  1609. return (CORE_PIN0_PINREG & CORE_PIN0_BITMASK) ? 1 : 0;
  1610. } else if (pin == 1) {
  1611. return (CORE_PIN1_PINREG & CORE_PIN1_BITMASK) ? 1 : 0;
  1612. } else if (pin == 2) {
  1613. return (CORE_PIN2_PINREG & CORE_PIN2_BITMASK) ? 1 : 0;
  1614. } else if (pin == 3) {
  1615. return (CORE_PIN3_PINREG & CORE_PIN3_BITMASK) ? 1 : 0;
  1616. } else if (pin == 4) {
  1617. return (CORE_PIN4_PINREG & CORE_PIN4_BITMASK) ? 1 : 0;
  1618. } else if (pin == 5) {
  1619. return (CORE_PIN5_PINREG & CORE_PIN5_BITMASK) ? 1 : 0;
  1620. } else if (pin == 6) {
  1621. return (CORE_PIN6_PINREG & CORE_PIN6_BITMASK) ? 1 : 0;
  1622. } else if (pin == 7) {
  1623. return (CORE_PIN7_PINREG & CORE_PIN7_BITMASK) ? 1 : 0;
  1624. } else if (pin == 8) {
  1625. return (CORE_PIN8_PINREG & CORE_PIN8_BITMASK) ? 1 : 0;
  1626. } else if (pin == 9) {
  1627. return (CORE_PIN9_PINREG & CORE_PIN9_BITMASK) ? 1 : 0;
  1628. } else if (pin == 10) {
  1629. return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
  1630. } else if (pin == 11) {
  1631. return (CORE_PIN11_PINREG & CORE_PIN11_BITMASK) ? 1 : 0;
  1632. } else if (pin == 12) {
  1633. return (CORE_PIN12_PINREG & CORE_PIN12_BITMASK) ? 1 : 0;
  1634. } else if (pin == 13) {
  1635. return (CORE_PIN13_PINREG & CORE_PIN13_BITMASK) ? 1 : 0;
  1636. } else if (pin == 14) {
  1637. return (CORE_PIN14_PINREG & CORE_PIN14_BITMASK) ? 1 : 0;
  1638. } else if (pin == 15) {
  1639. return (CORE_PIN15_PINREG & CORE_PIN15_BITMASK) ? 1 : 0;
  1640. } else if (pin == 16) {
  1641. return (CORE_PIN16_PINREG & CORE_PIN16_BITMASK) ? 1 : 0;
  1642. } else if (pin == 17) {
  1643. return (CORE_PIN17_PINREG & CORE_PIN17_BITMASK) ? 1 : 0;
  1644. } else if (pin == 18) {
  1645. return (CORE_PIN18_PINREG & CORE_PIN18_BITMASK) ? 1 : 0;
  1646. } else if (pin == 19) {
  1647. return (CORE_PIN19_PINREG & CORE_PIN19_BITMASK) ? 1 : 0;
  1648. } else if (pin == 20) {
  1649. return (CORE_PIN20_PINREG & CORE_PIN20_BITMASK) ? 1 : 0;
  1650. } else if (pin == 21) {
  1651. return (CORE_PIN21_PINREG & CORE_PIN21_BITMASK) ? 1 : 0;
  1652. } else if (pin == 22) {
  1653. return (CORE_PIN22_PINREG & CORE_PIN22_BITMASK) ? 1 : 0;
  1654. } else if (pin == 23) {
  1655. return (CORE_PIN23_PINREG & CORE_PIN23_BITMASK) ? 1 : 0;
  1656. } else if (pin == 24) {
  1657. return (CORE_PIN24_PINREG & CORE_PIN24_BITMASK) ? 1 : 0;
  1658. } else if (pin == 25) {
  1659. return (CORE_PIN25_PINREG & CORE_PIN25_BITMASK) ? 1 : 0;
  1660. } else if (pin == 26) {
  1661. return (CORE_PIN26_PINREG & CORE_PIN26_BITMASK) ? 1 : 0;
  1662. }
  1663. #if defined(CORE_PIN27_PINREG)
  1664. else if (pin == 27) {
  1665. return (CORE_PIN27_PINREG & CORE_PIN27_BITMASK) ? 1 : 0;
  1666. } else if (pin == 28) {
  1667. return (CORE_PIN28_PINREG & CORE_PIN28_BITMASK) ? 1 : 0;
  1668. } else if (pin == 29) {
  1669. return (CORE_PIN29_PINREG & CORE_PIN29_BITMASK) ? 1 : 0;
  1670. } else if (pin == 30) {
  1671. return (CORE_PIN30_PINREG & CORE_PIN30_BITMASK) ? 1 : 0;
  1672. } else if (pin == 31) {
  1673. return (CORE_PIN31_PINREG & CORE_PIN31_BITMASK) ? 1 : 0;
  1674. } else if (pin == 32) {
  1675. return (CORE_PIN32_PINREG & CORE_PIN32_BITMASK) ? 1 : 0;
  1676. } else if (pin == 33) {
  1677. return (CORE_PIN33_PINREG & CORE_PIN33_BITMASK) ? 1 : 0;
  1678. }
  1679. #endif
  1680. #if defined(CORE_PIN34_PINREG)
  1681. else if (pin == 34) {
  1682. return (CORE_PIN34_PINREG & CORE_PIN34_BITMASK) ? 1 : 0;
  1683. } else if (pin == 35) {
  1684. return (CORE_PIN35_PINREG & CORE_PIN35_BITMASK) ? 1 : 0;
  1685. } else if (pin == 36) {
  1686. return (CORE_PIN36_PINREG & CORE_PIN36_BITMASK) ? 1 : 0;
  1687. } else if (pin == 37) {
  1688. return (CORE_PIN37_PINREG & CORE_PIN37_BITMASK) ? 1 : 0;
  1689. } else if (pin == 38) {
  1690. return (CORE_PIN38_PINREG & CORE_PIN38_BITMASK) ? 1 : 0;
  1691. } else if (pin == 39) {
  1692. return (CORE_PIN39_PINREG & CORE_PIN39_BITMASK) ? 1 : 0;
  1693. } else if (pin == 40) {
  1694. return (CORE_PIN40_PINREG & CORE_PIN40_BITMASK) ? 1 : 0;
  1695. } else if (pin == 41) {
  1696. return (CORE_PIN41_PINREG & CORE_PIN41_BITMASK) ? 1 : 0;
  1697. } else if (pin == 42) {
  1698. return (CORE_PIN42_PINREG & CORE_PIN42_BITMASK) ? 1 : 0;
  1699. } else if (pin == 43) {
  1700. return (CORE_PIN43_PINREG & CORE_PIN43_BITMASK) ? 1 : 0;
  1701. } else if (pin == 44) {
  1702. return (CORE_PIN44_PINREG & CORE_PIN44_BITMASK) ? 1 : 0;
  1703. } else if (pin == 45) {
  1704. return (CORE_PIN45_PINREG & CORE_PIN45_BITMASK) ? 1 : 0;
  1705. } else if (pin == 46) {
  1706. return (CORE_PIN46_PINREG & CORE_PIN46_BITMASK) ? 1 : 0;
  1707. } else if (pin == 47) {
  1708. return (CORE_PIN47_PINREG & CORE_PIN47_BITMASK) ? 1 : 0;
  1709. } else if (pin == 48) {
  1710. return (CORE_PIN48_PINREG & CORE_PIN48_BITMASK) ? 1 : 0;
  1711. } else if (pin == 49) {
  1712. return (CORE_PIN49_PINREG & CORE_PIN49_BITMASK) ? 1 : 0;
  1713. } else if (pin == 50) {
  1714. return (CORE_PIN50_PINREG & CORE_PIN50_BITMASK) ? 1 : 0;
  1715. } else if (pin == 51) {
  1716. return (CORE_PIN51_PINREG & CORE_PIN51_BITMASK) ? 1 : 0;
  1717. } else if (pin == 52) {
  1718. return (CORE_PIN52_PINREG & CORE_PIN52_BITMASK) ? 1 : 0;
  1719. } else if (pin == 53) {
  1720. return (CORE_PIN53_PINREG & CORE_PIN53_BITMASK) ? 1 : 0;
  1721. } else if (pin == 54) {
  1722. return (CORE_PIN54_PINREG & CORE_PIN54_BITMASK) ? 1 : 0;
  1723. } else if (pin == 55) {
  1724. return (CORE_PIN55_PINREG & CORE_PIN55_BITMASK) ? 1 : 0;
  1725. } else if (pin == 56) {
  1726. return (CORE_PIN56_PINREG & CORE_PIN56_BITMASK) ? 1 : 0;
  1727. } else if (pin == 57) {
  1728. return (CORE_PIN57_PINREG & CORE_PIN57_BITMASK) ? 1 : 0;
  1729. } else if (pin == 58) {
  1730. return (CORE_PIN58_PINREG & CORE_PIN58_BITMASK) ? 1 : 0;
  1731. } else if (pin == 59) {
  1732. return (CORE_PIN59_PINREG & CORE_PIN59_BITMASK) ? 1 : 0;
  1733. } else if (pin == 60) {
  1734. return (CORE_PIN60_PINREG & CORE_PIN60_BITMASK) ? 1 : 0;
  1735. } else if (pin == 61) {
  1736. return (CORE_PIN61_PINREG & CORE_PIN61_BITMASK) ? 1 : 0;
  1737. } else if (pin == 62) {
  1738. return (CORE_PIN62_PINREG & CORE_PIN62_BITMASK) ? 1 : 0;
  1739. } else if (pin == 63) {
  1740. return (CORE_PIN63_PINREG & CORE_PIN63_BITMASK) ? 1 : 0;
  1741. }
  1742. #endif
  1743. else {
  1744. return 0;
  1745. }
  1746. } else {
  1747. #if defined(KINETISK)
  1748. return *portInputRegister(pin);
  1749. #else
  1750. return (*portInputRegister(pin) & digitalPinToBitMask(pin)) ? 1 : 0;
  1751. #endif
  1752. }
  1753. }
  1754. void pinMode(uint8_t pin, uint8_t mode);
  1755. void init_pins(void);
  1756. void analogWrite(uint8_t pin, int val);
  1757. void analogWriteRes(uint32_t bits);
  1758. static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); }
  1759. void analogWriteFrequency(uint8_t pin, float frequency);
  1760. void analogWriteDAC0(int val);
  1761. void analogWriteDAC1(int val);
  1762. #ifdef __cplusplus
  1763. void attachInterruptVector(IRQ_NUMBER_t irq, void (*function)(void));
  1764. #else
  1765. void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void));
  1766. #endif
  1767. void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
  1768. void detachInterrupt(uint8_t pin);
  1769. void _init_Teensyduino_internal_(void);
  1770. int analogRead(uint8_t pin);
  1771. void analogReference(uint8_t type);
  1772. void analogReadRes(unsigned int bits);
  1773. static inline void analogReadResolution(unsigned int bits) { analogReadRes(bits); }
  1774. void analogReadAveraging(unsigned int num);
  1775. void analog_init(void);
  1776. #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
  1777. #define DEFAULT 0
  1778. #define INTERNAL 2
  1779. #define INTERNAL1V2 2
  1780. #define INTERNAL1V1 2
  1781. #define EXTERNAL 0
  1782. #elif defined(__MKL26Z64__)
  1783. #define DEFAULT 0
  1784. #define INTERNAL 0
  1785. #define EXTERNAL 1
  1786. #endif
  1787. int touchRead(uint8_t pin);
  1788. static inline void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1789. extern void _shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) __attribute__((noinline));
  1790. extern void shiftOut_lsbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1791. extern void shiftOut_msbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1792. static inline void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
  1793. {
  1794. if (__builtin_constant_p(bitOrder)) {
  1795. if (bitOrder == LSBFIRST) {
  1796. shiftOut_lsbFirst(dataPin, clockPin, value);
  1797. } else {
  1798. shiftOut_msbFirst(dataPin, clockPin, value);
  1799. }
  1800. } else {
  1801. _shiftOut(dataPin, clockPin, bitOrder, value);
  1802. }
  1803. }
  1804. static inline uint8_t shiftIn(uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1805. extern uint8_t _shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) __attribute__((noinline));
  1806. extern uint8_t shiftIn_lsbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1807. extern uint8_t shiftIn_msbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1808. static inline uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
  1809. {
  1810. if (__builtin_constant_p(bitOrder)) {
  1811. if (bitOrder == LSBFIRST) {
  1812. return shiftIn_lsbFirst(dataPin, clockPin);
  1813. } else {
  1814. return shiftIn_msbFirst(dataPin, clockPin);
  1815. }
  1816. } else {
  1817. return _shiftIn(dataPin, clockPin, bitOrder);
  1818. }
  1819. }
  1820. void _reboot_Teensyduino_(void) __attribute__((noreturn));
  1821. void _restart_Teensyduino_(void) __attribute__((noreturn));
  1822. void yield(void);
  1823. void delay(uint32_t msec);
  1824. extern volatile uint32_t systick_millis_count;
  1825. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  1826. static inline uint32_t millis(void)
  1827. {
  1828. // Reading a volatile variable to another volatile
  1829. // seems redundant, but isn't for some cases.
  1830. // Eventually this should probably be replaced by a
  1831. // proper memory barrier or other technique. Please
  1832. // do not remove this "redundant" code without
  1833. // carefully verifying the case mentioned here:
  1834. //
  1835. // https://forum.pjrc.com/threads/17469-millis%28%29-on-teensy-3?p=104924&viewfull=1#post104924
  1836. //
  1837. volatile uint32_t ret = systick_millis_count; // single aligned 32 bit is atomic
  1838. return ret;
  1839. }
  1840. uint32_t micros(void);
  1841. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  1842. static inline void delayMicroseconds(uint32_t usec)
  1843. {
  1844. #if F_CPU == 240000000
  1845. uint32_t n = usec * 80;
  1846. #elif F_CPU == 216000000
  1847. uint32_t n = usec * 72;
  1848. #elif F_CPU == 192000000
  1849. uint32_t n = usec * 64;
  1850. #elif F_CPU == 180000000
  1851. uint32_t n = usec * 60;
  1852. #elif F_CPU == 168000000
  1853. uint32_t n = usec * 56;
  1854. #elif F_CPU == 144000000
  1855. uint32_t n = usec * 48;
  1856. #elif F_CPU == 120000000
  1857. uint32_t n = usec * 40;
  1858. #elif F_CPU == 96000000
  1859. uint32_t n = usec << 5;
  1860. #elif F_CPU == 72000000
  1861. uint32_t n = usec * 24;
  1862. #elif F_CPU == 48000000
  1863. uint32_t n = usec << 4;
  1864. #elif F_CPU == 24000000
  1865. uint32_t n = usec << 3;
  1866. #elif F_CPU == 16000000
  1867. uint32_t n = usec << 2;
  1868. #elif F_CPU == 8000000
  1869. uint32_t n = usec << 1;
  1870. #elif F_CPU == 4000000
  1871. uint32_t n = usec;
  1872. #elif F_CPU == 2000000
  1873. uint32_t n = usec >> 1;
  1874. #endif
  1875. // changed because a delay of 1 micro Sec @ 2MHz will be 0
  1876. if (n == 0) return;
  1877. __asm__ volatile(
  1878. "L_%=_delayMicroseconds:" "\n\t"
  1879. #if F_CPU < 24000000
  1880. "nop" "\n\t"
  1881. #endif
  1882. #ifdef KINETISL
  1883. "sub %0, #1" "\n\t"
  1884. #else
  1885. "subs %0, #1" "\n\t"
  1886. #endif
  1887. "bne L_%=_delayMicroseconds" "\n"
  1888. : "+r" (n) :
  1889. );
  1890. }
  1891. #ifdef __cplusplus
  1892. }
  1893. #endif
  1894. #ifdef __cplusplus
  1895. extern "C" {
  1896. #endif
  1897. unsigned long rtc_get(void);
  1898. void rtc_set(unsigned long t);
  1899. void rtc_compensate(int adjust);
  1900. #ifdef __cplusplus
  1901. }
  1902. class teensy3_clock_class
  1903. {
  1904. public:
  1905. static unsigned long get(void) __attribute__((always_inline)) { return rtc_get(); }
  1906. static void set(unsigned long t) __attribute__((always_inline)) { rtc_set(t); }
  1907. static void compensate(int adj) __attribute__((always_inline)) { rtc_compensate(adj); }
  1908. };
  1909. extern teensy3_clock_class Teensy3Clock;
  1910. #endif
  1911. #endif