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.

1278 lines
47KB

  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__)
  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 24
  84. #define CORE_PIN31_BIT 23
  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. #define CORE_PIN0_PORTREG GPIO1_DR
  134. #define CORE_PIN1_PORTREG GPIO1_DR
  135. #define CORE_PIN2_PORTREG GPIO4_DR
  136. #define CORE_PIN3_PORTREG GPIO4_DR
  137. #define CORE_PIN4_PORTREG GPIO4_DR
  138. #define CORE_PIN5_PORTREG GPIO4_DR
  139. #define CORE_PIN6_PORTREG GPIO2_DR
  140. #define CORE_PIN7_PORTREG GPIO2_DR
  141. #define CORE_PIN8_PORTREG GPIO2_DR
  142. #define CORE_PIN9_PORTREG GPIO2_DR
  143. #define CORE_PIN10_PORTREG GPIO2_DR
  144. #define CORE_PIN11_PORTREG GPIO2_DR
  145. #define CORE_PIN12_PORTREG GPIO2_DR
  146. #define CORE_PIN13_PORTREG GPIO2_DR
  147. #define CORE_PIN14_PORTREG GPIO1_DR
  148. #define CORE_PIN15_PORTREG GPIO1_DR
  149. #define CORE_PIN16_PORTREG GPIO1_DR
  150. #define CORE_PIN17_PORTREG GPIO1_DR
  151. #define CORE_PIN18_PORTREG GPIO1_DR
  152. #define CORE_PIN19_PORTREG GPIO1_DR
  153. #define CORE_PIN20_PORTREG GPIO1_DR
  154. #define CORE_PIN21_PORTREG GPIO1_DR
  155. #define CORE_PIN22_PORTREG GPIO1_DR
  156. #define CORE_PIN23_PORTREG GPIO1_DR
  157. #define CORE_PIN24_PORTREG GPIO1_DR
  158. #define CORE_PIN25_PORTREG GPIO1_DR
  159. #define CORE_PIN26_PORTREG GPIO1_DR
  160. #define CORE_PIN27_PORTREG GPIO1_DR
  161. #define CORE_PIN28_PORTREG GPIO3_DR
  162. #define CORE_PIN29_PORTREG GPIO4_DR
  163. #define CORE_PIN30_PORTREG GPIO4_DR
  164. #define CORE_PIN31_PORTREG GPIO4_DR
  165. #define CORE_PIN32_PORTREG GPIO2_DR
  166. #define CORE_PIN33_PORTREG GPIO4_DR
  167. #define CORE_PIN34_PORTREG GPIO3_DR
  168. #define CORE_PIN35_PORTREG GPIO3_DR
  169. #define CORE_PIN36_PORTREG GPIO3_DR
  170. #define CORE_PIN37_PORTREG GPIO3_DR
  171. #define CORE_PIN38_PORTREG GPIO3_DR
  172. #define CORE_PIN39_PORTREG GPIO3_DR
  173. #define CORE_PIN0_PORTSET GPIO1_DR_SET
  174. #define CORE_PIN1_PORTSET GPIO1_DR_SET
  175. #define CORE_PIN2_PORTSET GPIO4_DR_SET
  176. #define CORE_PIN3_PORTSET GPIO4_DR_SET
  177. #define CORE_PIN4_PORTSET GPIO4_DR_SET
  178. #define CORE_PIN5_PORTSET GPIO4_DR_SET
  179. #define CORE_PIN6_PORTSET GPIO2_DR_SET
  180. #define CORE_PIN7_PORTSET GPIO2_DR_SET
  181. #define CORE_PIN8_PORTSET GPIO2_DR_SET
  182. #define CORE_PIN9_PORTSET GPIO2_DR_SET
  183. #define CORE_PIN10_PORTSET GPIO2_DR_SET
  184. #define CORE_PIN11_PORTSET GPIO2_DR_SET
  185. #define CORE_PIN12_PORTSET GPIO2_DR_SET
  186. #define CORE_PIN13_PORTSET GPIO2_DR_SET
  187. #define CORE_PIN14_PORTSET GPIO1_DR_SET
  188. #define CORE_PIN15_PORTSET GPIO1_DR_SET
  189. #define CORE_PIN16_PORTSET GPIO1_DR_SET
  190. #define CORE_PIN17_PORTSET GPIO1_DR_SET
  191. #define CORE_PIN18_PORTSET GPIO1_DR_SET
  192. #define CORE_PIN19_PORTSET GPIO1_DR_SET
  193. #define CORE_PIN20_PORTSET GPIO1_DR_SET
  194. #define CORE_PIN21_PORTSET GPIO1_DR_SET
  195. #define CORE_PIN22_PORTSET GPIO1_DR_SET
  196. #define CORE_PIN23_PORTSET GPIO1_DR_SET
  197. #define CORE_PIN24_PORTSET GPIO1_DR_SET
  198. #define CORE_PIN25_PORTSET GPIO1_DR_SET
  199. #define CORE_PIN26_PORTSET GPIO1_DR_SET
  200. #define CORE_PIN27_PORTSET GPIO1_DR_SET
  201. #define CORE_PIN28_PORTSET GPIO3_DR_SET
  202. #define CORE_PIN29_PORTSET GPIO4_DR_SET
  203. #define CORE_PIN30_PORTSET GPIO4_DR_SET
  204. #define CORE_PIN31_PORTSET GPIO4_DR_SET
  205. #define CORE_PIN32_PORTSET GPIO2_DR_SET
  206. #define CORE_PIN33_PORTSET GPIO4_DR_SET
  207. #define CORE_PIN34_PORTSET GPIO3_DR_SET
  208. #define CORE_PIN35_PORTSET GPIO3_DR_SET
  209. #define CORE_PIN36_PORTSET GPIO3_DR_SET
  210. #define CORE_PIN37_PORTSET GPIO3_DR_SET
  211. #define CORE_PIN38_PORTSET GPIO3_DR_SET
  212. #define CORE_PIN39_PORTSET GPIO3_DR_SET
  213. #define CORE_PIN0_PORTCLEAR GPIO1_DR_CLEAR
  214. #define CORE_PIN1_PORTCLEAR GPIO1_DR_CLEAR
  215. #define CORE_PIN2_PORTCLEAR GPIO4_DR_CLEAR
  216. #define CORE_PIN3_PORTCLEAR GPIO4_DR_CLEAR
  217. #define CORE_PIN4_PORTCLEAR GPIO4_DR_CLEAR
  218. #define CORE_PIN5_PORTCLEAR GPIO4_DR_CLEAR
  219. #define CORE_PIN6_PORTCLEAR GPIO2_DR_CLEAR
  220. #define CORE_PIN7_PORTCLEAR GPIO2_DR_CLEAR
  221. #define CORE_PIN8_PORTCLEAR GPIO2_DR_CLEAR
  222. #define CORE_PIN9_PORTCLEAR GPIO2_DR_CLEAR
  223. #define CORE_PIN10_PORTCLEAR GPIO2_DR_CLEAR
  224. #define CORE_PIN11_PORTCLEAR GPIO2_DR_CLEAR
  225. #define CORE_PIN12_PORTCLEAR GPIO2_DR_CLEAR
  226. #define CORE_PIN13_PORTCLEAR GPIO2_DR_CLEAR
  227. #define CORE_PIN14_PORTCLEAR GPIO1_DR_CLEAR
  228. #define CORE_PIN15_PORTCLEAR GPIO1_DR_CLEAR
  229. #define CORE_PIN16_PORTCLEAR GPIO1_DR_CLEAR
  230. #define CORE_PIN17_PORTCLEAR GPIO1_DR_CLEAR
  231. #define CORE_PIN18_PORTCLEAR GPIO1_DR_CLEAR
  232. #define CORE_PIN19_PORTCLEAR GPIO1_DR_CLEAR
  233. #define CORE_PIN20_PORTCLEAR GPIO1_DR_CLEAR
  234. #define CORE_PIN21_PORTCLEAR GPIO1_DR_CLEAR
  235. #define CORE_PIN22_PORTCLEAR GPIO1_DR_CLEAR
  236. #define CORE_PIN23_PORTCLEAR GPIO1_DR_CLEAR
  237. #define CORE_PIN24_PORTCLEAR GPIO1_DR_CLEAR
  238. #define CORE_PIN25_PORTCLEAR GPIO1_DR_CLEAR
  239. #define CORE_PIN26_PORTCLEAR GPIO1_DR_CLEAR
  240. #define CORE_PIN27_PORTCLEAR GPIO1_DR_CLEAR
  241. #define CORE_PIN28_PORTCLEAR GPIO3_DR_CLEAR
  242. #define CORE_PIN29_PORTCLEAR GPIO4_DR_CLEAR
  243. #define CORE_PIN30_PORTCLEAR GPIO4_DR_CLEAR
  244. #define CORE_PIN31_PORTCLEAR GPIO4_DR_CLEAR
  245. #define CORE_PIN32_PORTCLEAR GPIO2_DR_CLEAR
  246. #define CORE_PIN33_PORTCLEAR GPIO4_DR_CLEAR
  247. #define CORE_PIN34_PORTCLEAR GPIO3_DR_CLEAR
  248. #define CORE_PIN35_PORTCLEAR GPIO3_DR_CLEAR
  249. #define CORE_PIN36_PORTCLEAR GPIO3_DR_CLEAR
  250. #define CORE_PIN37_PORTCLEAR GPIO3_DR_CLEAR
  251. #define CORE_PIN38_PORTCLEAR GPIO3_DR_CLEAR
  252. #define CORE_PIN39_PORTCLEAR GPIO3_DR_CLEAR
  253. #define CORE_PIN0_DDRREG GPIO1_GDIR
  254. #define CORE_PIN1_DDRREG GPIO1_GDIR
  255. #define CORE_PIN2_DDRREG GPIO4_GDIR
  256. #define CORE_PIN3_DDRREG GPIO4_GDIR
  257. #define CORE_PIN4_DDRREG GPIO4_GDIR
  258. #define CORE_PIN5_DDRREG GPIO4_GDIR
  259. #define CORE_PIN6_DDRREG GPIO2_GDIR
  260. #define CORE_PIN7_DDRREG GPIO2_GDIR
  261. #define CORE_PIN8_DDRREG GPIO2_GDIR
  262. #define CORE_PIN9_DDRREG GPIO2_GDIR
  263. #define CORE_PIN10_DDRREG GPIO2_GDIR
  264. #define CORE_PIN11_DDRREG GPIO2_GDIR
  265. #define CORE_PIN12_DDRREG GPIO2_GDIR
  266. #define CORE_PIN13_DDRREG GPIO2_GDIR
  267. #define CORE_PIN14_DDRREG GPIO1_GDIR
  268. #define CORE_PIN15_DDRREG GPIO1_GDIR
  269. #define CORE_PIN16_DDRREG GPIO1_GDIR
  270. #define CORE_PIN17_DDRREG GPIO1_GDIR
  271. #define CORE_PIN18_DDRREG GPIO1_GDIR
  272. #define CORE_PIN19_DDRREG GPIO1_GDIR
  273. #define CORE_PIN20_DDRREG GPIO1_GDIR
  274. #define CORE_PIN21_DDRREG GPIO1_GDIR
  275. #define CORE_PIN22_DDRREG GPIO1_GDIR
  276. #define CORE_PIN23_DDRREG GPIO1_GDIR
  277. #define CORE_PIN24_DDRREG GPIO1_GDIR
  278. #define CORE_PIN25_DDRREG GPIO1_GDIR
  279. #define CORE_PIN26_DDRREG GPIO1_GDIR
  280. #define CORE_PIN27_DDRREG GPIO1_GDIR
  281. #define CORE_PIN28_DDRREG GPIO3_GDIR
  282. #define CORE_PIN29_DDRREG GPIO4_GDIR
  283. #define CORE_PIN30_DDRREG GPIO4_GDIR
  284. #define CORE_PIN31_DDRREG GPIO4_GDIR
  285. #define CORE_PIN32_DDRREG GPIO2_GDIR
  286. #define CORE_PIN33_DDRREG GPIO4_GDIR
  287. #define CORE_PIN34_DDRREG GPIO3_GDIR
  288. #define CORE_PIN35_DDRREG GPIO3_GDIR
  289. #define CORE_PIN36_DDRREG GPIO3_GDIR
  290. #define CORE_PIN37_DDRREG GPIO3_GDIR
  291. #define CORE_PIN38_DDRREG GPIO3_GDIR
  292. #define CORE_PIN39_DDRREG GPIO3_GDIR
  293. #define CORE_PIN0_PINREG GPIO1_PSR
  294. #define CORE_PIN1_PINREG GPIO1_PSR
  295. #define CORE_PIN2_PINREG GPIO4_PSR
  296. #define CORE_PIN3_PINREG GPIO4_PSR
  297. #define CORE_PIN4_PINREG GPIO4_PSR
  298. #define CORE_PIN5_PINREG GPIO4_PSR
  299. #define CORE_PIN6_PINREG GPIO2_PSR
  300. #define CORE_PIN7_PINREG GPIO2_PSR
  301. #define CORE_PIN8_PINREG GPIO2_PSR
  302. #define CORE_PIN9_PINREG GPIO2_PSR
  303. #define CORE_PIN10_PINREG GPIO2_PSR
  304. #define CORE_PIN11_PINREG GPIO2_PSR
  305. #define CORE_PIN12_PINREG GPIO2_PSR
  306. #define CORE_PIN13_PINREG GPIO2_PSR
  307. #define CORE_PIN14_PINREG GPIO1_PSR
  308. #define CORE_PIN15_PINREG GPIO1_PSR
  309. #define CORE_PIN16_PINREG GPIO1_PSR
  310. #define CORE_PIN17_PINREG GPIO1_PSR
  311. #define CORE_PIN18_PINREG GPIO1_PSR
  312. #define CORE_PIN19_PINREG GPIO1_PSR
  313. #define CORE_PIN20_PINREG GPIO1_PSR
  314. #define CORE_PIN21_PINREG GPIO1_PSR
  315. #define CORE_PIN22_PINREG GPIO1_PSR
  316. #define CORE_PIN23_PINREG GPIO1_PSR
  317. #define CORE_PIN24_PINREG GPIO1_PSR
  318. #define CORE_PIN25_PINREG GPIO1_PSR
  319. #define CORE_PIN26_PINREG GPIO1_PSR
  320. #define CORE_PIN27_PINREG GPIO1_PSR
  321. #define CORE_PIN28_PINREG GPIO3_PSR
  322. #define CORE_PIN29_PINREG GPIO4_PSR
  323. #define CORE_PIN30_PINREG GPIO4_PSR
  324. #define CORE_PIN31_PINREG GPIO4_PSR
  325. #define CORE_PIN32_PINREG GPIO2_PSR
  326. #define CORE_PIN33_PINREG GPIO4_PSR
  327. #define CORE_PIN34_PINREG GPIO3_PSR
  328. #define CORE_PIN35_PINREG GPIO3_PSR
  329. #define CORE_PIN36_PINREG GPIO3_PSR
  330. #define CORE_PIN37_PINREG GPIO3_PSR
  331. #define CORE_PIN38_PINREG GPIO3_PSR
  332. #define CORE_PIN39_PINREG GPIO3_PSR
  333. // mux config registers control which peripheral uses the pin
  334. #define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
  335. #define CORE_PIN1_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02
  336. #define CORE_PIN2_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04
  337. #define CORE_PIN3_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_05
  338. #define CORE_PIN4_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_06
  339. #define CORE_PIN5_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_08
  340. #define CORE_PIN6_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_10
  341. #define CORE_PIN7_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01
  342. #define CORE_PIN8_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00
  343. #define CORE_PIN9_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11
  344. #define CORE_PIN10_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_00
  345. #define CORE_PIN11_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_02
  346. #define CORE_PIN12_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_01
  347. #define CORE_PIN13_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03
  348. #define CORE_PIN14_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02
  349. #define CORE_PIN15_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03
  350. #define CORE_PIN16_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07
  351. #define CORE_PIN17_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06
  352. #define CORE_PIN18_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_01
  353. #define CORE_PIN19_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00
  354. #define CORE_PIN20_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10
  355. #define CORE_PIN21_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11
  356. #define CORE_PIN22_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_08
  357. #define CORE_PIN23_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_09
  358. #define CORE_PIN24_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12
  359. #define CORE_PIN25_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13
  360. #define CORE_PIN26_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_14
  361. #define CORE_PIN27_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_15
  362. #define CORE_PIN28_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32
  363. #define CORE_PIN29_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31
  364. #define CORE_PIN30_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_24
  365. #define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_23
  366. #define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
  367. #define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
  368. #define CORE_PIN34_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_03
  369. #define CORE_PIN35_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_02
  370. #define CORE_PIN36_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_01
  371. #define CORE_PIN37_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_00
  372. #define CORE_PIN38_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_05
  373. #define CORE_PIN39_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_04
  374. // pad config registers control pullup/pulldown/keeper, drive strength, etc
  375. #define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
  376. #define CORE_PIN1_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_02
  377. #define CORE_PIN2_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04
  378. #define CORE_PIN3_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_05
  379. #define CORE_PIN4_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_06
  380. #define CORE_PIN5_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_08
  381. #define CORE_PIN6_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
  382. #define CORE_PIN7_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01
  383. #define CORE_PIN8_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_00
  384. #define CORE_PIN9_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_11
  385. #define CORE_PIN10_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_00
  386. #define CORE_PIN11_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_02
  387. #define CORE_PIN12_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_01
  388. #define CORE_PIN13_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03
  389. #define CORE_PIN14_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02
  390. #define CORE_PIN15_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_03
  391. #define CORE_PIN16_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_07
  392. #define CORE_PIN17_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_06
  393. #define CORE_PIN18_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01
  394. #define CORE_PIN19_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00
  395. #define CORE_PIN20_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_10
  396. #define CORE_PIN21_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11
  397. #define CORE_PIN22_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_08
  398. #define CORE_PIN23_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_09
  399. #define CORE_PIN24_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_12
  400. #define CORE_PIN25_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_13
  401. #define CORE_PIN26_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_14
  402. #define CORE_PIN27_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_15
  403. #define CORE_PIN28_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_32
  404. #define CORE_PIN29_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_31
  405. #define CORE_PIN30_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_24
  406. #define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_23
  407. #define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
  408. #define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
  409. #define CORE_PIN34_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_03
  410. #define CORE_PIN35_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_02
  411. #define CORE_PIN36_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_01
  412. #define CORE_PIN37_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_00
  413. #define CORE_PIN38_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_05
  414. #define CORE_PIN39_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_04
  415. #define CORE_LED0_PIN 13
  416. #define CORE_ADC0_PIN 14
  417. #define CORE_ADC1_PIN 15
  418. #define CORE_ADC2_PIN 16
  419. #define CORE_ADC3_PIN 17
  420. #define CORE_ADC4_PIN 18
  421. #define CORE_ADC5_PIN 19
  422. #define CORE_ADC6_PIN 20
  423. #define CORE_ADC7_PIN 21
  424. #define CORE_ADC8_PIN 22
  425. #define CORE_ADC9_PIN 23
  426. #define CORE_RXD0_PIN 0
  427. #define CORE_TXD0_PIN 1
  428. #define CORE_RXD1_PIN 7
  429. #define CORE_TXD1_PIN 8
  430. #define CORE_RXD2_PIN 15
  431. #define CORE_TXD2_PIN 14
  432. #define CORE_RXD3_PIN 16
  433. #define CORE_TXD3_PIN 17
  434. #define CORE_RXD4_PIN 21
  435. #define CORE_TXD4_PIN 20
  436. #define CORE_RXD5_PIN 25
  437. #define CORE_TXD5_PIN 24
  438. #define CORE_RXD6_PIN 28
  439. #define CORE_TXD6_PIN 29
  440. #define CORE_INT0_PIN 0
  441. #define CORE_INT1_PIN 1
  442. #define CORE_INT2_PIN 2
  443. #define CORE_INT3_PIN 3
  444. #define CORE_INT4_PIN 4
  445. #define CORE_INT5_PIN 5
  446. #define CORE_INT6_PIN 6
  447. #define CORE_INT7_PIN 7
  448. #define CORE_INT8_PIN 8
  449. #define CORE_INT9_PIN 9
  450. #define CORE_INT10_PIN 10
  451. #define CORE_INT11_PIN 11
  452. #define CORE_INT12_PIN 12
  453. #define CORE_INT13_PIN 13
  454. #define CORE_INT14_PIN 14
  455. #define CORE_INT15_PIN 15
  456. #define CORE_INT16_PIN 16
  457. #define CORE_INT17_PIN 17
  458. #define CORE_INT18_PIN 18
  459. #define CORE_INT19_PIN 19
  460. #define CORE_INT20_PIN 20
  461. #define CORE_INT21_PIN 21
  462. #define CORE_INT22_PIN 22
  463. #define CORE_INT23_PIN 23
  464. #define CORE_INT24_PIN 24
  465. #define CORE_INT25_PIN 25
  466. #define CORE_INT26_PIN 26
  467. #define CORE_INT27_PIN 27
  468. #define CORE_INT28_PIN 28
  469. #define CORE_INT29_PIN 29
  470. #define CORE_INT30_PIN 30
  471. #define CORE_INT31_PIN 31
  472. #define CORE_INT32_PIN 32
  473. #define CORE_INT33_PIN 33
  474. #define CORE_INT34_PIN 34
  475. #define CORE_INT35_PIN 35
  476. #define CORE_INT36_PIN 36
  477. #define CORE_INT37_PIN 37
  478. #define CORE_INT38_PIN 38
  479. #define CORE_INT39_PIN 39
  480. #define CORE_INT_EVERY_PIN 1
  481. #elif defined(__IMXRT1052__)
  482. #define CORE_NUM_TOTAL_PINS 34
  483. #define CORE_NUM_DIGITAL 34
  484. #define CORE_NUM_INTERRUPT 34
  485. #define CORE_NUM_ANALOG 14
  486. #define CORE_NUM_PWM 27
  487. #define CORE_PIN0_BIT 3
  488. #define CORE_PIN1_BIT 2
  489. #define CORE_PIN2_BIT 4
  490. #define CORE_PIN3_BIT 5
  491. #define CORE_PIN4_BIT 6
  492. #define CORE_PIN5_BIT 7
  493. #define CORE_PIN6_BIT 17
  494. #define CORE_PIN7_BIT 16
  495. #define CORE_PIN8_BIT 10
  496. #define CORE_PIN9_BIT 11
  497. #define CORE_PIN10_BIT 0
  498. #define CORE_PIN11_BIT 2
  499. #define CORE_PIN12_BIT 1
  500. #define CORE_PIN13_BIT 3
  501. #define CORE_PIN14_BIT 18
  502. #define CORE_PIN15_BIT 19
  503. #define CORE_PIN16_BIT 23
  504. #define CORE_PIN17_BIT 22
  505. #define CORE_PIN18_BIT 17
  506. #define CORE_PIN19_BIT 16
  507. #define CORE_PIN20_BIT 26
  508. #define CORE_PIN21_BIT 27
  509. #define CORE_PIN22_BIT 24
  510. #define CORE_PIN23_BIT 25
  511. #define CORE_PIN24_BIT 12
  512. #define CORE_PIN25_BIT 13
  513. #define CORE_PIN26_BIT 30
  514. #define CORE_PIN27_BIT 31
  515. #define CORE_PIN28_BIT 18
  516. #define CORE_PIN29_BIT 31
  517. #define CORE_PIN30_BIT 24
  518. #define CORE_PIN31_BIT 23
  519. #define CORE_PIN32_BIT 12
  520. #define CORE_PIN33_BIT 8
  521. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  522. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  523. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  524. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  525. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  526. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  527. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  528. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  529. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  530. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  531. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  532. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  533. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  534. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  535. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  536. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  537. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  538. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  539. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  540. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  541. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  542. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  543. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  544. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  545. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  546. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  547. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  548. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  549. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  550. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  551. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  552. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  553. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  554. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  555. #define CORE_PIN0_PORTREG GPIO1_DR
  556. #define CORE_PIN1_PORTREG GPIO1_DR
  557. #define CORE_PIN2_PORTREG GPIO4_DR
  558. #define CORE_PIN3_PORTREG GPIO4_DR
  559. #define CORE_PIN4_PORTREG GPIO4_DR
  560. #define CORE_PIN5_PORTREG GPIO4_DR
  561. #define CORE_PIN6_PORTREG GPIO2_DR
  562. #define CORE_PIN7_PORTREG GPIO2_DR
  563. #define CORE_PIN8_PORTREG GPIO2_DR
  564. #define CORE_PIN9_PORTREG GPIO2_DR
  565. #define CORE_PIN10_PORTREG GPIO2_DR
  566. #define CORE_PIN11_PORTREG GPIO2_DR
  567. #define CORE_PIN12_PORTREG GPIO2_DR
  568. #define CORE_PIN13_PORTREG GPIO2_DR
  569. #define CORE_PIN14_PORTREG GPIO1_DR
  570. #define CORE_PIN15_PORTREG GPIO1_DR
  571. #define CORE_PIN16_PORTREG GPIO1_DR
  572. #define CORE_PIN17_PORTREG GPIO1_DR
  573. #define CORE_PIN18_PORTREG GPIO1_DR
  574. #define CORE_PIN19_PORTREG GPIO1_DR
  575. #define CORE_PIN20_PORTREG GPIO1_DR
  576. #define CORE_PIN21_PORTREG GPIO1_DR
  577. #define CORE_PIN22_PORTREG GPIO1_DR
  578. #define CORE_PIN23_PORTREG GPIO1_DR
  579. #define CORE_PIN24_PORTREG GPIO1_DR
  580. #define CORE_PIN25_PORTREG GPIO1_DR
  581. #define CORE_PIN26_PORTREG GPIO1_DR
  582. #define CORE_PIN27_PORTREG GPIO1_DR
  583. #define CORE_PIN28_PORTREG GPIO3_DR
  584. #define CORE_PIN29_PORTREG GPIO4_DR
  585. #define CORE_PIN30_PORTREG GPIO4_DR
  586. #define CORE_PIN31_PORTREG GPIO4_DR
  587. #define CORE_PIN32_PORTREG GPIO2_DR
  588. #define CORE_PIN33_PORTREG GPIO4_DR
  589. #define CORE_PIN0_PORTSET GPIO1_DR_SET
  590. #define CORE_PIN1_PORTSET GPIO1_DR_SET
  591. #define CORE_PIN2_PORTSET GPIO4_DR_SET
  592. #define CORE_PIN3_PORTSET GPIO4_DR_SET
  593. #define CORE_PIN4_PORTSET GPIO4_DR_SET
  594. #define CORE_PIN5_PORTSET GPIO4_DR_SET
  595. #define CORE_PIN6_PORTSET GPIO2_DR_SET
  596. #define CORE_PIN7_PORTSET GPIO2_DR_SET
  597. #define CORE_PIN8_PORTSET GPIO2_DR_SET
  598. #define CORE_PIN9_PORTSET GPIO2_DR_SET
  599. #define CORE_PIN10_PORTSET GPIO2_DR_SET
  600. #define CORE_PIN11_PORTSET GPIO2_DR_SET
  601. #define CORE_PIN12_PORTSET GPIO2_DR_SET
  602. #define CORE_PIN13_PORTSET GPIO2_DR_SET
  603. #define CORE_PIN14_PORTSET GPIO1_DR_SET
  604. #define CORE_PIN15_PORTSET GPIO1_DR_SET
  605. #define CORE_PIN16_PORTSET GPIO1_DR_SET
  606. #define CORE_PIN17_PORTSET GPIO1_DR_SET
  607. #define CORE_PIN18_PORTSET GPIO1_DR_SET
  608. #define CORE_PIN19_PORTSET GPIO1_DR_SET
  609. #define CORE_PIN20_PORTSET GPIO1_DR_SET
  610. #define CORE_PIN21_PORTSET GPIO1_DR_SET
  611. #define CORE_PIN22_PORTSET GPIO1_DR_SET
  612. #define CORE_PIN23_PORTSET GPIO1_DR_SET
  613. #define CORE_PIN24_PORTSET GPIO1_DR_SET
  614. #define CORE_PIN25_PORTSET GPIO1_DR_SET
  615. #define CORE_PIN26_PORTSET GPIO1_DR_SET
  616. #define CORE_PIN27_PORTSET GPIO1_DR_SET
  617. #define CORE_PIN28_PORTSET GPIO3_DR_SET
  618. #define CORE_PIN29_PORTSET GPIO4_DR_SET
  619. #define CORE_PIN30_PORTSET GPIO4_DR_SET
  620. #define CORE_PIN31_PORTSET GPIO4_DR_SET
  621. #define CORE_PIN32_PORTSET GPIO2_DR_SET
  622. #define CORE_PIN33_PORTSET GPIO4_DR_SET
  623. #define CORE_PIN0_PORTCLEAR GPIO1_DR_CLEAR
  624. #define CORE_PIN1_PORTCLEAR GPIO1_DR_CLEAR
  625. #define CORE_PIN2_PORTCLEAR GPIO4_DR_CLEAR
  626. #define CORE_PIN3_PORTCLEAR GPIO4_DR_CLEAR
  627. #define CORE_PIN4_PORTCLEAR GPIO4_DR_CLEAR
  628. #define CORE_PIN5_PORTCLEAR GPIO4_DR_CLEAR
  629. #define CORE_PIN6_PORTCLEAR GPIO2_DR_CLEAR
  630. #define CORE_PIN7_PORTCLEAR GPIO2_DR_CLEAR
  631. #define CORE_PIN8_PORTCLEAR GPIO2_DR_CLEAR
  632. #define CORE_PIN9_PORTCLEAR GPIO2_DR_CLEAR
  633. #define CORE_PIN10_PORTCLEAR GPIO2_DR_CLEAR
  634. #define CORE_PIN11_PORTCLEAR GPIO2_DR_CLEAR
  635. #define CORE_PIN12_PORTCLEAR GPIO2_DR_CLEAR
  636. #define CORE_PIN13_PORTCLEAR GPIO2_DR_CLEAR
  637. #define CORE_PIN14_PORTCLEAR GPIO1_DR_CLEAR
  638. #define CORE_PIN15_PORTCLEAR GPIO1_DR_CLEAR
  639. #define CORE_PIN16_PORTCLEAR GPIO1_DR_CLEAR
  640. #define CORE_PIN17_PORTCLEAR GPIO1_DR_CLEAR
  641. #define CORE_PIN18_PORTCLEAR GPIO1_DR_CLEAR
  642. #define CORE_PIN19_PORTCLEAR GPIO1_DR_CLEAR
  643. #define CORE_PIN20_PORTCLEAR GPIO1_DR_CLEAR
  644. #define CORE_PIN21_PORTCLEAR GPIO1_DR_CLEAR
  645. #define CORE_PIN22_PORTCLEAR GPIO1_DR_CLEAR
  646. #define CORE_PIN23_PORTCLEAR GPIO1_DR_CLEAR
  647. #define CORE_PIN24_PORTCLEAR GPIO1_DR_CLEAR
  648. #define CORE_PIN25_PORTCLEAR GPIO1_DR_CLEAR
  649. #define CORE_PIN26_PORTCLEAR GPIO1_DR_CLEAR
  650. #define CORE_PIN27_PORTCLEAR GPIO1_DR_CLEAR
  651. #define CORE_PIN28_PORTCLEAR GPIO3_DR_CLEAR
  652. #define CORE_PIN29_PORTCLEAR GPIO4_DR_CLEAR
  653. #define CORE_PIN30_PORTCLEAR GPIO4_DR_CLEAR
  654. #define CORE_PIN31_PORTCLEAR GPIO4_DR_CLEAR
  655. #define CORE_PIN32_PORTCLEAR GPIO2_DR_CLEAR
  656. #define CORE_PIN33_PORTCLEAR GPIO4_DR_CLEAR
  657. #define CORE_PIN0_DDRREG GPIO1_GDIR
  658. #define CORE_PIN1_DDRREG GPIO1_GDIR
  659. #define CORE_PIN2_DDRREG GPIO4_GDIR
  660. #define CORE_PIN3_DDRREG GPIO4_GDIR
  661. #define CORE_PIN4_DDRREG GPIO4_GDIR
  662. #define CORE_PIN5_DDRREG GPIO4_GDIR
  663. #define CORE_PIN6_DDRREG GPIO2_GDIR
  664. #define CORE_PIN7_DDRREG GPIO2_GDIR
  665. #define CORE_PIN8_DDRREG GPIO2_GDIR
  666. #define CORE_PIN9_DDRREG GPIO2_GDIR
  667. #define CORE_PIN10_DDRREG GPIO2_GDIR
  668. #define CORE_PIN11_DDRREG GPIO2_GDIR
  669. #define CORE_PIN12_DDRREG GPIO2_GDIR
  670. #define CORE_PIN13_DDRREG GPIO2_GDIR
  671. #define CORE_PIN14_DDRREG GPIO1_GDIR
  672. #define CORE_PIN15_DDRREG GPIO1_GDIR
  673. #define CORE_PIN16_DDRREG GPIO1_GDIR
  674. #define CORE_PIN17_DDRREG GPIO1_GDIR
  675. #define CORE_PIN18_DDRREG GPIO1_GDIR
  676. #define CORE_PIN19_DDRREG GPIO1_GDIR
  677. #define CORE_PIN20_DDRREG GPIO1_GDIR
  678. #define CORE_PIN21_DDRREG GPIO1_GDIR
  679. #define CORE_PIN22_DDRREG GPIO1_GDIR
  680. #define CORE_PIN23_DDRREG GPIO1_GDIR
  681. #define CORE_PIN24_DDRREG GPIO1_GDIR
  682. #define CORE_PIN25_DDRREG GPIO1_GDIR
  683. #define CORE_PIN26_DDRREG GPIO1_GDIR
  684. #define CORE_PIN27_DDRREG GPIO1_GDIR
  685. #define CORE_PIN28_DDRREG GPIO3_GDIR
  686. #define CORE_PIN29_DDRREG GPIO4_GDIR
  687. #define CORE_PIN30_DDRREG GPIO4_GDIR
  688. #define CORE_PIN31_DDRREG GPIO4_GDIR
  689. #define CORE_PIN32_DDRREG GPIO2_GDIR
  690. #define CORE_PIN33_DDRREG GPIO4_GDIR
  691. #define CORE_PIN0_PINREG GPIO1_PSR
  692. #define CORE_PIN1_PINREG GPIO1_PSR
  693. #define CORE_PIN2_PINREG GPIO4_PSR
  694. #define CORE_PIN3_PINREG GPIO4_PSR
  695. #define CORE_PIN4_PINREG GPIO4_PSR
  696. #define CORE_PIN5_PINREG GPIO4_PSR
  697. #define CORE_PIN6_PINREG GPIO2_PSR
  698. #define CORE_PIN7_PINREG GPIO2_PSR
  699. #define CORE_PIN8_PINREG GPIO2_PSR
  700. #define CORE_PIN9_PINREG GPIO2_PSR
  701. #define CORE_PIN10_PINREG GPIO2_PSR
  702. #define CORE_PIN11_PINREG GPIO2_PSR
  703. #define CORE_PIN12_PINREG GPIO2_PSR
  704. #define CORE_PIN13_PINREG GPIO2_PSR
  705. #define CORE_PIN14_PINREG GPIO1_PSR
  706. #define CORE_PIN15_PINREG GPIO1_PSR
  707. #define CORE_PIN16_PINREG GPIO1_PSR
  708. #define CORE_PIN17_PINREG GPIO1_PSR
  709. #define CORE_PIN18_PINREG GPIO1_PSR
  710. #define CORE_PIN19_PINREG GPIO1_PSR
  711. #define CORE_PIN20_PINREG GPIO1_PSR
  712. #define CORE_PIN21_PINREG GPIO1_PSR
  713. #define CORE_PIN22_PINREG GPIO1_PSR
  714. #define CORE_PIN23_PINREG GPIO1_PSR
  715. #define CORE_PIN24_PINREG GPIO1_PSR
  716. #define CORE_PIN25_PINREG GPIO1_PSR
  717. #define CORE_PIN26_PINREG GPIO1_PSR
  718. #define CORE_PIN27_PINREG GPIO1_PSR
  719. #define CORE_PIN28_PINREG GPIO3_PSR
  720. #define CORE_PIN29_PINREG GPIO4_PSR
  721. #define CORE_PIN30_PINREG GPIO4_PSR
  722. #define CORE_PIN31_PINREG GPIO4_PSR
  723. #define CORE_PIN32_PINREG GPIO2_PSR
  724. #define CORE_PIN33_PINREG GPIO4_PSR
  725. // mux config registers control which peripheral uses the pin
  726. #define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
  727. #define CORE_PIN1_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02
  728. #define CORE_PIN2_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04
  729. #define CORE_PIN3_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_05
  730. #define CORE_PIN4_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_06
  731. #define CORE_PIN5_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
  732. #define CORE_PIN6_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01
  733. #define CORE_PIN7_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00
  734. #define CORE_PIN8_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_10
  735. #define CORE_PIN9_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11
  736. #define CORE_PIN10_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_00
  737. #define CORE_PIN11_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_02
  738. #define CORE_PIN12_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_01
  739. #define CORE_PIN13_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03
  740. #define CORE_PIN14_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02
  741. #define CORE_PIN15_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03
  742. #define CORE_PIN16_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07
  743. #define CORE_PIN17_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06
  744. #define CORE_PIN18_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_01
  745. #define CORE_PIN19_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00
  746. #define CORE_PIN20_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10
  747. #define CORE_PIN21_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11
  748. #define CORE_PIN22_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_08
  749. #define CORE_PIN23_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_09
  750. #define CORE_PIN24_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12
  751. #define CORE_PIN25_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13
  752. #define CORE_PIN26_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_14
  753. #define CORE_PIN27_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_15
  754. #define CORE_PIN28_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32
  755. #define CORE_PIN29_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31
  756. #define CORE_PIN30_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_24
  757. #define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_23
  758. #define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
  759. #define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_08
  760. // pad config registers control pullup/pulldown/keeper, drive strength, etc
  761. #define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
  762. #define CORE_PIN1_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_02
  763. #define CORE_PIN2_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04
  764. #define CORE_PIN3_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_05
  765. #define CORE_PIN4_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_06
  766. #define CORE_PIN5_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
  767. #define CORE_PIN6_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01
  768. #define CORE_PIN7_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_00
  769. #define CORE_PIN8_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
  770. #define CORE_PIN9_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_11
  771. #define CORE_PIN10_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_00
  772. #define CORE_PIN11_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_02
  773. #define CORE_PIN12_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_01
  774. #define CORE_PIN13_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03
  775. #define CORE_PIN14_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02
  776. #define CORE_PIN15_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_03
  777. #define CORE_PIN16_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_07
  778. #define CORE_PIN17_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_06
  779. #define CORE_PIN18_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01
  780. #define CORE_PIN19_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00
  781. #define CORE_PIN20_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_10
  782. #define CORE_PIN21_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11
  783. #define CORE_PIN22_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_08
  784. #define CORE_PIN23_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_09
  785. #define CORE_PIN24_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_12
  786. #define CORE_PIN25_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_13
  787. #define CORE_PIN26_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_14
  788. #define CORE_PIN27_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_15
  789. #define CORE_PIN28_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_32
  790. #define CORE_PIN29_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_31
  791. #define CORE_PIN30_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_24
  792. #define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_23
  793. #define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
  794. #define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_08
  795. #define CORE_LED0_PIN 13
  796. #define CORE_ADC0_PIN 14
  797. #define CORE_ADC1_PIN 15
  798. #define CORE_ADC2_PIN 16
  799. #define CORE_ADC3_PIN 17
  800. #define CORE_ADC4_PIN 18
  801. #define CORE_ADC5_PIN 19
  802. #define CORE_ADC6_PIN 20
  803. #define CORE_ADC7_PIN 21
  804. #define CORE_ADC8_PIN 22
  805. #define CORE_ADC9_PIN 23
  806. #define CORE_RXD0_PIN 0
  807. #define CORE_TXD0_PIN 1
  808. #define CORE_RXD1_PIN 6
  809. #define CORE_TXD1_PIN 7
  810. #define CORE_RXD2_PIN 15
  811. #define CORE_TXD2_PIN 14
  812. #define CORE_RXD3_PIN 16
  813. #define CORE_TXD3_PIN 17
  814. #define CORE_RXD4_PIN 21
  815. #define CORE_TXD4_PIN 20
  816. #define CORE_RXD5_PIN 25
  817. #define CORE_TXD5_PIN 24
  818. #define CORE_RXD6_PIN 28
  819. #define CORE_TXD6_PIN 29
  820. #define CORE_RXD7_PIN 30
  821. #define CORE_TXD7_PIN 31
  822. #define CORE_INT0_PIN 0
  823. #define CORE_INT1_PIN 1
  824. #define CORE_INT2_PIN 2
  825. #define CORE_INT3_PIN 3
  826. #define CORE_INT4_PIN 4
  827. #define CORE_INT5_PIN 5
  828. #define CORE_INT6_PIN 6
  829. #define CORE_INT7_PIN 7
  830. #define CORE_INT8_PIN 8
  831. #define CORE_INT9_PIN 9
  832. #define CORE_INT10_PIN 10
  833. #define CORE_INT11_PIN 11
  834. #define CORE_INT12_PIN 12
  835. #define CORE_INT13_PIN 13
  836. #define CORE_INT14_PIN 14
  837. #define CORE_INT15_PIN 15
  838. #define CORE_INT16_PIN 16
  839. #define CORE_INT17_PIN 17
  840. #define CORE_INT18_PIN 18
  841. #define CORE_INT19_PIN 19
  842. #define CORE_INT20_PIN 20
  843. #define CORE_INT21_PIN 21
  844. #define CORE_INT22_PIN 22
  845. #define CORE_INT23_PIN 23
  846. #define CORE_INT24_PIN 24
  847. #define CORE_INT25_PIN 25
  848. #define CORE_INT26_PIN 26
  849. #define CORE_INT27_PIN 27
  850. #define CORE_INT28_PIN 28
  851. #define CORE_INT29_PIN 29
  852. #define CORE_INT30_PIN 30
  853. #define CORE_INT31_PIN 31
  854. #define CORE_INT32_PIN 32
  855. #define CORE_INT33_PIN 33
  856. #define CORE_INT_EVERY_PIN 1
  857. #endif // __IMXRT1052__
  858. #ifdef __cplusplus
  859. extern "C" {
  860. #endif
  861. void digitalWrite(uint8_t pin, uint8_t val);
  862. static inline void digitalWriteFast(uint8_t pin, uint8_t val) __attribute__((always_inline, unused));
  863. static inline void digitalWriteFast(uint8_t pin, uint8_t val)
  864. {
  865. if (__builtin_constant_p(pin)) {
  866. if (val) {
  867. if (pin == 0) {
  868. CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
  869. } else if (pin == 1) {
  870. CORE_PIN1_PORTSET = CORE_PIN1_BITMASK;
  871. } else if (pin == 2) {
  872. CORE_PIN2_PORTSET = CORE_PIN2_BITMASK;
  873. } else if (pin == 3) {
  874. CORE_PIN3_PORTSET = CORE_PIN3_BITMASK;
  875. } else if (pin == 4) {
  876. CORE_PIN4_PORTSET = CORE_PIN4_BITMASK;
  877. } else if (pin == 5) {
  878. CORE_PIN5_PORTSET = CORE_PIN5_BITMASK;
  879. } else if (pin == 6) {
  880. CORE_PIN6_PORTSET = CORE_PIN6_BITMASK;
  881. } else if (pin == 7) {
  882. CORE_PIN7_PORTSET = CORE_PIN7_BITMASK;
  883. } else if (pin == 8) {
  884. CORE_PIN8_PORTSET = CORE_PIN8_BITMASK;
  885. } else if (pin == 9) {
  886. CORE_PIN9_PORTSET = CORE_PIN9_BITMASK;
  887. } else if (pin == 10) {
  888. CORE_PIN10_PORTSET = CORE_PIN10_BITMASK;
  889. } else if (pin == 11) {
  890. CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
  891. } else if (pin == 12) {
  892. CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
  893. } else if (pin == 13) {
  894. CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
  895. } else if (pin == 14) {
  896. CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
  897. } else if (pin == 15) {
  898. CORE_PIN15_PORTSET = CORE_PIN15_BITMASK;
  899. } else if (pin == 16) {
  900. CORE_PIN16_PORTSET = CORE_PIN16_BITMASK;
  901. } else if (pin == 17) {
  902. CORE_PIN17_PORTSET = CORE_PIN17_BITMASK;
  903. } else if (pin == 18) {
  904. CORE_PIN18_PORTSET = CORE_PIN18_BITMASK;
  905. } else if (pin == 19) {
  906. CORE_PIN19_PORTSET = CORE_PIN19_BITMASK;
  907. } else if (pin == 20) {
  908. CORE_PIN20_PORTSET = CORE_PIN20_BITMASK;
  909. } else if (pin == 21) {
  910. CORE_PIN21_PORTSET = CORE_PIN21_BITMASK;
  911. } else if (pin == 22) {
  912. CORE_PIN22_PORTSET = CORE_PIN22_BITMASK;
  913. } else if (pin == 23) {
  914. CORE_PIN23_PORTSET = CORE_PIN23_BITMASK;
  915. } else if (pin == 24) {
  916. CORE_PIN24_PORTSET = CORE_PIN24_BITMASK;
  917. } else if (pin == 25) {
  918. CORE_PIN25_PORTSET = CORE_PIN25_BITMASK;
  919. } else if (pin == 26) {
  920. CORE_PIN26_PORTSET = CORE_PIN26_BITMASK;
  921. } else if (pin == 27) {
  922. CORE_PIN27_PORTSET = CORE_PIN27_BITMASK;
  923. } else if (pin == 28) {
  924. CORE_PIN28_PORTSET = CORE_PIN28_BITMASK;
  925. } else if (pin == 29) {
  926. CORE_PIN29_PORTSET = CORE_PIN29_BITMASK;
  927. } else if (pin == 30) {
  928. CORE_PIN30_PORTSET = CORE_PIN30_BITMASK;
  929. } else if (pin == 31) {
  930. CORE_PIN31_PORTSET = CORE_PIN31_BITMASK;
  931. } else if (pin == 32) {
  932. CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
  933. } else if (pin == 33) {
  934. CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
  935. #if defined(__IMXRT1062__)
  936. } else if (pin == 34) {
  937. CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
  938. } else if (pin == 35) {
  939. CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
  940. } else if (pin == 36) {
  941. CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
  942. } else if (pin == 37) {
  943. CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
  944. } else if (pin == 38) {
  945. CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
  946. } else if (pin == 39) {
  947. CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
  948. #endif
  949. }
  950. } else {
  951. if (pin == 0) {
  952. CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;
  953. } else if (pin == 1) {
  954. CORE_PIN1_PORTCLEAR = CORE_PIN1_BITMASK;
  955. } else if (pin == 2) {
  956. CORE_PIN2_PORTCLEAR = CORE_PIN2_BITMASK;
  957. } else if (pin == 3) {
  958. CORE_PIN3_PORTCLEAR = CORE_PIN3_BITMASK;
  959. } else if (pin == 4) {
  960. CORE_PIN4_PORTCLEAR = CORE_PIN4_BITMASK;
  961. } else if (pin == 5) {
  962. CORE_PIN5_PORTCLEAR = CORE_PIN5_BITMASK;
  963. } else if (pin == 6) {
  964. CORE_PIN6_PORTCLEAR = CORE_PIN6_BITMASK;
  965. } else if (pin == 7) {
  966. CORE_PIN7_PORTCLEAR = CORE_PIN7_BITMASK;
  967. } else if (pin == 8) {
  968. CORE_PIN8_PORTCLEAR = CORE_PIN8_BITMASK;
  969. } else if (pin == 9) {
  970. CORE_PIN9_PORTCLEAR = CORE_PIN9_BITMASK;
  971. } else if (pin == 10) {
  972. CORE_PIN10_PORTCLEAR = CORE_PIN10_BITMASK;
  973. } else if (pin == 11) {
  974. CORE_PIN11_PORTCLEAR = CORE_PIN11_BITMASK;
  975. } else if (pin == 12) {
  976. CORE_PIN12_PORTCLEAR = CORE_PIN12_BITMASK;
  977. } else if (pin == 13) {
  978. CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
  979. } else if (pin == 14) {
  980. CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
  981. } else if (pin == 15) {
  982. CORE_PIN15_PORTCLEAR = CORE_PIN15_BITMASK;
  983. } else if (pin == 16) {
  984. CORE_PIN16_PORTCLEAR = CORE_PIN16_BITMASK;
  985. } else if (pin == 17) {
  986. CORE_PIN17_PORTCLEAR = CORE_PIN17_BITMASK;
  987. } else if (pin == 18) {
  988. CORE_PIN18_PORTCLEAR = CORE_PIN18_BITMASK;
  989. } else if (pin == 19) {
  990. CORE_PIN19_PORTCLEAR = CORE_PIN19_BITMASK;
  991. } else if (pin == 20) {
  992. CORE_PIN20_PORTCLEAR = CORE_PIN20_BITMASK;
  993. } else if (pin == 21) {
  994. CORE_PIN21_PORTCLEAR = CORE_PIN21_BITMASK;
  995. } else if (pin == 22) {
  996. CORE_PIN22_PORTCLEAR = CORE_PIN22_BITMASK;
  997. } else if (pin == 23) {
  998. CORE_PIN23_PORTCLEAR = CORE_PIN23_BITMASK;
  999. } else if (pin == 24) {
  1000. CORE_PIN24_PORTCLEAR = CORE_PIN24_BITMASK;
  1001. } else if (pin == 25) {
  1002. CORE_PIN25_PORTCLEAR = CORE_PIN25_BITMASK;
  1003. } else if (pin == 26) {
  1004. CORE_PIN26_PORTCLEAR = CORE_PIN26_BITMASK;
  1005. } else if (pin == 27) {
  1006. CORE_PIN27_PORTCLEAR = CORE_PIN27_BITMASK;
  1007. } else if (pin == 28) {
  1008. CORE_PIN28_PORTCLEAR = CORE_PIN28_BITMASK;
  1009. } else if (pin == 29) {
  1010. CORE_PIN29_PORTCLEAR = CORE_PIN29_BITMASK;
  1011. } else if (pin == 30) {
  1012. CORE_PIN30_PORTCLEAR = CORE_PIN30_BITMASK;
  1013. } else if (pin == 31) {
  1014. CORE_PIN31_PORTCLEAR = CORE_PIN31_BITMASK;
  1015. } else if (pin == 32) {
  1016. CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
  1017. } else if (pin == 33) {
  1018. CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
  1019. #if defined(__IMXRT1062__)
  1020. } else if (pin == 34) {
  1021. CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
  1022. } else if (pin == 35) {
  1023. CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
  1024. } else if (pin == 36) {
  1025. CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
  1026. } else if (pin == 37) {
  1027. CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
  1028. } else if (pin == 38) {
  1029. CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
  1030. } else if (pin == 39) {
  1031. CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
  1032. #endif
  1033. }
  1034. }
  1035. } else {
  1036. if(val) *portSetRegister(pin) = digitalPinToBitMask(pin);
  1037. else *portClearRegister(pin) = digitalPinToBitMask(pin);
  1038. }
  1039. }
  1040. uint8_t digitalRead(uint8_t pin);
  1041. static inline uint8_t digitalReadFast(uint8_t pin) __attribute__((always_inline, unused));
  1042. static inline uint8_t digitalReadFast(uint8_t pin)
  1043. {
  1044. if (__builtin_constant_p(pin)) {
  1045. if (pin == 0) {
  1046. return (CORE_PIN0_PINREG & CORE_PIN0_BITMASK) ? 1 : 0;
  1047. } else if (pin == 1) {
  1048. return (CORE_PIN1_PINREG & CORE_PIN1_BITMASK) ? 1 : 0;
  1049. } else if (pin == 2) {
  1050. return (CORE_PIN2_PINREG & CORE_PIN2_BITMASK) ? 1 : 0;
  1051. } else if (pin == 3) {
  1052. return (CORE_PIN3_PINREG & CORE_PIN3_BITMASK) ? 1 : 0;
  1053. } else if (pin == 4) {
  1054. return (CORE_PIN4_PINREG & CORE_PIN4_BITMASK) ? 1 : 0;
  1055. } else if (pin == 5) {
  1056. return (CORE_PIN5_PINREG & CORE_PIN5_BITMASK) ? 1 : 0;
  1057. } else if (pin == 6) {
  1058. return (CORE_PIN6_PINREG & CORE_PIN6_BITMASK) ? 1 : 0;
  1059. } else if (pin == 7) {
  1060. return (CORE_PIN7_PINREG & CORE_PIN7_BITMASK) ? 1 : 0;
  1061. } else if (pin == 8) {
  1062. return (CORE_PIN8_PINREG & CORE_PIN8_BITMASK) ? 1 : 0;
  1063. } else if (pin == 9) {
  1064. return (CORE_PIN9_PINREG & CORE_PIN9_BITMASK) ? 1 : 0;
  1065. } else if (pin == 10) {
  1066. return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
  1067. } else if (pin == 11) {
  1068. return (CORE_PIN11_PINREG & CORE_PIN11_BITMASK) ? 1 : 0;
  1069. } else if (pin == 12) {
  1070. return (CORE_PIN12_PINREG & CORE_PIN12_BITMASK) ? 1 : 0;
  1071. } else if (pin == 13) {
  1072. return (CORE_PIN13_PINREG & CORE_PIN13_BITMASK) ? 1 : 0;
  1073. } else if (pin == 14) {
  1074. return (CORE_PIN14_PINREG & CORE_PIN14_BITMASK) ? 1 : 0;
  1075. } else if (pin == 15) {
  1076. return (CORE_PIN15_PINREG & CORE_PIN15_BITMASK) ? 1 : 0;
  1077. } else if (pin == 16) {
  1078. return (CORE_PIN16_PINREG & CORE_PIN16_BITMASK) ? 1 : 0;
  1079. } else if (pin == 17) {
  1080. return (CORE_PIN17_PINREG & CORE_PIN17_BITMASK) ? 1 : 0;
  1081. } else if (pin == 18) {
  1082. return (CORE_PIN18_PINREG & CORE_PIN18_BITMASK) ? 1 : 0;
  1083. } else if (pin == 19) {
  1084. return (CORE_PIN19_PINREG & CORE_PIN19_BITMASK) ? 1 : 0;
  1085. } else if (pin == 20) {
  1086. return (CORE_PIN20_PINREG & CORE_PIN20_BITMASK) ? 1 : 0;
  1087. } else if (pin == 21) {
  1088. return (CORE_PIN21_PINREG & CORE_PIN21_BITMASK) ? 1 : 0;
  1089. } else if (pin == 22) {
  1090. return (CORE_PIN22_PINREG & CORE_PIN22_BITMASK) ? 1 : 0;
  1091. } else if (pin == 23) {
  1092. return (CORE_PIN23_PINREG & CORE_PIN23_BITMASK) ? 1 : 0;
  1093. } else if (pin == 24) {
  1094. return (CORE_PIN24_PINREG & CORE_PIN24_BITMASK) ? 1 : 0;
  1095. } else if (pin == 25) {
  1096. return (CORE_PIN25_PINREG & CORE_PIN25_BITMASK) ? 1 : 0;
  1097. } else if (pin == 26) {
  1098. return (CORE_PIN26_PINREG & CORE_PIN26_BITMASK) ? 1 : 0;
  1099. } else if (pin == 27) {
  1100. return (CORE_PIN27_PINREG & CORE_PIN27_BITMASK) ? 1 : 0;
  1101. } else if (pin == 28) {
  1102. return (CORE_PIN28_PINREG & CORE_PIN28_BITMASK) ? 1 : 0;
  1103. } else if (pin == 29) {
  1104. return (CORE_PIN29_PINREG & CORE_PIN29_BITMASK) ? 1 : 0;
  1105. } else if (pin == 30) {
  1106. return (CORE_PIN30_PINREG & CORE_PIN30_BITMASK) ? 1 : 0;
  1107. } else if (pin == 31) {
  1108. return (CORE_PIN31_PINREG & CORE_PIN31_BITMASK) ? 1 : 0;
  1109. } else if (pin == 32) {
  1110. return (CORE_PIN32_PINREG & CORE_PIN32_BITMASK) ? 1 : 0;
  1111. } else if (pin == 33) {
  1112. return (CORE_PIN33_PINREG & CORE_PIN33_BITMASK) ? 1 : 0;
  1113. } else {
  1114. return 0;
  1115. }
  1116. } else {
  1117. return (*portInputRegister(pin) & digitalPinToBitMask(pin)) ? 1 : 0;
  1118. }
  1119. }
  1120. void pinMode(uint8_t pin, uint8_t mode);
  1121. void init_pins(void);
  1122. void analogWrite(uint8_t pin, int val);
  1123. uint32_t analogWriteRes(uint32_t bits);
  1124. static inline uint32_t analogWriteResolution(uint32_t bits) { return analogWriteRes(bits); }
  1125. void analogWriteFrequency(uint8_t pin, float frequency);
  1126. void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
  1127. void detachInterrupt(uint8_t pin);
  1128. void _init_Teensyduino_internal_(void);
  1129. int analogRead(uint8_t pin);
  1130. void analogReference(uint8_t type);
  1131. void analogReadRes(unsigned int bits);
  1132. static inline void analogReadResolution(unsigned int bits) { analogReadRes(bits); }
  1133. void analogReadAveraging(unsigned int num);
  1134. void analog_init(void);
  1135. int touchRead(uint8_t pin);
  1136. static inline void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1137. extern void _shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) __attribute__((noinline));
  1138. extern void shiftOut_lsbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1139. extern void shiftOut_msbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1140. static inline void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
  1141. {
  1142. if (__builtin_constant_p(bitOrder)) {
  1143. if (bitOrder == LSBFIRST) {
  1144. shiftOut_lsbFirst(dataPin, clockPin, value);
  1145. } else {
  1146. shiftOut_msbFirst(dataPin, clockPin, value);
  1147. }
  1148. } else {
  1149. _shiftOut(dataPin, clockPin, bitOrder, value);
  1150. }
  1151. }
  1152. static inline uint8_t shiftIn(uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1153. extern uint8_t _shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) __attribute__((noinline));
  1154. extern uint8_t shiftIn_lsbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1155. extern uint8_t shiftIn_msbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1156. static inline uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
  1157. {
  1158. if (__builtin_constant_p(bitOrder)) {
  1159. if (bitOrder == LSBFIRST) {
  1160. return shiftIn_lsbFirst(dataPin, clockPin);
  1161. } else {
  1162. return shiftIn_msbFirst(dataPin, clockPin);
  1163. }
  1164. } else {
  1165. return _shiftIn(dataPin, clockPin, bitOrder);
  1166. }
  1167. }
  1168. void _reboot_Teensyduino_(void) __attribute__((noreturn));
  1169. void _restart_Teensyduino_(void) __attribute__((noreturn));
  1170. void yield(void);
  1171. void delay(uint32_t msec);
  1172. extern volatile uint32_t F_CPU_ACTUAL;
  1173. extern volatile uint32_t F_BUS_ACTUAL;
  1174. extern volatile uint32_t systick_millis_count;
  1175. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  1176. static inline uint32_t millis(void)
  1177. {
  1178. return systick_millis_count;
  1179. }
  1180. uint32_t micros(void);
  1181. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  1182. static inline void delayMicroseconds(uint32_t usec)
  1183. {
  1184. uint32_t begin = ARM_DWT_CYCCNT;
  1185. uint32_t cycles = F_CPU_ACTUAL / 1000000 * usec;
  1186. // TODO: check if cycles is large, do a wait with yield calls until it's smaller
  1187. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1188. }
  1189. static inline void delayNanoseconds(uint32_t) __attribute__((always_inline, unused));
  1190. static inline void delayNanoseconds(uint32_t nsec)
  1191. {
  1192. uint32_t begin = ARM_DWT_CYCCNT;
  1193. uint32_t cycles = ((F_CPU_ACTUAL>>16) * nsec) / (1000000000UL>>16);
  1194. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1195. }
  1196. unsigned long rtc_get(void);
  1197. void rtc_set(unsigned long t);
  1198. void rtc_compensate(int adjust);
  1199. void tempmon_init(void);
  1200. float tempmonGetTemp(void);
  1201. void tempmon_Start();
  1202. void tempmon_Stop();
  1203. void tempmon_PwrDwn();
  1204. #ifdef __cplusplus
  1205. }
  1206. class teensy3_clock_class
  1207. {
  1208. public:
  1209. static unsigned long get(void) __attribute__((always_inline)) { return rtc_get(); }
  1210. static void set(unsigned long t) __attribute__((always_inline)) { rtc_set(t); }
  1211. static void compensate(int adj) __attribute__((always_inline)) { rtc_compensate(adj); }
  1212. };
  1213. extern teensy3_clock_class Teensy3Clock;
  1214. #endif // __cplusplus