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.

1611 lines
60KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2018 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. #pragma once
  31. #include "imxrt.h"
  32. #include "pins_arduino.h"
  33. #define HIGH 1
  34. #define LOW 0
  35. #define INPUT 0
  36. #define OUTPUT 1
  37. #define INPUT_PULLUP 2
  38. #define INPUT_PULLDOWN 3
  39. #define OUTPUT_OPENDRAIN 4
  40. #define INPUT_DISABLE 5
  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. #if defined(__IMXRT1062__) && defined(ARDUINO_TEENSY40)
  48. #define CORE_NUM_TOTAL_PINS 40
  49. #define CORE_NUM_DIGITAL 40
  50. #define CORE_NUM_INTERRUPT 40
  51. #define CORE_NUM_ANALOG 14
  52. #define CORE_NUM_PWM 27
  53. #define CORE_PIN0_BIT 3
  54. #define CORE_PIN1_BIT 2
  55. #define CORE_PIN2_BIT 4
  56. #define CORE_PIN3_BIT 5
  57. #define CORE_PIN4_BIT 6
  58. #define CORE_PIN5_BIT 8
  59. #define CORE_PIN6_BIT 10
  60. #define CORE_PIN7_BIT 17
  61. #define CORE_PIN8_BIT 16
  62. #define CORE_PIN9_BIT 11
  63. #define CORE_PIN10_BIT 0
  64. #define CORE_PIN11_BIT 2
  65. #define CORE_PIN12_BIT 1
  66. #define CORE_PIN13_BIT 3
  67. #define CORE_PIN14_BIT 18
  68. #define CORE_PIN15_BIT 19
  69. #define CORE_PIN16_BIT 23
  70. #define CORE_PIN17_BIT 22
  71. #define CORE_PIN18_BIT 17
  72. #define CORE_PIN19_BIT 16
  73. #define CORE_PIN20_BIT 26
  74. #define CORE_PIN21_BIT 27
  75. #define CORE_PIN22_BIT 24
  76. #define CORE_PIN23_BIT 25
  77. #define CORE_PIN24_BIT 12
  78. #define CORE_PIN25_BIT 13
  79. #define CORE_PIN26_BIT 30
  80. #define CORE_PIN27_BIT 31
  81. #define CORE_PIN28_BIT 18
  82. #define CORE_PIN29_BIT 31
  83. #define CORE_PIN30_BIT 23
  84. #define CORE_PIN31_BIT 22
  85. #define CORE_PIN32_BIT 12
  86. #define CORE_PIN33_BIT 7
  87. #define CORE_PIN34_BIT 15
  88. #define CORE_PIN35_BIT 14
  89. #define CORE_PIN36_BIT 13
  90. #define CORE_PIN37_BIT 12
  91. #define CORE_PIN38_BIT 17
  92. #define CORE_PIN39_BIT 16
  93. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  94. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  95. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  96. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  97. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  98. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  99. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  100. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  101. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  102. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  103. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  104. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  105. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  106. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  107. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  108. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  109. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  110. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  111. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  112. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  113. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  114. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  115. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  116. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  117. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  118. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  119. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  120. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  121. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  122. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  123. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  124. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  125. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  126. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  127. #define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
  128. #define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
  129. #define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
  130. #define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
  131. #define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
  132. #define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))
  133. // Fast GPIO
  134. #define CORE_PIN0_PORTREG GPIO6_DR
  135. #define CORE_PIN1_PORTREG GPIO6_DR
  136. #define CORE_PIN2_PORTREG GPIO9_DR
  137. #define CORE_PIN3_PORTREG GPIO9_DR
  138. #define CORE_PIN4_PORTREG GPIO9_DR
  139. #define CORE_PIN5_PORTREG GPIO9_DR
  140. #define CORE_PIN6_PORTREG GPIO7_DR
  141. #define CORE_PIN7_PORTREG GPIO7_DR
  142. #define CORE_PIN8_PORTREG GPIO7_DR
  143. #define CORE_PIN9_PORTREG GPIO7_DR
  144. #define CORE_PIN10_PORTREG GPIO7_DR
  145. #define CORE_PIN11_PORTREG GPIO7_DR
  146. #define CORE_PIN12_PORTREG GPIO7_DR
  147. #define CORE_PIN13_PORTREG GPIO7_DR
  148. #define CORE_PIN14_PORTREG GPIO6_DR
  149. #define CORE_PIN15_PORTREG GPIO6_DR
  150. #define CORE_PIN16_PORTREG GPIO6_DR
  151. #define CORE_PIN17_PORTREG GPIO6_DR
  152. #define CORE_PIN18_PORTREG GPIO6_DR
  153. #define CORE_PIN19_PORTREG GPIO6_DR
  154. #define CORE_PIN20_PORTREG GPIO6_DR
  155. #define CORE_PIN21_PORTREG GPIO6_DR
  156. #define CORE_PIN22_PORTREG GPIO6_DR
  157. #define CORE_PIN23_PORTREG GPIO6_DR
  158. #define CORE_PIN24_PORTREG GPIO6_DR
  159. #define CORE_PIN25_PORTREG GPIO6_DR
  160. #define CORE_PIN26_PORTREG GPIO6_DR
  161. #define CORE_PIN27_PORTREG GPIO6_DR
  162. #define CORE_PIN28_PORTREG GPIO8_DR
  163. #define CORE_PIN29_PORTREG GPIO9_DR
  164. #define CORE_PIN30_PORTREG GPIO8_DR
  165. #define CORE_PIN31_PORTREG GPIO8_DR
  166. #define CORE_PIN32_PORTREG GPIO7_DR
  167. #define CORE_PIN33_PORTREG GPIO9_DR
  168. #define CORE_PIN34_PORTREG GPIO8_DR
  169. #define CORE_PIN35_PORTREG GPIO8_DR
  170. #define CORE_PIN36_PORTREG GPIO8_DR
  171. #define CORE_PIN37_PORTREG GPIO8_DR
  172. #define CORE_PIN38_PORTREG GPIO8_DR
  173. #define CORE_PIN39_PORTREG GPIO8_DR
  174. #define CORE_PIN0_PORTSET GPIO6_DR_SET
  175. #define CORE_PIN1_PORTSET GPIO6_DR_SET
  176. #define CORE_PIN2_PORTSET GPIO9_DR_SET
  177. #define CORE_PIN3_PORTSET GPIO9_DR_SET
  178. #define CORE_PIN4_PORTSET GPIO9_DR_SET
  179. #define CORE_PIN5_PORTSET GPIO9_DR_SET
  180. #define CORE_PIN6_PORTSET GPIO7_DR_SET
  181. #define CORE_PIN7_PORTSET GPIO7_DR_SET
  182. #define CORE_PIN8_PORTSET GPIO7_DR_SET
  183. #define CORE_PIN9_PORTSET GPIO7_DR_SET
  184. #define CORE_PIN10_PORTSET GPIO7_DR_SET
  185. #define CORE_PIN11_PORTSET GPIO7_DR_SET
  186. #define CORE_PIN12_PORTSET GPIO7_DR_SET
  187. #define CORE_PIN13_PORTSET GPIO7_DR_SET
  188. #define CORE_PIN14_PORTSET GPIO6_DR_SET
  189. #define CORE_PIN15_PORTSET GPIO6_DR_SET
  190. #define CORE_PIN16_PORTSET GPIO6_DR_SET
  191. #define CORE_PIN17_PORTSET GPIO6_DR_SET
  192. #define CORE_PIN18_PORTSET GPIO6_DR_SET
  193. #define CORE_PIN19_PORTSET GPIO6_DR_SET
  194. #define CORE_PIN20_PORTSET GPIO6_DR_SET
  195. #define CORE_PIN21_PORTSET GPIO6_DR_SET
  196. #define CORE_PIN22_PORTSET GPIO6_DR_SET
  197. #define CORE_PIN23_PORTSET GPIO6_DR_SET
  198. #define CORE_PIN24_PORTSET GPIO6_DR_SET
  199. #define CORE_PIN25_PORTSET GPIO6_DR_SET
  200. #define CORE_PIN26_PORTSET GPIO6_DR_SET
  201. #define CORE_PIN27_PORTSET GPIO6_DR_SET
  202. #define CORE_PIN28_PORTSET GPIO8_DR_SET
  203. #define CORE_PIN29_PORTSET GPIO9_DR_SET
  204. #define CORE_PIN30_PORTSET GPIO8_DR_SET
  205. #define CORE_PIN31_PORTSET GPIO8_DR_SET
  206. #define CORE_PIN32_PORTSET GPIO7_DR_SET
  207. #define CORE_PIN33_PORTSET GPIO9_DR_SET
  208. #define CORE_PIN34_PORTSET GPIO8_DR_SET
  209. #define CORE_PIN35_PORTSET GPIO8_DR_SET
  210. #define CORE_PIN36_PORTSET GPIO8_DR_SET
  211. #define CORE_PIN37_PORTSET GPIO8_DR_SET
  212. #define CORE_PIN38_PORTSET GPIO8_DR_SET
  213. #define CORE_PIN39_PORTSET GPIO8_DR_SET
  214. #define CORE_PIN0_PORTCLEAR GPIO6_DR_CLEAR
  215. #define CORE_PIN1_PORTCLEAR GPIO6_DR_CLEAR
  216. #define CORE_PIN2_PORTCLEAR GPIO9_DR_CLEAR
  217. #define CORE_PIN3_PORTCLEAR GPIO9_DR_CLEAR
  218. #define CORE_PIN4_PORTCLEAR GPIO9_DR_CLEAR
  219. #define CORE_PIN5_PORTCLEAR GPIO9_DR_CLEAR
  220. #define CORE_PIN6_PORTCLEAR GPIO7_DR_CLEAR
  221. #define CORE_PIN7_PORTCLEAR GPIO7_DR_CLEAR
  222. #define CORE_PIN8_PORTCLEAR GPIO7_DR_CLEAR
  223. #define CORE_PIN9_PORTCLEAR GPIO7_DR_CLEAR
  224. #define CORE_PIN10_PORTCLEAR GPIO7_DR_CLEAR
  225. #define CORE_PIN11_PORTCLEAR GPIO7_DR_CLEAR
  226. #define CORE_PIN12_PORTCLEAR GPIO7_DR_CLEAR
  227. #define CORE_PIN13_PORTCLEAR GPIO7_DR_CLEAR
  228. #define CORE_PIN14_PORTCLEAR GPIO6_DR_CLEAR
  229. #define CORE_PIN15_PORTCLEAR GPIO6_DR_CLEAR
  230. #define CORE_PIN16_PORTCLEAR GPIO6_DR_CLEAR
  231. #define CORE_PIN17_PORTCLEAR GPIO6_DR_CLEAR
  232. #define CORE_PIN18_PORTCLEAR GPIO6_DR_CLEAR
  233. #define CORE_PIN19_PORTCLEAR GPIO6_DR_CLEAR
  234. #define CORE_PIN20_PORTCLEAR GPIO6_DR_CLEAR
  235. #define CORE_PIN21_PORTCLEAR GPIO6_DR_CLEAR
  236. #define CORE_PIN22_PORTCLEAR GPIO6_DR_CLEAR
  237. #define CORE_PIN23_PORTCLEAR GPIO6_DR_CLEAR
  238. #define CORE_PIN24_PORTCLEAR GPIO6_DR_CLEAR
  239. #define CORE_PIN25_PORTCLEAR GPIO6_DR_CLEAR
  240. #define CORE_PIN26_PORTCLEAR GPIO6_DR_CLEAR
  241. #define CORE_PIN27_PORTCLEAR GPIO6_DR_CLEAR
  242. #define CORE_PIN28_PORTCLEAR GPIO8_DR_CLEAR
  243. #define CORE_PIN29_PORTCLEAR GPIO9_DR_CLEAR
  244. #define CORE_PIN30_PORTCLEAR GPIO8_DR_CLEAR
  245. #define CORE_PIN31_PORTCLEAR GPIO8_DR_CLEAR
  246. #define CORE_PIN32_PORTCLEAR GPIO7_DR_CLEAR
  247. #define CORE_PIN33_PORTCLEAR GPIO9_DR_CLEAR
  248. #define CORE_PIN34_PORTCLEAR GPIO8_DR_CLEAR
  249. #define CORE_PIN35_PORTCLEAR GPIO8_DR_CLEAR
  250. #define CORE_PIN36_PORTCLEAR GPIO8_DR_CLEAR
  251. #define CORE_PIN37_PORTCLEAR GPIO8_DR_CLEAR
  252. #define CORE_PIN38_PORTCLEAR GPIO8_DR_CLEAR
  253. #define CORE_PIN39_PORTCLEAR GPIO8_DR_CLEAR
  254. #define CORE_PIN0_DDRREG GPIO6_GDIR
  255. #define CORE_PIN1_DDRREG GPIO6_GDIR
  256. #define CORE_PIN2_DDRREG GPIO9_GDIR
  257. #define CORE_PIN3_DDRREG GPIO9_GDIR
  258. #define CORE_PIN4_DDRREG GPIO9_GDIR
  259. #define CORE_PIN5_DDRREG GPIO9_GDIR
  260. #define CORE_PIN6_DDRREG GPIO7_GDIR
  261. #define CORE_PIN7_DDRREG GPIO7_GDIR
  262. #define CORE_PIN8_DDRREG GPIO7_GDIR
  263. #define CORE_PIN9_DDRREG GPIO7_GDIR
  264. #define CORE_PIN10_DDRREG GPIO7_GDIR
  265. #define CORE_PIN11_DDRREG GPIO7_GDIR
  266. #define CORE_PIN12_DDRREG GPIO7_GDIR
  267. #define CORE_PIN13_DDRREG GPIO7_GDIR
  268. #define CORE_PIN14_DDRREG GPIO6_GDIR
  269. #define CORE_PIN15_DDRREG GPIO6_GDIR
  270. #define CORE_PIN16_DDRREG GPIO6_GDIR
  271. #define CORE_PIN17_DDRREG GPIO6_GDIR
  272. #define CORE_PIN18_DDRREG GPIO6_GDIR
  273. #define CORE_PIN19_DDRREG GPIO6_GDIR
  274. #define CORE_PIN20_DDRREG GPIO6_GDIR
  275. #define CORE_PIN21_DDRREG GPIO6_GDIR
  276. #define CORE_PIN22_DDRREG GPIO6_GDIR
  277. #define CORE_PIN23_DDRREG GPIO6_GDIR
  278. #define CORE_PIN24_DDRREG GPIO6_GDIR
  279. #define CORE_PIN25_DDRREG GPIO6_GDIR
  280. #define CORE_PIN26_DDRREG GPIO6_GDIR
  281. #define CORE_PIN27_DDRREG GPIO6_GDIR
  282. #define CORE_PIN28_DDRREG GPIO8_GDIR
  283. #define CORE_PIN29_DDRREG GPIO9_GDIR
  284. #define CORE_PIN30_DDRREG GPIO8_GDIR
  285. #define CORE_PIN31_DDRREG GPIO8_GDIR
  286. #define CORE_PIN32_DDRREG GPIO7_GDIR
  287. #define CORE_PIN33_DDRREG GPIO9_GDIR
  288. #define CORE_PIN34_DDRREG GPIO8_GDIR
  289. #define CORE_PIN35_DDRREG GPIO8_GDIR
  290. #define CORE_PIN36_DDRREG GPIO8_GDIR
  291. #define CORE_PIN37_DDRREG GPIO8_GDIR
  292. #define CORE_PIN38_DDRREG GPIO8_GDIR
  293. #define CORE_PIN39_DDRREG GPIO8_GDIR
  294. #define CORE_PIN0_PINREG GPIO6_PSR
  295. #define CORE_PIN1_PINREG GPIO6_PSR
  296. #define CORE_PIN2_PINREG GPIO9_PSR
  297. #define CORE_PIN3_PINREG GPIO9_PSR
  298. #define CORE_PIN4_PINREG GPIO9_PSR
  299. #define CORE_PIN5_PINREG GPIO9_PSR
  300. #define CORE_PIN6_PINREG GPIO7_PSR
  301. #define CORE_PIN7_PINREG GPIO7_PSR
  302. #define CORE_PIN8_PINREG GPIO7_PSR
  303. #define CORE_PIN9_PINREG GPIO7_PSR
  304. #define CORE_PIN10_PINREG GPIO7_PSR
  305. #define CORE_PIN11_PINREG GPIO7_PSR
  306. #define CORE_PIN12_PINREG GPIO7_PSR
  307. #define CORE_PIN13_PINREG GPIO7_PSR
  308. #define CORE_PIN14_PINREG GPIO6_PSR
  309. #define CORE_PIN15_PINREG GPIO6_PSR
  310. #define CORE_PIN16_PINREG GPIO6_PSR
  311. #define CORE_PIN17_PINREG GPIO6_PSR
  312. #define CORE_PIN18_PINREG GPIO6_PSR
  313. #define CORE_PIN19_PINREG GPIO6_PSR
  314. #define CORE_PIN20_PINREG GPIO6_PSR
  315. #define CORE_PIN21_PINREG GPIO6_PSR
  316. #define CORE_PIN22_PINREG GPIO6_PSR
  317. #define CORE_PIN23_PINREG GPIO6_PSR
  318. #define CORE_PIN24_PINREG GPIO6_PSR
  319. #define CORE_PIN25_PINREG GPIO6_PSR
  320. #define CORE_PIN26_PINREG GPIO6_PSR
  321. #define CORE_PIN27_PINREG GPIO6_PSR
  322. #define CORE_PIN28_PINREG GPIO8_PSR
  323. #define CORE_PIN29_PINREG GPIO9_PSR
  324. #define CORE_PIN30_PINREG GPIO8_PSR
  325. #define CORE_PIN31_PINREG GPIO8_PSR
  326. #define CORE_PIN32_PINREG GPIO7_PSR
  327. #define CORE_PIN33_PINREG GPIO9_PSR
  328. #define CORE_PIN34_PINREG GPIO8_PSR
  329. #define CORE_PIN35_PINREG GPIO8_PSR
  330. #define CORE_PIN36_PINREG GPIO8_PSR
  331. #define CORE_PIN37_PINREG GPIO8_PSR
  332. #define CORE_PIN38_PINREG GPIO8_PSR
  333. #define CORE_PIN39_PINREG GPIO8_PSR
  334. // mux config registers control which peripheral uses the pin
  335. #define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
  336. #define CORE_PIN1_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02
  337. #define CORE_PIN2_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04
  338. #define CORE_PIN3_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_05
  339. #define CORE_PIN4_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_06
  340. #define CORE_PIN5_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_08
  341. #define CORE_PIN6_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_10
  342. #define CORE_PIN7_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01
  343. #define CORE_PIN8_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00
  344. #define CORE_PIN9_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11
  345. #define CORE_PIN10_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_00
  346. #define CORE_PIN11_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_02
  347. #define CORE_PIN12_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_01
  348. #define CORE_PIN13_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03
  349. #define CORE_PIN14_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02
  350. #define CORE_PIN15_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03
  351. #define CORE_PIN16_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07
  352. #define CORE_PIN17_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06
  353. #define CORE_PIN18_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_01
  354. #define CORE_PIN19_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00
  355. #define CORE_PIN20_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10
  356. #define CORE_PIN21_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11
  357. #define CORE_PIN22_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_08
  358. #define CORE_PIN23_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_09
  359. #define CORE_PIN24_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12
  360. #define CORE_PIN25_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13
  361. #define CORE_PIN26_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_14
  362. #define CORE_PIN27_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_15
  363. #define CORE_PIN28_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32
  364. #define CORE_PIN29_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31
  365. #define CORE_PIN30_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_37
  366. #define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_36
  367. #define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
  368. #define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
  369. #define CORE_PIN34_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_03
  370. #define CORE_PIN35_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_02
  371. #define CORE_PIN36_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_01
  372. #define CORE_PIN37_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_00
  373. #define CORE_PIN38_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_05
  374. #define CORE_PIN39_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_04
  375. // pad config registers control pullup/pulldown/keeper, drive strength, etc
  376. #define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
  377. #define CORE_PIN1_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_02
  378. #define CORE_PIN2_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04
  379. #define CORE_PIN3_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_05
  380. #define CORE_PIN4_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_06
  381. #define CORE_PIN5_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_08
  382. #define CORE_PIN6_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
  383. #define CORE_PIN7_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01
  384. #define CORE_PIN8_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_00
  385. #define CORE_PIN9_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_11
  386. #define CORE_PIN10_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_00
  387. #define CORE_PIN11_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_02
  388. #define CORE_PIN12_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_01
  389. #define CORE_PIN13_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03
  390. #define CORE_PIN14_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02
  391. #define CORE_PIN15_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_03
  392. #define CORE_PIN16_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_07
  393. #define CORE_PIN17_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_06
  394. #define CORE_PIN18_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01
  395. #define CORE_PIN19_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00
  396. #define CORE_PIN20_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_10
  397. #define CORE_PIN21_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11
  398. #define CORE_PIN22_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_08
  399. #define CORE_PIN23_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_09
  400. #define CORE_PIN24_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_12
  401. #define CORE_PIN25_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_13
  402. #define CORE_PIN26_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_14
  403. #define CORE_PIN27_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_15
  404. #define CORE_PIN28_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_32
  405. #define CORE_PIN29_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_31
  406. #define CORE_PIN30_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_37
  407. #define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_36
  408. #define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
  409. #define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
  410. #define CORE_PIN34_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_03
  411. #define CORE_PIN35_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_02
  412. #define CORE_PIN36_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_01
  413. #define CORE_PIN37_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_00
  414. #define CORE_PIN38_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_05
  415. #define CORE_PIN39_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_04
  416. #define CORE_LED0_PIN 13
  417. #define CORE_ADC0_PIN 14
  418. #define CORE_ADC1_PIN 15
  419. #define CORE_ADC2_PIN 16
  420. #define CORE_ADC3_PIN 17
  421. #define CORE_ADC4_PIN 18
  422. #define CORE_ADC5_PIN 19
  423. #define CORE_ADC6_PIN 20
  424. #define CORE_ADC7_PIN 21
  425. #define CORE_ADC8_PIN 22
  426. #define CORE_ADC9_PIN 23
  427. #define CORE_RXD0_PIN 0
  428. #define CORE_TXD0_PIN 1
  429. #define CORE_RXD1_PIN 7
  430. #define CORE_TXD1_PIN 8
  431. #define CORE_RXD2_PIN 15
  432. #define CORE_TXD2_PIN 14
  433. #define CORE_RXD3_PIN 16
  434. #define CORE_TXD3_PIN 17
  435. #define CORE_RXD4_PIN 21
  436. #define CORE_TXD4_PIN 20
  437. #define CORE_RXD5_PIN 25
  438. #define CORE_TXD5_PIN 24
  439. #define CORE_RXD6_PIN 28
  440. #define CORE_TXD6_PIN 29
  441. #define CORE_INT0_PIN 0
  442. #define CORE_INT1_PIN 1
  443. #define CORE_INT2_PIN 2
  444. #define CORE_INT3_PIN 3
  445. #define CORE_INT4_PIN 4
  446. #define CORE_INT5_PIN 5
  447. #define CORE_INT6_PIN 6
  448. #define CORE_INT7_PIN 7
  449. #define CORE_INT8_PIN 8
  450. #define CORE_INT9_PIN 9
  451. #define CORE_INT10_PIN 10
  452. #define CORE_INT11_PIN 11
  453. #define CORE_INT12_PIN 12
  454. #define CORE_INT13_PIN 13
  455. #define CORE_INT14_PIN 14
  456. #define CORE_INT15_PIN 15
  457. #define CORE_INT16_PIN 16
  458. #define CORE_INT17_PIN 17
  459. #define CORE_INT18_PIN 18
  460. #define CORE_INT19_PIN 19
  461. #define CORE_INT20_PIN 20
  462. #define CORE_INT21_PIN 21
  463. #define CORE_INT22_PIN 22
  464. #define CORE_INT23_PIN 23
  465. #define CORE_INT24_PIN 24
  466. #define CORE_INT25_PIN 25
  467. #define CORE_INT26_PIN 26
  468. #define CORE_INT27_PIN 27
  469. #define CORE_INT28_PIN 28
  470. #define CORE_INT29_PIN 29
  471. #define CORE_INT30_PIN 30
  472. #define CORE_INT31_PIN 31
  473. #define CORE_INT32_PIN 32
  474. #define CORE_INT33_PIN 33
  475. #define CORE_INT34_PIN 34
  476. #define CORE_INT35_PIN 35
  477. #define CORE_INT36_PIN 36
  478. #define CORE_INT37_PIN 37
  479. #define CORE_INT38_PIN 38
  480. #define CORE_INT39_PIN 39
  481. #define CORE_INT_EVERY_PIN 1
  482. #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
  483. #define CORE_NUM_TOTAL_PINS 55
  484. #define CORE_NUM_DIGITAL 55
  485. #define CORE_NUM_INTERRUPT 55
  486. #define CORE_NUM_ANALOG 18
  487. #define CORE_NUM_PWM 31
  488. #define CORE_PIN0_BIT 3
  489. #define CORE_PIN1_BIT 2
  490. #define CORE_PIN2_BIT 4
  491. #define CORE_PIN3_BIT 5
  492. #define CORE_PIN4_BIT 6
  493. #define CORE_PIN5_BIT 8
  494. #define CORE_PIN6_BIT 10
  495. #define CORE_PIN7_BIT 17
  496. #define CORE_PIN8_BIT 16
  497. #define CORE_PIN9_BIT 11
  498. #define CORE_PIN10_BIT 0
  499. #define CORE_PIN11_BIT 2
  500. #define CORE_PIN12_BIT 1
  501. #define CORE_PIN13_BIT 3
  502. #define CORE_PIN14_BIT 18
  503. #define CORE_PIN15_BIT 19
  504. #define CORE_PIN16_BIT 23
  505. #define CORE_PIN17_BIT 22
  506. #define CORE_PIN18_BIT 17
  507. #define CORE_PIN19_BIT 16
  508. #define CORE_PIN20_BIT 26
  509. #define CORE_PIN21_BIT 27
  510. #define CORE_PIN22_BIT 24
  511. #define CORE_PIN23_BIT 25
  512. #define CORE_PIN24_BIT 12
  513. #define CORE_PIN25_BIT 13
  514. #define CORE_PIN26_BIT 30
  515. #define CORE_PIN27_BIT 31
  516. #define CORE_PIN28_BIT 18
  517. #define CORE_PIN29_BIT 31
  518. #define CORE_PIN30_BIT 23
  519. #define CORE_PIN31_BIT 22
  520. #define CORE_PIN32_BIT 12
  521. #define CORE_PIN33_BIT 7
  522. #define CORE_PIN34_BIT 29
  523. #define CORE_PIN35_BIT 28
  524. #define CORE_PIN36_BIT 18
  525. #define CORE_PIN37_BIT 19
  526. #define CORE_PIN38_BIT 28
  527. #define CORE_PIN39_BIT 29
  528. #define CORE_PIN40_BIT 20
  529. #define CORE_PIN41_BIT 21
  530. #define CORE_PIN42_BIT 15
  531. #define CORE_PIN43_BIT 14
  532. #define CORE_PIN44_BIT 13
  533. #define CORE_PIN45_BIT 12
  534. #define CORE_PIN46_BIT 17
  535. #define CORE_PIN47_BIT 16
  536. #define CORE_PIN48_BIT 24
  537. #define CORE_PIN49_BIT 27
  538. #define CORE_PIN50_BIT 28
  539. #define CORE_PIN51_BIT 22
  540. #define CORE_PIN52_BIT 26
  541. #define CORE_PIN53_BIT 25
  542. #define CORE_PIN54_BIT 29
  543. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  544. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  545. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  546. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  547. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  548. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  549. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  550. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  551. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  552. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  553. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  554. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  555. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  556. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  557. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  558. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  559. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  560. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  561. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  562. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  563. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  564. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  565. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  566. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  567. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  568. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  569. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  570. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  571. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  572. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  573. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  574. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  575. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  576. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  577. #define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
  578. #define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
  579. #define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
  580. #define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
  581. #define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
  582. #define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))
  583. #define CORE_PIN40_BITMASK (1<<(CORE_PIN40_BIT))
  584. #define CORE_PIN41_BITMASK (1<<(CORE_PIN41_BIT))
  585. #define CORE_PIN42_BITMASK (1<<(CORE_PIN42_BIT))
  586. #define CORE_PIN43_BITMASK (1<<(CORE_PIN43_BIT))
  587. #define CORE_PIN44_BITMASK (1<<(CORE_PIN44_BIT))
  588. #define CORE_PIN45_BITMASK (1<<(CORE_PIN45_BIT))
  589. #define CORE_PIN46_BITMASK (1<<(CORE_PIN46_BIT))
  590. #define CORE_PIN47_BITMASK (1<<(CORE_PIN47_BIT))
  591. #define CORE_PIN48_BITMASK (1<<(CORE_PIN48_BIT))
  592. #define CORE_PIN49_BITMASK (1<<(CORE_PIN49_BIT))
  593. #define CORE_PIN50_BITMASK (1<<(CORE_PIN50_BIT))
  594. #define CORE_PIN51_BITMASK (1<<(CORE_PIN51_BIT))
  595. #define CORE_PIN52_BITMASK (1<<(CORE_PIN52_BIT))
  596. #define CORE_PIN53_BITMASK (1<<(CORE_PIN53_BIT))
  597. #define CORE_PIN54_BITMASK (1<<(CORE_PIN54_BIT))
  598. // Fast GPIO
  599. #define CORE_PIN0_PORTREG GPIO6_DR
  600. #define CORE_PIN1_PORTREG GPIO6_DR
  601. #define CORE_PIN2_PORTREG GPIO9_DR
  602. #define CORE_PIN3_PORTREG GPIO9_DR
  603. #define CORE_PIN4_PORTREG GPIO9_DR
  604. #define CORE_PIN5_PORTREG GPIO9_DR
  605. #define CORE_PIN6_PORTREG GPIO7_DR
  606. #define CORE_PIN7_PORTREG GPIO7_DR
  607. #define CORE_PIN8_PORTREG GPIO7_DR
  608. #define CORE_PIN9_PORTREG GPIO7_DR
  609. #define CORE_PIN10_PORTREG GPIO7_DR
  610. #define CORE_PIN11_PORTREG GPIO7_DR
  611. #define CORE_PIN12_PORTREG GPIO7_DR
  612. #define CORE_PIN13_PORTREG GPIO7_DR
  613. #define CORE_PIN14_PORTREG GPIO6_DR
  614. #define CORE_PIN15_PORTREG GPIO6_DR
  615. #define CORE_PIN16_PORTREG GPIO6_DR
  616. #define CORE_PIN17_PORTREG GPIO6_DR
  617. #define CORE_PIN18_PORTREG GPIO6_DR
  618. #define CORE_PIN19_PORTREG GPIO6_DR
  619. #define CORE_PIN20_PORTREG GPIO6_DR
  620. #define CORE_PIN21_PORTREG GPIO6_DR
  621. #define CORE_PIN22_PORTREG GPIO6_DR
  622. #define CORE_PIN23_PORTREG GPIO6_DR
  623. #define CORE_PIN24_PORTREG GPIO6_DR
  624. #define CORE_PIN25_PORTREG GPIO6_DR
  625. #define CORE_PIN26_PORTREG GPIO6_DR
  626. #define CORE_PIN27_PORTREG GPIO6_DR
  627. #define CORE_PIN28_PORTREG GPIO8_DR
  628. #define CORE_PIN29_PORTREG GPIO9_DR
  629. #define CORE_PIN30_PORTREG GPIO8_DR
  630. #define CORE_PIN31_PORTREG GPIO8_DR
  631. #define CORE_PIN32_PORTREG GPIO7_DR
  632. #define CORE_PIN33_PORTREG GPIO9_DR
  633. #define CORE_PIN34_PORTREG GPIO7_DR
  634. #define CORE_PIN35_PORTREG GPIO7_DR
  635. #define CORE_PIN36_PORTREG GPIO7_DR
  636. #define CORE_PIN37_PORTREG GPIO7_DR
  637. #define CORE_PIN38_PORTREG GPIO6_DR
  638. #define CORE_PIN39_PORTREG GPIO6_DR
  639. #define CORE_PIN40_PORTREG GPIO6_DR
  640. #define CORE_PIN41_PORTREG GPIO6_DR
  641. #define CORE_PIN42_PORTREG GPIO8_DR
  642. #define CORE_PIN43_PORTREG GPIO8_DR
  643. #define CORE_PIN44_PORTREG GPIO8_DR
  644. #define CORE_PIN45_PORTREG GPIO8_DR
  645. #define CORE_PIN46_PORTREG GPIO8_DR
  646. #define CORE_PIN47_PORTREG GPIO8_DR
  647. #define CORE_PIN48_PORTREG GPIO9_DR
  648. #define CORE_PIN49_PORTREG GPIO9_DR
  649. #define CORE_PIN50_PORTREG GPIO9_DR
  650. #define CORE_PIN51_PORTREG GPIO9_DR
  651. #define CORE_PIN52_PORTREG GPIO9_DR
  652. #define CORE_PIN53_PORTREG GPIO9_DR
  653. #define CORE_PIN54_PORTREG GPIO9_DR
  654. #define CORE_PIN0_PORTSET GPIO6_DR_SET
  655. #define CORE_PIN1_PORTSET GPIO6_DR_SET
  656. #define CORE_PIN2_PORTSET GPIO9_DR_SET
  657. #define CORE_PIN3_PORTSET GPIO9_DR_SET
  658. #define CORE_PIN4_PORTSET GPIO9_DR_SET
  659. #define CORE_PIN5_PORTSET GPIO9_DR_SET
  660. #define CORE_PIN6_PORTSET GPIO7_DR_SET
  661. #define CORE_PIN7_PORTSET GPIO7_DR_SET
  662. #define CORE_PIN8_PORTSET GPIO7_DR_SET
  663. #define CORE_PIN9_PORTSET GPIO7_DR_SET
  664. #define CORE_PIN10_PORTSET GPIO7_DR_SET
  665. #define CORE_PIN11_PORTSET GPIO7_DR_SET
  666. #define CORE_PIN12_PORTSET GPIO7_DR_SET
  667. #define CORE_PIN13_PORTSET GPIO7_DR_SET
  668. #define CORE_PIN14_PORTSET GPIO6_DR_SET
  669. #define CORE_PIN15_PORTSET GPIO6_DR_SET
  670. #define CORE_PIN16_PORTSET GPIO6_DR_SET
  671. #define CORE_PIN17_PORTSET GPIO6_DR_SET
  672. #define CORE_PIN18_PORTSET GPIO6_DR_SET
  673. #define CORE_PIN19_PORTSET GPIO6_DR_SET
  674. #define CORE_PIN20_PORTSET GPIO6_DR_SET
  675. #define CORE_PIN21_PORTSET GPIO6_DR_SET
  676. #define CORE_PIN22_PORTSET GPIO6_DR_SET
  677. #define CORE_PIN23_PORTSET GPIO6_DR_SET
  678. #define CORE_PIN24_PORTSET GPIO6_DR_SET
  679. #define CORE_PIN25_PORTSET GPIO6_DR_SET
  680. #define CORE_PIN26_PORTSET GPIO6_DR_SET
  681. #define CORE_PIN27_PORTSET GPIO6_DR_SET
  682. #define CORE_PIN28_PORTSET GPIO8_DR_SET
  683. #define CORE_PIN29_PORTSET GPIO9_DR_SET
  684. #define CORE_PIN30_PORTSET GPIO8_DR_SET
  685. #define CORE_PIN31_PORTSET GPIO8_DR_SET
  686. #define CORE_PIN32_PORTSET GPIO7_DR_SET
  687. #define CORE_PIN33_PORTSET GPIO9_DR_SET
  688. #define CORE_PIN34_PORTSET GPIO7_DR_SET
  689. #define CORE_PIN35_PORTSET GPIO7_DR_SET
  690. #define CORE_PIN36_PORTSET GPIO7_DR_SET
  691. #define CORE_PIN37_PORTSET GPIO7_DR_SET
  692. #define CORE_PIN38_PORTSET GPIO6_DR_SET
  693. #define CORE_PIN39_PORTSET GPIO6_DR_SET
  694. #define CORE_PIN40_PORTSET GPIO6_DR_SET
  695. #define CORE_PIN41_PORTSET GPIO6_DR_SET
  696. #define CORE_PIN42_PORTSET GPIO8_DR_SET
  697. #define CORE_PIN43_PORTSET GPIO8_DR_SET
  698. #define CORE_PIN44_PORTSET GPIO8_DR_SET
  699. #define CORE_PIN45_PORTSET GPIO8_DR_SET
  700. #define CORE_PIN46_PORTSET GPIO8_DR_SET
  701. #define CORE_PIN47_PORTSET GPIO8_DR_SET
  702. #define CORE_PIN48_PORTSET GPIO9_DR_SET
  703. #define CORE_PIN49_PORTSET GPIO9_DR_SET
  704. #define CORE_PIN50_PORTSET GPIO9_DR_SET
  705. #define CORE_PIN51_PORTSET GPIO9_DR_SET
  706. #define CORE_PIN52_PORTSET GPIO9_DR_SET
  707. #define CORE_PIN53_PORTSET GPIO9_DR_SET
  708. #define CORE_PIN54_PORTSET GPIO9_DR_SET
  709. #define CORE_PIN0_PORTCLEAR GPIO6_DR_CLEAR
  710. #define CORE_PIN1_PORTCLEAR GPIO6_DR_CLEAR
  711. #define CORE_PIN2_PORTCLEAR GPIO9_DR_CLEAR
  712. #define CORE_PIN3_PORTCLEAR GPIO9_DR_CLEAR
  713. #define CORE_PIN4_PORTCLEAR GPIO9_DR_CLEAR
  714. #define CORE_PIN5_PORTCLEAR GPIO9_DR_CLEAR
  715. #define CORE_PIN6_PORTCLEAR GPIO7_DR_CLEAR
  716. #define CORE_PIN7_PORTCLEAR GPIO7_DR_CLEAR
  717. #define CORE_PIN8_PORTCLEAR GPIO7_DR_CLEAR
  718. #define CORE_PIN9_PORTCLEAR GPIO7_DR_CLEAR
  719. #define CORE_PIN10_PORTCLEAR GPIO7_DR_CLEAR
  720. #define CORE_PIN11_PORTCLEAR GPIO7_DR_CLEAR
  721. #define CORE_PIN12_PORTCLEAR GPIO7_DR_CLEAR
  722. #define CORE_PIN13_PORTCLEAR GPIO7_DR_CLEAR
  723. #define CORE_PIN14_PORTCLEAR GPIO6_DR_CLEAR
  724. #define CORE_PIN15_PORTCLEAR GPIO6_DR_CLEAR
  725. #define CORE_PIN16_PORTCLEAR GPIO6_DR_CLEAR
  726. #define CORE_PIN17_PORTCLEAR GPIO6_DR_CLEAR
  727. #define CORE_PIN18_PORTCLEAR GPIO6_DR_CLEAR
  728. #define CORE_PIN19_PORTCLEAR GPIO6_DR_CLEAR
  729. #define CORE_PIN20_PORTCLEAR GPIO6_DR_CLEAR
  730. #define CORE_PIN21_PORTCLEAR GPIO6_DR_CLEAR
  731. #define CORE_PIN22_PORTCLEAR GPIO6_DR_CLEAR
  732. #define CORE_PIN23_PORTCLEAR GPIO6_DR_CLEAR
  733. #define CORE_PIN24_PORTCLEAR GPIO6_DR_CLEAR
  734. #define CORE_PIN25_PORTCLEAR GPIO6_DR_CLEAR
  735. #define CORE_PIN26_PORTCLEAR GPIO6_DR_CLEAR
  736. #define CORE_PIN27_PORTCLEAR GPIO6_DR_CLEAR
  737. #define CORE_PIN28_PORTCLEAR GPIO8_DR_CLEAR
  738. #define CORE_PIN29_PORTCLEAR GPIO9_DR_CLEAR
  739. #define CORE_PIN30_PORTCLEAR GPIO8_DR_CLEAR
  740. #define CORE_PIN31_PORTCLEAR GPIO8_DR_CLEAR
  741. #define CORE_PIN32_PORTCLEAR GPIO7_DR_CLEAR
  742. #define CORE_PIN33_PORTCLEAR GPIO9_DR_CLEAR
  743. #define CORE_PIN34_PORTCLEAR GPIO7_DR_CLEAR
  744. #define CORE_PIN35_PORTCLEAR GPIO7_DR_CLEAR
  745. #define CORE_PIN36_PORTCLEAR GPIO7_DR_CLEAR
  746. #define CORE_PIN37_PORTCLEAR GPIO7_DR_CLEAR
  747. #define CORE_PIN38_PORTCLEAR GPIO6_DR_CLEAR
  748. #define CORE_PIN39_PORTCLEAR GPIO6_DR_CLEAR
  749. #define CORE_PIN40_PORTCLEAR GPIO6_DR_CLEAR
  750. #define CORE_PIN41_PORTCLEAR GPIO6_DR_CLEAR
  751. #define CORE_PIN42_PORTCLEAR GPIO8_DR_CLEAR
  752. #define CORE_PIN43_PORTCLEAR GPIO8_DR_CLEAR
  753. #define CORE_PIN44_PORTCLEAR GPIO8_DR_CLEAR
  754. #define CORE_PIN45_PORTCLEAR GPIO8_DR_CLEAR
  755. #define CORE_PIN46_PORTCLEAR GPIO8_DR_CLEAR
  756. #define CORE_PIN47_PORTCLEAR GPIO8_DR_CLEAR
  757. #define CORE_PIN48_PORTCLEAR GPIO9_DR_CLEAR
  758. #define CORE_PIN49_PORTCLEAR GPIO9_DR_CLEAR
  759. #define CORE_PIN50_PORTCLEAR GPIO9_DR_CLEAR
  760. #define CORE_PIN51_PORTCLEAR GPIO9_DR_CLEAR
  761. #define CORE_PIN52_PORTCLEAR GPIO9_DR_CLEAR
  762. #define CORE_PIN53_PORTCLEAR GPIO9_DR_CLEAR
  763. #define CORE_PIN54_PORTCLEAR GPIO9_DR_CLEAR
  764. #define CORE_PIN0_DDRREG GPIO6_GDIR
  765. #define CORE_PIN1_DDRREG GPIO6_GDIR
  766. #define CORE_PIN2_DDRREG GPIO9_GDIR
  767. #define CORE_PIN3_DDRREG GPIO9_GDIR
  768. #define CORE_PIN4_DDRREG GPIO9_GDIR
  769. #define CORE_PIN5_DDRREG GPIO9_GDIR
  770. #define CORE_PIN6_DDRREG GPIO7_GDIR
  771. #define CORE_PIN7_DDRREG GPIO7_GDIR
  772. #define CORE_PIN8_DDRREG GPIO7_GDIR
  773. #define CORE_PIN9_DDRREG GPIO7_GDIR
  774. #define CORE_PIN10_DDRREG GPIO7_GDIR
  775. #define CORE_PIN11_DDRREG GPIO7_GDIR
  776. #define CORE_PIN12_DDRREG GPIO7_GDIR
  777. #define CORE_PIN13_DDRREG GPIO7_GDIR
  778. #define CORE_PIN14_DDRREG GPIO6_GDIR
  779. #define CORE_PIN15_DDRREG GPIO6_GDIR
  780. #define CORE_PIN16_DDRREG GPIO6_GDIR
  781. #define CORE_PIN17_DDRREG GPIO6_GDIR
  782. #define CORE_PIN18_DDRREG GPIO6_GDIR
  783. #define CORE_PIN19_DDRREG GPIO6_GDIR
  784. #define CORE_PIN20_DDRREG GPIO6_GDIR
  785. #define CORE_PIN21_DDRREG GPIO6_GDIR
  786. #define CORE_PIN22_DDRREG GPIO6_GDIR
  787. #define CORE_PIN23_DDRREG GPIO6_GDIR
  788. #define CORE_PIN24_DDRREG GPIO6_GDIR
  789. #define CORE_PIN25_DDRREG GPIO6_GDIR
  790. #define CORE_PIN26_DDRREG GPIO6_GDIR
  791. #define CORE_PIN27_DDRREG GPIO6_GDIR
  792. #define CORE_PIN28_DDRREG GPIO8_GDIR
  793. #define CORE_PIN29_DDRREG GPIO9_GDIR
  794. #define CORE_PIN30_DDRREG GPIO8_GDIR
  795. #define CORE_PIN31_DDRREG GPIO8_GDIR
  796. #define CORE_PIN32_DDRREG GPIO7_GDIR
  797. #define CORE_PIN33_DDRREG GPIO9_GDIR
  798. #define CORE_PIN34_DDRREG GPIO7_GDIR
  799. #define CORE_PIN35_DDRREG GPIO7_GDIR
  800. #define CORE_PIN36_DDRREG GPIO7_GDIR
  801. #define CORE_PIN37_DDRREG GPIO7_GDIR
  802. #define CORE_PIN38_DDRREG GPIO6_GDIR
  803. #define CORE_PIN39_DDRREG GPIO6_GDIR
  804. #define CORE_PIN40_DDRREG GPIO6_GDIR
  805. #define CORE_PIN41_DDRREG GPIO6_GDIR
  806. #define CORE_PIN42_DDRREG GPIO8_GDIR
  807. #define CORE_PIN43_DDRREG GPIO8_GDIR
  808. #define CORE_PIN44_DDRREG GPIO8_GDIR
  809. #define CORE_PIN45_DDRREG GPIO8_GDIR
  810. #define CORE_PIN46_DDRREG GPIO8_GDIR
  811. #define CORE_PIN47_DDRREG GPIO8_GDIR
  812. #define CORE_PIN48_DDRREG GPIO9_GDIR
  813. #define CORE_PIN49_DDRREG GPIO9_GDIR
  814. #define CORE_PIN50_DDRREG GPIO9_GDIR
  815. #define CORE_PIN51_DDRREG GPIO9_GDIR
  816. #define CORE_PIN52_DDRREG GPIO9_GDIR
  817. #define CORE_PIN53_DDRREG GPIO9_GDIR
  818. #define CORE_PIN54_DDRREG GPIO9_GDIR
  819. #define CORE_PIN0_PINREG GPIO6_PSR
  820. #define CORE_PIN1_PINREG GPIO6_PSR
  821. #define CORE_PIN2_PINREG GPIO9_PSR
  822. #define CORE_PIN3_PINREG GPIO9_PSR
  823. #define CORE_PIN4_PINREG GPIO9_PSR
  824. #define CORE_PIN5_PINREG GPIO9_PSR
  825. #define CORE_PIN6_PINREG GPIO7_PSR
  826. #define CORE_PIN7_PINREG GPIO7_PSR
  827. #define CORE_PIN8_PINREG GPIO7_PSR
  828. #define CORE_PIN9_PINREG GPIO7_PSR
  829. #define CORE_PIN10_PINREG GPIO7_PSR
  830. #define CORE_PIN11_PINREG GPIO7_PSR
  831. #define CORE_PIN12_PINREG GPIO7_PSR
  832. #define CORE_PIN13_PINREG GPIO7_PSR
  833. #define CORE_PIN14_PINREG GPIO6_PSR
  834. #define CORE_PIN15_PINREG GPIO6_PSR
  835. #define CORE_PIN16_PINREG GPIO6_PSR
  836. #define CORE_PIN17_PINREG GPIO6_PSR
  837. #define CORE_PIN18_PINREG GPIO6_PSR
  838. #define CORE_PIN19_PINREG GPIO6_PSR
  839. #define CORE_PIN20_PINREG GPIO6_PSR
  840. #define CORE_PIN21_PINREG GPIO6_PSR
  841. #define CORE_PIN22_PINREG GPIO6_PSR
  842. #define CORE_PIN23_PINREG GPIO6_PSR
  843. #define CORE_PIN24_PINREG GPIO6_PSR
  844. #define CORE_PIN25_PINREG GPIO6_PSR
  845. #define CORE_PIN26_PINREG GPIO6_PSR
  846. #define CORE_PIN27_PINREG GPIO6_PSR
  847. #define CORE_PIN28_PINREG GPIO8_PSR
  848. #define CORE_PIN29_PINREG GPIO9_PSR
  849. #define CORE_PIN30_PINREG GPIO8_PSR
  850. #define CORE_PIN31_PINREG GPIO8_PSR
  851. #define CORE_PIN32_PINREG GPIO7_PSR
  852. #define CORE_PIN33_PINREG GPIO9_PSR
  853. #define CORE_PIN34_PINREG GPIO7_PSR
  854. #define CORE_PIN35_PINREG GPIO7_PSR
  855. #define CORE_PIN36_PINREG GPIO7_PSR
  856. #define CORE_PIN37_PINREG GPIO7_PSR
  857. #define CORE_PIN38_PINREG GPIO6_PSR
  858. #define CORE_PIN39_PINREG GPIO6_PSR
  859. #define CORE_PIN40_PINREG GPIO6_PSR
  860. #define CORE_PIN41_PINREG GPIO6_PSR
  861. #define CORE_PIN42_PINREG GPIO8_PSR
  862. #define CORE_PIN43_PINREG GPIO8_PSR
  863. #define CORE_PIN44_PINREG GPIO8_PSR
  864. #define CORE_PIN45_PINREG GPIO8_PSR
  865. #define CORE_PIN46_PINREG GPIO8_PSR
  866. #define CORE_PIN47_PINREG GPIO8_PSR
  867. #define CORE_PIN48_PINREG GPIO9_PSR
  868. #define CORE_PIN49_PINREG GPIO9_PSR
  869. #define CORE_PIN50_PINREG GPIO9_PSR
  870. #define CORE_PIN51_PINREG GPIO9_PSR
  871. #define CORE_PIN52_PINREG GPIO9_PSR
  872. #define CORE_PIN53_PINREG GPIO9_PSR
  873. #define CORE_PIN54_PINREG GPIO9_PSR
  874. // mux config registers control which peripheral uses the pin
  875. #define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
  876. #define CORE_PIN1_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02
  877. #define CORE_PIN2_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04
  878. #define CORE_PIN3_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_05
  879. #define CORE_PIN4_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_06
  880. #define CORE_PIN5_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_08
  881. #define CORE_PIN6_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_10
  882. #define CORE_PIN7_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01
  883. #define CORE_PIN8_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00
  884. #define CORE_PIN9_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11
  885. #define CORE_PIN10_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_00
  886. #define CORE_PIN11_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_02
  887. #define CORE_PIN12_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_01
  888. #define CORE_PIN13_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03
  889. #define CORE_PIN14_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02
  890. #define CORE_PIN15_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03
  891. #define CORE_PIN16_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07
  892. #define CORE_PIN17_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06
  893. #define CORE_PIN18_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_01
  894. #define CORE_PIN19_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00
  895. #define CORE_PIN20_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10
  896. #define CORE_PIN21_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11
  897. #define CORE_PIN22_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_08
  898. #define CORE_PIN23_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_09
  899. #define CORE_PIN24_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12
  900. #define CORE_PIN25_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13
  901. #define CORE_PIN26_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_14
  902. #define CORE_PIN27_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_15
  903. #define CORE_PIN28_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32
  904. #define CORE_PIN29_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31
  905. #define CORE_PIN30_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_37
  906. #define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_36
  907. #define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
  908. #define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
  909. #define CORE_PIN34_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_13
  910. #define CORE_PIN35_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_12
  911. #define CORE_PIN36_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_02
  912. #define CORE_PIN37_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_03
  913. #define CORE_PIN38_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_12
  914. #define CORE_PIN39_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_13
  915. #define CORE_PIN40_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_04
  916. #define CORE_PIN41_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_05
  917. #define CORE_PIN42_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_03
  918. #define CORE_PIN43_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_02
  919. #define CORE_PIN44_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_01
  920. #define CORE_PIN45_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_00
  921. #define CORE_PIN46_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_05
  922. #define CORE_PIN47_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_04
  923. #define CORE_PIN48_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_24
  924. #define CORE_PIN49_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_27
  925. #define CORE_PIN50_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_28
  926. #define CORE_PIN51_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_22
  927. #define CORE_PIN52_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_26
  928. #define CORE_PIN53_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_25
  929. #define CORE_PIN54_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_29
  930. // pad config registers control pullup/pulldown/keeper, drive strength, etc
  931. #define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
  932. #define CORE_PIN1_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_02
  933. #define CORE_PIN2_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04
  934. #define CORE_PIN3_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_05
  935. #define CORE_PIN4_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_06
  936. #define CORE_PIN5_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_08
  937. #define CORE_PIN6_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
  938. #define CORE_PIN7_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01
  939. #define CORE_PIN8_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_00
  940. #define CORE_PIN9_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_11
  941. #define CORE_PIN10_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_00
  942. #define CORE_PIN11_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_02
  943. #define CORE_PIN12_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_01
  944. #define CORE_PIN13_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03
  945. #define CORE_PIN14_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02
  946. #define CORE_PIN15_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_03
  947. #define CORE_PIN16_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_07
  948. #define CORE_PIN17_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_06
  949. #define CORE_PIN18_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01
  950. #define CORE_PIN19_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00
  951. #define CORE_PIN20_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_10
  952. #define CORE_PIN21_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11
  953. #define CORE_PIN22_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_08
  954. #define CORE_PIN23_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_09
  955. #define CORE_PIN24_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_12
  956. #define CORE_PIN25_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_13
  957. #define CORE_PIN26_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_14
  958. #define CORE_PIN27_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_15
  959. #define CORE_PIN28_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_32
  960. #define CORE_PIN29_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_31
  961. #define CORE_PIN30_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_37
  962. #define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_36
  963. #define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
  964. #define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
  965. #define CORE_PIN34_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_13
  966. #define CORE_PIN35_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_12
  967. #define CORE_PIN36_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_02
  968. #define CORE_PIN37_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_03
  969. #define CORE_PIN38_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_12
  970. #define CORE_PIN39_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_13
  971. #define CORE_PIN40_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_04
  972. #define CORE_PIN41_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_05
  973. #define CORE_PIN42_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_03
  974. #define CORE_PIN43_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_02
  975. #define CORE_PIN44_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_01
  976. #define CORE_PIN45_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_00
  977. #define CORE_PIN46_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_05
  978. #define CORE_PIN47_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_04
  979. #define CORE_PIN48_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_24
  980. #define CORE_PIN49_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_27
  981. #define CORE_PIN50_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_28
  982. #define CORE_PIN51_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_22
  983. #define CORE_PIN52_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_26
  984. #define CORE_PIN53_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_25
  985. #define CORE_PIN54_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_29
  986. #define CORE_LED0_PIN 13
  987. #define CORE_ADC0_PIN 14
  988. #define CORE_ADC1_PIN 15
  989. #define CORE_ADC2_PIN 16
  990. #define CORE_ADC3_PIN 17
  991. #define CORE_ADC4_PIN 18
  992. #define CORE_ADC5_PIN 19
  993. #define CORE_ADC6_PIN 20
  994. #define CORE_ADC7_PIN 21
  995. #define CORE_ADC8_PIN 22
  996. #define CORE_ADC9_PIN 23
  997. #define CORE_RXD0_PIN 0
  998. #define CORE_TXD0_PIN 1
  999. #define CORE_RXD1_PIN 7
  1000. #define CORE_TXD1_PIN 8
  1001. #define CORE_RXD2_PIN 15
  1002. #define CORE_TXD2_PIN 14
  1003. #define CORE_RXD3_PIN 16
  1004. #define CORE_TXD3_PIN 17
  1005. #define CORE_RXD4_PIN 21
  1006. #define CORE_TXD4_PIN 20
  1007. #define CORE_RXD5_PIN 25
  1008. #define CORE_TXD5_PIN 24
  1009. #define CORE_RXD6_PIN 28
  1010. #define CORE_TXD6_PIN 29
  1011. #define CORE_RXD7_PIN 34
  1012. #define CORE_TXD7_PIN 35
  1013. #define CORE_INT0_PIN 0
  1014. #define CORE_INT1_PIN 1
  1015. #define CORE_INT2_PIN 2
  1016. #define CORE_INT3_PIN 3
  1017. #define CORE_INT4_PIN 4
  1018. #define CORE_INT5_PIN 5
  1019. #define CORE_INT6_PIN 6
  1020. #define CORE_INT7_PIN 7
  1021. #define CORE_INT8_PIN 8
  1022. #define CORE_INT9_PIN 9
  1023. #define CORE_INT10_PIN 10
  1024. #define CORE_INT11_PIN 11
  1025. #define CORE_INT12_PIN 12
  1026. #define CORE_INT13_PIN 13
  1027. #define CORE_INT14_PIN 14
  1028. #define CORE_INT15_PIN 15
  1029. #define CORE_INT16_PIN 16
  1030. #define CORE_INT17_PIN 17
  1031. #define CORE_INT18_PIN 18
  1032. #define CORE_INT19_PIN 19
  1033. #define CORE_INT20_PIN 20
  1034. #define CORE_INT21_PIN 21
  1035. #define CORE_INT22_PIN 22
  1036. #define CORE_INT23_PIN 23
  1037. #define CORE_INT24_PIN 24
  1038. #define CORE_INT25_PIN 25
  1039. #define CORE_INT26_PIN 26
  1040. #define CORE_INT27_PIN 27
  1041. #define CORE_INT28_PIN 28
  1042. #define CORE_INT29_PIN 29
  1043. #define CORE_INT30_PIN 30
  1044. #define CORE_INT31_PIN 31
  1045. #define CORE_INT32_PIN 32
  1046. #define CORE_INT33_PIN 33
  1047. #define CORE_INT34_PIN 34
  1048. #define CORE_INT35_PIN 35
  1049. #define CORE_INT36_PIN 36
  1050. #define CORE_INT37_PIN 37
  1051. #define CORE_INT38_PIN 38
  1052. #define CORE_INT39_PIN 39
  1053. #define CORE_INT40_PIN 40
  1054. #define CORE_INT41_PIN 41
  1055. #define CORE_INT42_PIN 42
  1056. #define CORE_INT43_PIN 43
  1057. #define CORE_INT44_PIN 44
  1058. #define CORE_INT45_PIN 45
  1059. #define CORE_INT46_PIN 46
  1060. #define CORE_INT47_PIN 47
  1061. #define CORE_INT48_PIN 48
  1062. #define CORE_INT49_PIN 49
  1063. #define CORE_INT50_PIN 50
  1064. #define CORE_INT51_PIN 51
  1065. #define CORE_INT52_PIN 52
  1066. #define CORE_INT53_PIN 53
  1067. #define CORE_INT54_PIN 54
  1068. #define CORE_INT_EVERY_PIN 1
  1069. #endif // __IMXRT1062__
  1070. #ifdef __cplusplus
  1071. extern "C" {
  1072. #endif
  1073. //TODO:
  1074. //#define analogInputToDigitalPin(p)
  1075. //#define digitalPinHasPWM(p)
  1076. #define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
  1077. void digitalWrite(uint8_t pin, uint8_t val);
  1078. static inline void digitalWriteFast(uint8_t pin, uint8_t val) __attribute__((always_inline, unused));
  1079. static inline void digitalWriteFast(uint8_t pin, uint8_t val)
  1080. {
  1081. if (__builtin_constant_p(pin)) {
  1082. if (val) {
  1083. if (pin == 0) {
  1084. CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
  1085. } else if (pin == 1) {
  1086. CORE_PIN1_PORTSET = CORE_PIN1_BITMASK;
  1087. } else if (pin == 2) {
  1088. CORE_PIN2_PORTSET = CORE_PIN2_BITMASK;
  1089. } else if (pin == 3) {
  1090. CORE_PIN3_PORTSET = CORE_PIN3_BITMASK;
  1091. } else if (pin == 4) {
  1092. CORE_PIN4_PORTSET = CORE_PIN4_BITMASK;
  1093. } else if (pin == 5) {
  1094. CORE_PIN5_PORTSET = CORE_PIN5_BITMASK;
  1095. } else if (pin == 6) {
  1096. CORE_PIN6_PORTSET = CORE_PIN6_BITMASK;
  1097. } else if (pin == 7) {
  1098. CORE_PIN7_PORTSET = CORE_PIN7_BITMASK;
  1099. } else if (pin == 8) {
  1100. CORE_PIN8_PORTSET = CORE_PIN8_BITMASK;
  1101. } else if (pin == 9) {
  1102. CORE_PIN9_PORTSET = CORE_PIN9_BITMASK;
  1103. } else if (pin == 10) {
  1104. CORE_PIN10_PORTSET = CORE_PIN10_BITMASK;
  1105. } else if (pin == 11) {
  1106. CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
  1107. } else if (pin == 12) {
  1108. CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
  1109. } else if (pin == 13) {
  1110. CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
  1111. } else if (pin == 14) {
  1112. CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
  1113. } else if (pin == 15) {
  1114. CORE_PIN15_PORTSET = CORE_PIN15_BITMASK;
  1115. } else if (pin == 16) {
  1116. CORE_PIN16_PORTSET = CORE_PIN16_BITMASK;
  1117. } else if (pin == 17) {
  1118. CORE_PIN17_PORTSET = CORE_PIN17_BITMASK;
  1119. } else if (pin == 18) {
  1120. CORE_PIN18_PORTSET = CORE_PIN18_BITMASK;
  1121. } else if (pin == 19) {
  1122. CORE_PIN19_PORTSET = CORE_PIN19_BITMASK;
  1123. } else if (pin == 20) {
  1124. CORE_PIN20_PORTSET = CORE_PIN20_BITMASK;
  1125. } else if (pin == 21) {
  1126. CORE_PIN21_PORTSET = CORE_PIN21_BITMASK;
  1127. } else if (pin == 22) {
  1128. CORE_PIN22_PORTSET = CORE_PIN22_BITMASK;
  1129. } else if (pin == 23) {
  1130. CORE_PIN23_PORTSET = CORE_PIN23_BITMASK;
  1131. } else if (pin == 24) {
  1132. CORE_PIN24_PORTSET = CORE_PIN24_BITMASK;
  1133. } else if (pin == 25) {
  1134. CORE_PIN25_PORTSET = CORE_PIN25_BITMASK;
  1135. } else if (pin == 26) {
  1136. CORE_PIN26_PORTSET = CORE_PIN26_BITMASK;
  1137. } else if (pin == 27) {
  1138. CORE_PIN27_PORTSET = CORE_PIN27_BITMASK;
  1139. } else if (pin == 28) {
  1140. CORE_PIN28_PORTSET = CORE_PIN28_BITMASK;
  1141. } else if (pin == 29) {
  1142. CORE_PIN29_PORTSET = CORE_PIN29_BITMASK;
  1143. } else if (pin == 30) {
  1144. CORE_PIN30_PORTSET = CORE_PIN30_BITMASK;
  1145. } else if (pin == 31) {
  1146. CORE_PIN31_PORTSET = CORE_PIN31_BITMASK;
  1147. } else if (pin == 32) {
  1148. CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
  1149. } else if (pin == 33) {
  1150. CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
  1151. } else if (pin == 34) {
  1152. CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
  1153. } else if (pin == 35) {
  1154. CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
  1155. } else if (pin == 36) {
  1156. CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
  1157. } else if (pin == 37) {
  1158. CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
  1159. } else if (pin == 38) {
  1160. CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
  1161. } else if (pin == 39) {
  1162. CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
  1163. #if CORE_NUM_DIGITAL >= 55
  1164. } else if (pin == 40) {
  1165. CORE_PIN40_PORTSET = CORE_PIN40_BITMASK;
  1166. } else if (pin == 41) {
  1167. CORE_PIN41_PORTSET = CORE_PIN41_BITMASK;
  1168. } else if (pin == 42) {
  1169. CORE_PIN42_PORTSET = CORE_PIN42_BITMASK;
  1170. } else if (pin == 43) {
  1171. CORE_PIN43_PORTSET = CORE_PIN43_BITMASK;
  1172. } else if (pin == 44) {
  1173. CORE_PIN44_PORTSET = CORE_PIN44_BITMASK;
  1174. } else if (pin == 45) {
  1175. CORE_PIN45_PORTSET = CORE_PIN45_BITMASK;
  1176. } else if (pin == 46) {
  1177. CORE_PIN46_PORTSET = CORE_PIN46_BITMASK;
  1178. } else if (pin == 47) {
  1179. CORE_PIN47_PORTSET = CORE_PIN47_BITMASK;
  1180. } else if (pin == 48) {
  1181. CORE_PIN48_PORTSET = CORE_PIN48_BITMASK;
  1182. } else if (pin == 49) {
  1183. CORE_PIN49_PORTSET = CORE_PIN49_BITMASK;
  1184. } else if (pin == 50) {
  1185. CORE_PIN50_PORTSET = CORE_PIN50_BITMASK;
  1186. } else if (pin == 51) {
  1187. CORE_PIN51_PORTSET = CORE_PIN51_BITMASK;
  1188. } else if (pin == 52) {
  1189. CORE_PIN52_PORTSET = CORE_PIN52_BITMASK;
  1190. } else if (pin == 53) {
  1191. CORE_PIN53_PORTSET = CORE_PIN53_BITMASK;
  1192. } else if (pin == 54) {
  1193. CORE_PIN54_PORTSET = CORE_PIN54_BITMASK;
  1194. #endif
  1195. }
  1196. } else {
  1197. if (pin == 0) {
  1198. CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;
  1199. } else if (pin == 1) {
  1200. CORE_PIN1_PORTCLEAR = CORE_PIN1_BITMASK;
  1201. } else if (pin == 2) {
  1202. CORE_PIN2_PORTCLEAR = CORE_PIN2_BITMASK;
  1203. } else if (pin == 3) {
  1204. CORE_PIN3_PORTCLEAR = CORE_PIN3_BITMASK;
  1205. } else if (pin == 4) {
  1206. CORE_PIN4_PORTCLEAR = CORE_PIN4_BITMASK;
  1207. } else if (pin == 5) {
  1208. CORE_PIN5_PORTCLEAR = CORE_PIN5_BITMASK;
  1209. } else if (pin == 6) {
  1210. CORE_PIN6_PORTCLEAR = CORE_PIN6_BITMASK;
  1211. } else if (pin == 7) {
  1212. CORE_PIN7_PORTCLEAR = CORE_PIN7_BITMASK;
  1213. } else if (pin == 8) {
  1214. CORE_PIN8_PORTCLEAR = CORE_PIN8_BITMASK;
  1215. } else if (pin == 9) {
  1216. CORE_PIN9_PORTCLEAR = CORE_PIN9_BITMASK;
  1217. } else if (pin == 10) {
  1218. CORE_PIN10_PORTCLEAR = CORE_PIN10_BITMASK;
  1219. } else if (pin == 11) {
  1220. CORE_PIN11_PORTCLEAR = CORE_PIN11_BITMASK;
  1221. } else if (pin == 12) {
  1222. CORE_PIN12_PORTCLEAR = CORE_PIN12_BITMASK;
  1223. } else if (pin == 13) {
  1224. CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
  1225. } else if (pin == 14) {
  1226. CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
  1227. } else if (pin == 15) {
  1228. CORE_PIN15_PORTCLEAR = CORE_PIN15_BITMASK;
  1229. } else if (pin == 16) {
  1230. CORE_PIN16_PORTCLEAR = CORE_PIN16_BITMASK;
  1231. } else if (pin == 17) {
  1232. CORE_PIN17_PORTCLEAR = CORE_PIN17_BITMASK;
  1233. } else if (pin == 18) {
  1234. CORE_PIN18_PORTCLEAR = CORE_PIN18_BITMASK;
  1235. } else if (pin == 19) {
  1236. CORE_PIN19_PORTCLEAR = CORE_PIN19_BITMASK;
  1237. } else if (pin == 20) {
  1238. CORE_PIN20_PORTCLEAR = CORE_PIN20_BITMASK;
  1239. } else if (pin == 21) {
  1240. CORE_PIN21_PORTCLEAR = CORE_PIN21_BITMASK;
  1241. } else if (pin == 22) {
  1242. CORE_PIN22_PORTCLEAR = CORE_PIN22_BITMASK;
  1243. } else if (pin == 23) {
  1244. CORE_PIN23_PORTCLEAR = CORE_PIN23_BITMASK;
  1245. } else if (pin == 24) {
  1246. CORE_PIN24_PORTCLEAR = CORE_PIN24_BITMASK;
  1247. } else if (pin == 25) {
  1248. CORE_PIN25_PORTCLEAR = CORE_PIN25_BITMASK;
  1249. } else if (pin == 26) {
  1250. CORE_PIN26_PORTCLEAR = CORE_PIN26_BITMASK;
  1251. } else if (pin == 27) {
  1252. CORE_PIN27_PORTCLEAR = CORE_PIN27_BITMASK;
  1253. } else if (pin == 28) {
  1254. CORE_PIN28_PORTCLEAR = CORE_PIN28_BITMASK;
  1255. } else if (pin == 29) {
  1256. CORE_PIN29_PORTCLEAR = CORE_PIN29_BITMASK;
  1257. } else if (pin == 30) {
  1258. CORE_PIN30_PORTCLEAR = CORE_PIN30_BITMASK;
  1259. } else if (pin == 31) {
  1260. CORE_PIN31_PORTCLEAR = CORE_PIN31_BITMASK;
  1261. } else if (pin == 32) {
  1262. CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
  1263. } else if (pin == 33) {
  1264. CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
  1265. } else if (pin == 34) {
  1266. CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
  1267. } else if (pin == 35) {
  1268. CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
  1269. } else if (pin == 36) {
  1270. CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
  1271. } else if (pin == 37) {
  1272. CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
  1273. } else if (pin == 38) {
  1274. CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
  1275. } else if (pin == 39) {
  1276. CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
  1277. #if CORE_NUM_DIGITAL >= 55
  1278. } else if (pin == 40) {
  1279. CORE_PIN40_PORTCLEAR = CORE_PIN40_BITMASK;
  1280. } else if (pin == 41) {
  1281. CORE_PIN41_PORTCLEAR = CORE_PIN41_BITMASK;
  1282. } else if (pin == 42) {
  1283. CORE_PIN42_PORTCLEAR = CORE_PIN42_BITMASK;
  1284. } else if (pin == 43) {
  1285. CORE_PIN43_PORTCLEAR = CORE_PIN43_BITMASK;
  1286. } else if (pin == 44) {
  1287. CORE_PIN44_PORTCLEAR = CORE_PIN44_BITMASK;
  1288. } else if (pin == 45) {
  1289. CORE_PIN45_PORTCLEAR = CORE_PIN45_BITMASK;
  1290. } else if (pin == 46) {
  1291. CORE_PIN46_PORTCLEAR = CORE_PIN46_BITMASK;
  1292. } else if (pin == 47) {
  1293. CORE_PIN47_PORTCLEAR = CORE_PIN47_BITMASK;
  1294. } else if (pin == 48) {
  1295. CORE_PIN48_PORTCLEAR = CORE_PIN48_BITMASK;
  1296. } else if (pin == 49) {
  1297. CORE_PIN49_PORTCLEAR = CORE_PIN49_BITMASK;
  1298. } else if (pin == 50) {
  1299. CORE_PIN50_PORTCLEAR = CORE_PIN50_BITMASK;
  1300. } else if (pin == 51) {
  1301. CORE_PIN51_PORTCLEAR = CORE_PIN51_BITMASK;
  1302. } else if (pin == 52) {
  1303. CORE_PIN52_PORTCLEAR = CORE_PIN52_BITMASK;
  1304. } else if (pin == 53) {
  1305. CORE_PIN53_PORTCLEAR = CORE_PIN53_BITMASK;
  1306. } else if (pin == 54) {
  1307. CORE_PIN54_PORTCLEAR = CORE_PIN54_BITMASK;
  1308. #endif
  1309. }
  1310. }
  1311. } else {
  1312. if(val) *portSetRegister(pin) = digitalPinToBitMask(pin);
  1313. else *portClearRegister(pin) = digitalPinToBitMask(pin);
  1314. }
  1315. }
  1316. uint8_t digitalRead(uint8_t pin);
  1317. static inline uint8_t digitalReadFast(uint8_t pin) __attribute__((always_inline, unused));
  1318. static inline uint8_t digitalReadFast(uint8_t pin)
  1319. {
  1320. if (__builtin_constant_p(pin)) {
  1321. if (pin == 0) {
  1322. return (CORE_PIN0_PINREG & CORE_PIN0_BITMASK) ? 1 : 0;
  1323. } else if (pin == 1) {
  1324. return (CORE_PIN1_PINREG & CORE_PIN1_BITMASK) ? 1 : 0;
  1325. } else if (pin == 2) {
  1326. return (CORE_PIN2_PINREG & CORE_PIN2_BITMASK) ? 1 : 0;
  1327. } else if (pin == 3) {
  1328. return (CORE_PIN3_PINREG & CORE_PIN3_BITMASK) ? 1 : 0;
  1329. } else if (pin == 4) {
  1330. return (CORE_PIN4_PINREG & CORE_PIN4_BITMASK) ? 1 : 0;
  1331. } else if (pin == 5) {
  1332. return (CORE_PIN5_PINREG & CORE_PIN5_BITMASK) ? 1 : 0;
  1333. } else if (pin == 6) {
  1334. return (CORE_PIN6_PINREG & CORE_PIN6_BITMASK) ? 1 : 0;
  1335. } else if (pin == 7) {
  1336. return (CORE_PIN7_PINREG & CORE_PIN7_BITMASK) ? 1 : 0;
  1337. } else if (pin == 8) {
  1338. return (CORE_PIN8_PINREG & CORE_PIN8_BITMASK) ? 1 : 0;
  1339. } else if (pin == 9) {
  1340. return (CORE_PIN9_PINREG & CORE_PIN9_BITMASK) ? 1 : 0;
  1341. } else if (pin == 10) {
  1342. return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
  1343. } else if (pin == 11) {
  1344. return (CORE_PIN11_PINREG & CORE_PIN11_BITMASK) ? 1 : 0;
  1345. } else if (pin == 12) {
  1346. return (CORE_PIN12_PINREG & CORE_PIN12_BITMASK) ? 1 : 0;
  1347. } else if (pin == 13) {
  1348. return (CORE_PIN13_PINREG & CORE_PIN13_BITMASK) ? 1 : 0;
  1349. } else if (pin == 14) {
  1350. return (CORE_PIN14_PINREG & CORE_PIN14_BITMASK) ? 1 : 0;
  1351. } else if (pin == 15) {
  1352. return (CORE_PIN15_PINREG & CORE_PIN15_BITMASK) ? 1 : 0;
  1353. } else if (pin == 16) {
  1354. return (CORE_PIN16_PINREG & CORE_PIN16_BITMASK) ? 1 : 0;
  1355. } else if (pin == 17) {
  1356. return (CORE_PIN17_PINREG & CORE_PIN17_BITMASK) ? 1 : 0;
  1357. } else if (pin == 18) {
  1358. return (CORE_PIN18_PINREG & CORE_PIN18_BITMASK) ? 1 : 0;
  1359. } else if (pin == 19) {
  1360. return (CORE_PIN19_PINREG & CORE_PIN19_BITMASK) ? 1 : 0;
  1361. } else if (pin == 20) {
  1362. return (CORE_PIN20_PINREG & CORE_PIN20_BITMASK) ? 1 : 0;
  1363. } else if (pin == 21) {
  1364. return (CORE_PIN21_PINREG & CORE_PIN21_BITMASK) ? 1 : 0;
  1365. } else if (pin == 22) {
  1366. return (CORE_PIN22_PINREG & CORE_PIN22_BITMASK) ? 1 : 0;
  1367. } else if (pin == 23) {
  1368. return (CORE_PIN23_PINREG & CORE_PIN23_BITMASK) ? 1 : 0;
  1369. } else if (pin == 24) {
  1370. return (CORE_PIN24_PINREG & CORE_PIN24_BITMASK) ? 1 : 0;
  1371. } else if (pin == 25) {
  1372. return (CORE_PIN25_PINREG & CORE_PIN25_BITMASK) ? 1 : 0;
  1373. } else if (pin == 26) {
  1374. return (CORE_PIN26_PINREG & CORE_PIN26_BITMASK) ? 1 : 0;
  1375. } else if (pin == 27) {
  1376. return (CORE_PIN27_PINREG & CORE_PIN27_BITMASK) ? 1 : 0;
  1377. } else if (pin == 28) {
  1378. return (CORE_PIN28_PINREG & CORE_PIN28_BITMASK) ? 1 : 0;
  1379. } else if (pin == 29) {
  1380. return (CORE_PIN29_PINREG & CORE_PIN29_BITMASK) ? 1 : 0;
  1381. } else if (pin == 30) {
  1382. return (CORE_PIN30_PINREG & CORE_PIN30_BITMASK) ? 1 : 0;
  1383. } else if (pin == 31) {
  1384. return (CORE_PIN31_PINREG & CORE_PIN31_BITMASK) ? 1 : 0;
  1385. } else if (pin == 32) {
  1386. return (CORE_PIN32_PINREG & CORE_PIN32_BITMASK) ? 1 : 0;
  1387. } else if (pin == 33) {
  1388. return (CORE_PIN33_PINREG & CORE_PIN33_BITMASK) ? 1 : 0;
  1389. } else if (pin == 34) {
  1390. return (CORE_PIN34_PINREG & CORE_PIN34_BITMASK) ? 1 : 0;
  1391. } else if (pin == 35) {
  1392. return (CORE_PIN35_PINREG & CORE_PIN35_BITMASK) ? 1 : 0;
  1393. } else if (pin == 36) {
  1394. return (CORE_PIN36_PINREG & CORE_PIN36_BITMASK) ? 1 : 0;
  1395. } else if (pin == 37) {
  1396. return (CORE_PIN37_PINREG & CORE_PIN37_BITMASK) ? 1 : 0;
  1397. } else if (pin == 38) {
  1398. return (CORE_PIN38_PINREG & CORE_PIN38_BITMASK) ? 1 : 0;
  1399. } else if (pin == 39) {
  1400. return (CORE_PIN39_PINREG & CORE_PIN39_BITMASK) ? 1 : 0;
  1401. #if CORE_NUM_DIGITAL >= 55
  1402. } else if (pin == 40) {
  1403. return (CORE_PIN40_PINREG & CORE_PIN40_BITMASK) ? 1 : 0;
  1404. } else if (pin == 41) {
  1405. return (CORE_PIN41_PINREG & CORE_PIN41_BITMASK) ? 1 : 0;
  1406. } else if (pin == 42) {
  1407. return (CORE_PIN42_PINREG & CORE_PIN42_BITMASK) ? 1 : 0;
  1408. } else if (pin == 43) {
  1409. return (CORE_PIN43_PINREG & CORE_PIN43_BITMASK) ? 1 : 0;
  1410. } else if (pin == 44) {
  1411. return (CORE_PIN44_PINREG & CORE_PIN44_BITMASK) ? 1 : 0;
  1412. } else if (pin == 45) {
  1413. return (CORE_PIN45_PINREG & CORE_PIN45_BITMASK) ? 1 : 0;
  1414. } else if (pin == 46) {
  1415. return (CORE_PIN46_PINREG & CORE_PIN46_BITMASK) ? 1 : 0;
  1416. } else if (pin == 47) {
  1417. return (CORE_PIN47_PINREG & CORE_PIN47_BITMASK) ? 1 : 0;
  1418. } else if (pin == 48) {
  1419. return (CORE_PIN48_PINREG & CORE_PIN48_BITMASK) ? 1 : 0;
  1420. } else if (pin == 49) {
  1421. return (CORE_PIN49_PINREG & CORE_PIN49_BITMASK) ? 1 : 0;
  1422. } else if (pin == 50) {
  1423. return (CORE_PIN50_PINREG & CORE_PIN50_BITMASK) ? 1 : 0;
  1424. } else if (pin == 51) {
  1425. return (CORE_PIN51_PINREG & CORE_PIN51_BITMASK) ? 1 : 0;
  1426. } else if (pin == 52) {
  1427. return (CORE_PIN52_PINREG & CORE_PIN52_BITMASK) ? 1 : 0;
  1428. } else if (pin == 53) {
  1429. return (CORE_PIN53_PINREG & CORE_PIN53_BITMASK) ? 1 : 0;
  1430. } else if (pin == 54) {
  1431. return (CORE_PIN54_PINREG & CORE_PIN54_BITMASK) ? 1 : 0;
  1432. #endif
  1433. } else {
  1434. return 0;
  1435. }
  1436. } else {
  1437. return (*portInputRegister(pin) & digitalPinToBitMask(pin)) ? 1 : 0;
  1438. }
  1439. }
  1440. void pinMode(uint8_t pin, uint8_t mode);
  1441. void init_pins(void);
  1442. void analogWrite(uint8_t pin, int val);
  1443. uint32_t analogWriteRes(uint32_t bits);
  1444. static inline uint32_t analogWriteResolution(uint32_t bits) { return analogWriteRes(bits); }
  1445. void analogWriteFrequency(uint8_t pin, float frequency);
  1446. void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
  1447. void detachInterrupt(uint8_t pin);
  1448. void _init_Teensyduino_internal_(void);
  1449. int analogRead(uint8_t pin);
  1450. void analogReference(uint8_t type);
  1451. void analogReadRes(unsigned int bits);
  1452. static inline void analogReadResolution(unsigned int bits) { analogReadRes(bits); }
  1453. void analogReadAveraging(unsigned int num);
  1454. void analog_init(void);
  1455. int touchRead(uint8_t pin);
  1456. static inline void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1457. extern void _shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) __attribute__((noinline));
  1458. extern void shiftOut_lsbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1459. extern void shiftOut_msbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1460. static inline void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
  1461. {
  1462. if (__builtin_constant_p(bitOrder)) {
  1463. if (bitOrder == LSBFIRST) {
  1464. shiftOut_lsbFirst(dataPin, clockPin, value);
  1465. } else {
  1466. shiftOut_msbFirst(dataPin, clockPin, value);
  1467. }
  1468. } else {
  1469. _shiftOut(dataPin, clockPin, bitOrder, value);
  1470. }
  1471. }
  1472. static inline uint8_t shiftIn(uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1473. extern uint8_t _shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) __attribute__((noinline));
  1474. extern uint8_t shiftIn_lsbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1475. extern uint8_t shiftIn_msbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1476. static inline uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
  1477. {
  1478. if (__builtin_constant_p(bitOrder)) {
  1479. if (bitOrder == LSBFIRST) {
  1480. return shiftIn_lsbFirst(dataPin, clockPin);
  1481. } else {
  1482. return shiftIn_msbFirst(dataPin, clockPin);
  1483. }
  1484. } else {
  1485. return _shiftIn(dataPin, clockPin, bitOrder);
  1486. }
  1487. }
  1488. void _reboot_Teensyduino_(void) __attribute__((noreturn));
  1489. void _restart_Teensyduino_(void) __attribute__((noreturn));
  1490. void yield(void);
  1491. void delay(uint32_t msec);
  1492. extern volatile uint32_t F_CPU_ACTUAL;
  1493. extern volatile uint32_t F_BUS_ACTUAL;
  1494. extern volatile uint32_t scale_cpu_cycles_to_microseconds;
  1495. extern volatile uint32_t systick_millis_count;
  1496. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  1497. static inline uint32_t millis(void)
  1498. {
  1499. return systick_millis_count;
  1500. }
  1501. uint32_t micros(void);
  1502. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  1503. static inline void delayMicroseconds(uint32_t usec)
  1504. {
  1505. uint32_t begin = ARM_DWT_CYCCNT;
  1506. uint32_t cycles = F_CPU_ACTUAL / 1000000 * usec;
  1507. // TODO: check if cycles is large, do a wait with yield calls until it's smaller
  1508. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1509. }
  1510. static inline void delayNanoseconds(uint32_t) __attribute__((always_inline, unused));
  1511. static inline void delayNanoseconds(uint32_t nsec)
  1512. {
  1513. uint32_t begin = ARM_DWT_CYCCNT;
  1514. uint32_t cycles = ((F_CPU_ACTUAL>>16) * nsec) / (1000000000UL>>16);
  1515. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1516. }
  1517. unsigned long rtc_get(void);
  1518. void rtc_set(unsigned long t);
  1519. void rtc_compensate(int adjust);
  1520. void tempmon_init(void);
  1521. float tempmonGetTemp(void);
  1522. void tempmon_Start();
  1523. void tempmon_Stop();
  1524. void tempmon_PwrDwn();
  1525. #ifdef __cplusplus
  1526. }
  1527. class teensy3_clock_class
  1528. {
  1529. public:
  1530. static unsigned long get(void) __attribute__((always_inline)) { return rtc_get(); }
  1531. static void set(unsigned long t) __attribute__((always_inline)) { rtc_set(t); }
  1532. static void compensate(int adj) __attribute__((always_inline)) { rtc_compensate(adj); }
  1533. };
  1534. extern teensy3_clock_class Teensy3Clock;
  1535. #endif // __cplusplus