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.

1439 lines
53KB

  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 48
  484. #define CORE_NUM_DIGITAL 48
  485. #define CORE_NUM_INTERRUPT 48
  486. #define CORE_NUM_ANALOG 18
  487. #define CORE_NUM_PWM 29
  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_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  537. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  538. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  539. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  540. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  541. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  542. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  543. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  544. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  545. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  546. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  547. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  548. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  549. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  550. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  551. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  552. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  553. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  554. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  555. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  556. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  557. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  558. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  559. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  560. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  561. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  562. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  563. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  564. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  565. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  566. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  567. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  568. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  569. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  570. #define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
  571. #define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
  572. #define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
  573. #define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
  574. #define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
  575. #define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))
  576. #define CORE_PIN40_BITMASK (1<<(CORE_PIN40_BIT))
  577. #define CORE_PIN41_BITMASK (1<<(CORE_PIN41_BIT))
  578. #define CORE_PIN42_BITMASK (1<<(CORE_PIN42_BIT))
  579. #define CORE_PIN43_BITMASK (1<<(CORE_PIN43_BIT))
  580. #define CORE_PIN44_BITMASK (1<<(CORE_PIN44_BIT))
  581. #define CORE_PIN45_BITMASK (1<<(CORE_PIN45_BIT))
  582. #define CORE_PIN46_BITMASK (1<<(CORE_PIN46_BIT))
  583. #define CORE_PIN47_BITMASK (1<<(CORE_PIN47_BIT))
  584. // Fast GPIO
  585. #define CORE_PIN0_PORTREG GPIO6_DR
  586. #define CORE_PIN1_PORTREG GPIO6_DR
  587. #define CORE_PIN2_PORTREG GPIO9_DR
  588. #define CORE_PIN3_PORTREG GPIO9_DR
  589. #define CORE_PIN4_PORTREG GPIO9_DR
  590. #define CORE_PIN5_PORTREG GPIO9_DR
  591. #define CORE_PIN6_PORTREG GPIO7_DR
  592. #define CORE_PIN7_PORTREG GPIO7_DR
  593. #define CORE_PIN8_PORTREG GPIO7_DR
  594. #define CORE_PIN9_PORTREG GPIO7_DR
  595. #define CORE_PIN10_PORTREG GPIO7_DR
  596. #define CORE_PIN11_PORTREG GPIO7_DR
  597. #define CORE_PIN12_PORTREG GPIO7_DR
  598. #define CORE_PIN13_PORTREG GPIO7_DR
  599. #define CORE_PIN14_PORTREG GPIO6_DR
  600. #define CORE_PIN15_PORTREG GPIO6_DR
  601. #define CORE_PIN16_PORTREG GPIO6_DR
  602. #define CORE_PIN17_PORTREG GPIO6_DR
  603. #define CORE_PIN18_PORTREG GPIO6_DR
  604. #define CORE_PIN19_PORTREG GPIO6_DR
  605. #define CORE_PIN20_PORTREG GPIO6_DR
  606. #define CORE_PIN21_PORTREG GPIO6_DR
  607. #define CORE_PIN22_PORTREG GPIO6_DR
  608. #define CORE_PIN23_PORTREG GPIO6_DR
  609. #define CORE_PIN24_PORTREG GPIO6_DR
  610. #define CORE_PIN25_PORTREG GPIO6_DR
  611. #define CORE_PIN26_PORTREG GPIO6_DR
  612. #define CORE_PIN27_PORTREG GPIO6_DR
  613. #define CORE_PIN28_PORTREG GPIO8_DR
  614. #define CORE_PIN29_PORTREG GPIO9_DR
  615. #define CORE_PIN30_PORTREG GPIO8_DR
  616. #define CORE_PIN31_PORTREG GPIO8_DR
  617. #define CORE_PIN32_PORTREG GPIO7_DR
  618. #define CORE_PIN33_PORTREG GPIO9_DR
  619. #define CORE_PIN34_PORTREG GPIO7_DR
  620. #define CORE_PIN35_PORTREG GPIO7_DR
  621. #define CORE_PIN36_PORTREG GPIO7_DR
  622. #define CORE_PIN37_PORTREG GPIO7_DR
  623. #define CORE_PIN38_PORTREG GPIO6_DR
  624. #define CORE_PIN39_PORTREG GPIO6_DR
  625. #define CORE_PIN40_PORTREG GPIO6_DR
  626. #define CORE_PIN41_PORTREG GPIO6_DR
  627. #define CORE_PIN42_PORTREG GPIO8_DR
  628. #define CORE_PIN43_PORTREG GPIO8_DR
  629. #define CORE_PIN44_PORTREG GPIO8_DR
  630. #define CORE_PIN45_PORTREG GPIO8_DR
  631. #define CORE_PIN46_PORTREG GPIO8_DR
  632. #define CORE_PIN47_PORTREG GPIO8_DR
  633. #define CORE_PIN0_PORTSET GPIO6_DR_SET
  634. #define CORE_PIN1_PORTSET GPIO6_DR_SET
  635. #define CORE_PIN2_PORTSET GPIO9_DR_SET
  636. #define CORE_PIN3_PORTSET GPIO9_DR_SET
  637. #define CORE_PIN4_PORTSET GPIO9_DR_SET
  638. #define CORE_PIN5_PORTSET GPIO9_DR_SET
  639. #define CORE_PIN6_PORTSET GPIO7_DR_SET
  640. #define CORE_PIN7_PORTSET GPIO7_DR_SET
  641. #define CORE_PIN8_PORTSET GPIO7_DR_SET
  642. #define CORE_PIN9_PORTSET GPIO7_DR_SET
  643. #define CORE_PIN10_PORTSET GPIO7_DR_SET
  644. #define CORE_PIN11_PORTSET GPIO7_DR_SET
  645. #define CORE_PIN12_PORTSET GPIO7_DR_SET
  646. #define CORE_PIN13_PORTSET GPIO7_DR_SET
  647. #define CORE_PIN14_PORTSET GPIO6_DR_SET
  648. #define CORE_PIN15_PORTSET GPIO6_DR_SET
  649. #define CORE_PIN16_PORTSET GPIO6_DR_SET
  650. #define CORE_PIN17_PORTSET GPIO6_DR_SET
  651. #define CORE_PIN18_PORTSET GPIO6_DR_SET
  652. #define CORE_PIN19_PORTSET GPIO6_DR_SET
  653. #define CORE_PIN20_PORTSET GPIO6_DR_SET
  654. #define CORE_PIN21_PORTSET GPIO6_DR_SET
  655. #define CORE_PIN22_PORTSET GPIO6_DR_SET
  656. #define CORE_PIN23_PORTSET GPIO6_DR_SET
  657. #define CORE_PIN24_PORTSET GPIO6_DR_SET
  658. #define CORE_PIN25_PORTSET GPIO6_DR_SET
  659. #define CORE_PIN26_PORTSET GPIO6_DR_SET
  660. #define CORE_PIN27_PORTSET GPIO6_DR_SET
  661. #define CORE_PIN28_PORTSET GPIO8_DR_SET
  662. #define CORE_PIN29_PORTSET GPIO9_DR_SET
  663. #define CORE_PIN30_PORTSET GPIO8_DR_SET
  664. #define CORE_PIN31_PORTSET GPIO8_DR_SET
  665. #define CORE_PIN32_PORTSET GPIO7_DR_SET
  666. #define CORE_PIN33_PORTSET GPIO9_DR_SET
  667. #define CORE_PIN34_PORTSET GPIO7_DR_SET
  668. #define CORE_PIN35_PORTSET GPIO7_DR_SET
  669. #define CORE_PIN36_PORTSET GPIO7_DR_SET
  670. #define CORE_PIN37_PORTSET GPIO7_DR_SET
  671. #define CORE_PIN38_PORTSET GPIO6_DR_SET
  672. #define CORE_PIN39_PORTSET GPIO6_DR_SET
  673. #define CORE_PIN40_PORTSET GPIO6_DR_SET
  674. #define CORE_PIN41_PORTSET GPIO6_DR_SET
  675. #define CORE_PIN42_PORTSET GPIO8_DR_SET
  676. #define CORE_PIN43_PORTSET GPIO8_DR_SET
  677. #define CORE_PIN44_PORTSET GPIO8_DR_SET
  678. #define CORE_PIN45_PORTSET GPIO8_DR_SET
  679. #define CORE_PIN46_PORTSET GPIO8_DR_SET
  680. #define CORE_PIN47_PORTSET GPIO8_DR_SET
  681. #define CORE_PIN0_PORTCLEAR GPIO6_DR_CLEAR
  682. #define CORE_PIN1_PORTCLEAR GPIO6_DR_CLEAR
  683. #define CORE_PIN2_PORTCLEAR GPIO9_DR_CLEAR
  684. #define CORE_PIN3_PORTCLEAR GPIO9_DR_CLEAR
  685. #define CORE_PIN4_PORTCLEAR GPIO9_DR_CLEAR
  686. #define CORE_PIN5_PORTCLEAR GPIO9_DR_CLEAR
  687. #define CORE_PIN6_PORTCLEAR GPIO7_DR_CLEAR
  688. #define CORE_PIN7_PORTCLEAR GPIO7_DR_CLEAR
  689. #define CORE_PIN8_PORTCLEAR GPIO7_DR_CLEAR
  690. #define CORE_PIN9_PORTCLEAR GPIO7_DR_CLEAR
  691. #define CORE_PIN10_PORTCLEAR GPIO7_DR_CLEAR
  692. #define CORE_PIN11_PORTCLEAR GPIO7_DR_CLEAR
  693. #define CORE_PIN12_PORTCLEAR GPIO7_DR_CLEAR
  694. #define CORE_PIN13_PORTCLEAR GPIO7_DR_CLEAR
  695. #define CORE_PIN14_PORTCLEAR GPIO6_DR_CLEAR
  696. #define CORE_PIN15_PORTCLEAR GPIO6_DR_CLEAR
  697. #define CORE_PIN16_PORTCLEAR GPIO6_DR_CLEAR
  698. #define CORE_PIN17_PORTCLEAR GPIO6_DR_CLEAR
  699. #define CORE_PIN18_PORTCLEAR GPIO6_DR_CLEAR
  700. #define CORE_PIN19_PORTCLEAR GPIO6_DR_CLEAR
  701. #define CORE_PIN20_PORTCLEAR GPIO6_DR_CLEAR
  702. #define CORE_PIN21_PORTCLEAR GPIO6_DR_CLEAR
  703. #define CORE_PIN22_PORTCLEAR GPIO6_DR_CLEAR
  704. #define CORE_PIN23_PORTCLEAR GPIO6_DR_CLEAR
  705. #define CORE_PIN24_PORTCLEAR GPIO6_DR_CLEAR
  706. #define CORE_PIN25_PORTCLEAR GPIO6_DR_CLEAR
  707. #define CORE_PIN26_PORTCLEAR GPIO6_DR_CLEAR
  708. #define CORE_PIN27_PORTCLEAR GPIO6_DR_CLEAR
  709. #define CORE_PIN28_PORTCLEAR GPIO8_DR_CLEAR
  710. #define CORE_PIN29_PORTCLEAR GPIO9_DR_CLEAR
  711. #define CORE_PIN30_PORTCLEAR GPIO8_DR_CLEAR
  712. #define CORE_PIN31_PORTCLEAR GPIO8_DR_CLEAR
  713. #define CORE_PIN32_PORTCLEAR GPIO7_DR_CLEAR
  714. #define CORE_PIN33_PORTCLEAR GPIO9_DR_CLEAR
  715. #define CORE_PIN34_PORTCLEAR GPIO7_DR_CLEAR
  716. #define CORE_PIN35_PORTCLEAR GPIO7_DR_CLEAR
  717. #define CORE_PIN36_PORTCLEAR GPIO7_DR_CLEAR
  718. #define CORE_PIN37_PORTCLEAR GPIO7_DR_CLEAR
  719. #define CORE_PIN38_PORTCLEAR GPIO6_DR_CLEAR
  720. #define CORE_PIN39_PORTCLEAR GPIO6_DR_CLEAR
  721. #define CORE_PIN40_PORTCLEAR GPIO6_DR_CLEAR
  722. #define CORE_PIN41_PORTCLEAR GPIO6_DR_CLEAR
  723. #define CORE_PIN42_PORTCLEAR GPIO8_DR_CLEAR
  724. #define CORE_PIN43_PORTCLEAR GPIO8_DR_CLEAR
  725. #define CORE_PIN44_PORTCLEAR GPIO8_DR_CLEAR
  726. #define CORE_PIN45_PORTCLEAR GPIO8_DR_CLEAR
  727. #define CORE_PIN46_PORTCLEAR GPIO8_DR_CLEAR
  728. #define CORE_PIN47_PORTCLEAR GPIO8_DR_CLEAR
  729. #define CORE_PIN0_DDRREG GPIO6_GDIR
  730. #define CORE_PIN1_DDRREG GPIO6_GDIR
  731. #define CORE_PIN2_DDRREG GPIO9_GDIR
  732. #define CORE_PIN3_DDRREG GPIO9_GDIR
  733. #define CORE_PIN4_DDRREG GPIO9_GDIR
  734. #define CORE_PIN5_DDRREG GPIO9_GDIR
  735. #define CORE_PIN6_DDRREG GPIO7_GDIR
  736. #define CORE_PIN7_DDRREG GPIO7_GDIR
  737. #define CORE_PIN8_DDRREG GPIO7_GDIR
  738. #define CORE_PIN9_DDRREG GPIO7_GDIR
  739. #define CORE_PIN10_DDRREG GPIO7_GDIR
  740. #define CORE_PIN11_DDRREG GPIO7_GDIR
  741. #define CORE_PIN12_DDRREG GPIO7_GDIR
  742. #define CORE_PIN13_DDRREG GPIO7_GDIR
  743. #define CORE_PIN14_DDRREG GPIO6_GDIR
  744. #define CORE_PIN15_DDRREG GPIO6_GDIR
  745. #define CORE_PIN16_DDRREG GPIO6_GDIR
  746. #define CORE_PIN17_DDRREG GPIO6_GDIR
  747. #define CORE_PIN18_DDRREG GPIO6_GDIR
  748. #define CORE_PIN19_DDRREG GPIO6_GDIR
  749. #define CORE_PIN20_DDRREG GPIO6_GDIR
  750. #define CORE_PIN21_DDRREG GPIO6_GDIR
  751. #define CORE_PIN22_DDRREG GPIO6_GDIR
  752. #define CORE_PIN23_DDRREG GPIO6_GDIR
  753. #define CORE_PIN24_DDRREG GPIO6_GDIR
  754. #define CORE_PIN25_DDRREG GPIO6_GDIR
  755. #define CORE_PIN26_DDRREG GPIO6_GDIR
  756. #define CORE_PIN27_DDRREG GPIO6_GDIR
  757. #define CORE_PIN28_DDRREG GPIO8_GDIR
  758. #define CORE_PIN29_DDRREG GPIO9_GDIR
  759. #define CORE_PIN30_DDRREG GPIO8_GDIR
  760. #define CORE_PIN31_DDRREG GPIO8_GDIR
  761. #define CORE_PIN32_DDRREG GPIO7_GDIR
  762. #define CORE_PIN33_DDRREG GPIO9_GDIR
  763. #define CORE_PIN34_DDRREG GPIO7_GDIR
  764. #define CORE_PIN35_DDRREG GPIO7_GDIR
  765. #define CORE_PIN36_DDRREG GPIO7_GDIR
  766. #define CORE_PIN37_DDRREG GPIO7_GDIR
  767. #define CORE_PIN38_DDRREG GPIO6_GDIR
  768. #define CORE_PIN39_DDRREG GPIO6_GDIR
  769. #define CORE_PIN40_DDRREG GPIO6_GDIR
  770. #define CORE_PIN41_DDRREG GPIO6_GDIR
  771. #define CORE_PIN42_DDRREG GPIO8_GDIR
  772. #define CORE_PIN43_DDRREG GPIO8_GDIR
  773. #define CORE_PIN44_DDRREG GPIO8_GDIR
  774. #define CORE_PIN45_DDRREG GPIO8_GDIR
  775. #define CORE_PIN46_DDRREG GPIO8_GDIR
  776. #define CORE_PIN47_DDRREG GPIO8_GDIR
  777. #define CORE_PIN0_PINREG GPIO6_PSR
  778. #define CORE_PIN1_PINREG GPIO6_PSR
  779. #define CORE_PIN2_PINREG GPIO9_PSR
  780. #define CORE_PIN3_PINREG GPIO9_PSR
  781. #define CORE_PIN4_PINREG GPIO9_PSR
  782. #define CORE_PIN5_PINREG GPIO9_PSR
  783. #define CORE_PIN6_PINREG GPIO7_PSR
  784. #define CORE_PIN7_PINREG GPIO7_PSR
  785. #define CORE_PIN8_PINREG GPIO7_PSR
  786. #define CORE_PIN9_PINREG GPIO7_PSR
  787. #define CORE_PIN10_PINREG GPIO7_PSR
  788. #define CORE_PIN11_PINREG GPIO7_PSR
  789. #define CORE_PIN12_PINREG GPIO7_PSR
  790. #define CORE_PIN13_PINREG GPIO7_PSR
  791. #define CORE_PIN14_PINREG GPIO6_PSR
  792. #define CORE_PIN15_PINREG GPIO6_PSR
  793. #define CORE_PIN16_PINREG GPIO6_PSR
  794. #define CORE_PIN17_PINREG GPIO6_PSR
  795. #define CORE_PIN18_PINREG GPIO6_PSR
  796. #define CORE_PIN19_PINREG GPIO6_PSR
  797. #define CORE_PIN20_PINREG GPIO6_PSR
  798. #define CORE_PIN21_PINREG GPIO6_PSR
  799. #define CORE_PIN22_PINREG GPIO6_PSR
  800. #define CORE_PIN23_PINREG GPIO6_PSR
  801. #define CORE_PIN24_PINREG GPIO6_PSR
  802. #define CORE_PIN25_PINREG GPIO6_PSR
  803. #define CORE_PIN26_PINREG GPIO6_PSR
  804. #define CORE_PIN27_PINREG GPIO6_PSR
  805. #define CORE_PIN28_PINREG GPIO8_PSR
  806. #define CORE_PIN29_PINREG GPIO9_PSR
  807. #define CORE_PIN30_PINREG GPIO8_PSR
  808. #define CORE_PIN31_PINREG GPIO8_PSR
  809. #define CORE_PIN32_PINREG GPIO7_PSR
  810. #define CORE_PIN33_PINREG GPIO9_PSR
  811. #define CORE_PIN34_PINREG GPIO7_PSR
  812. #define CORE_PIN35_PINREG GPIO7_PSR
  813. #define CORE_PIN36_PINREG GPIO7_PSR
  814. #define CORE_PIN37_PINREG GPIO7_PSR
  815. #define CORE_PIN38_PINREG GPIO6_PSR
  816. #define CORE_PIN39_PINREG GPIO6_PSR
  817. #define CORE_PIN40_PINREG GPIO6_PSR
  818. #define CORE_PIN41_PINREG GPIO6_PSR
  819. #define CORE_PIN42_PINREG GPIO8_PSR
  820. #define CORE_PIN43_PINREG GPIO8_PSR
  821. #define CORE_PIN44_PINREG GPIO8_PSR
  822. #define CORE_PIN45_PINREG GPIO8_PSR
  823. #define CORE_PIN46_PINREG GPIO8_PSR
  824. #define CORE_PIN47_PINREG GPIO8_PSR
  825. // mux config registers control which peripheral uses the pin
  826. #define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
  827. #define CORE_PIN1_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02
  828. #define CORE_PIN2_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04
  829. #define CORE_PIN3_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_05
  830. #define CORE_PIN4_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_06
  831. #define CORE_PIN5_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_08
  832. #define CORE_PIN6_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_10
  833. #define CORE_PIN7_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01
  834. #define CORE_PIN8_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00
  835. #define CORE_PIN9_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11
  836. #define CORE_PIN10_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_00
  837. #define CORE_PIN11_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_02
  838. #define CORE_PIN12_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_01
  839. #define CORE_PIN13_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03
  840. #define CORE_PIN14_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02
  841. #define CORE_PIN15_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03
  842. #define CORE_PIN16_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07
  843. #define CORE_PIN17_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06
  844. #define CORE_PIN18_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_01
  845. #define CORE_PIN19_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00
  846. #define CORE_PIN20_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10
  847. #define CORE_PIN21_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11
  848. #define CORE_PIN22_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_08
  849. #define CORE_PIN23_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_09
  850. #define CORE_PIN24_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12
  851. #define CORE_PIN25_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13
  852. #define CORE_PIN26_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_14
  853. #define CORE_PIN27_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_15
  854. #define CORE_PIN28_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32
  855. #define CORE_PIN29_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31
  856. #define CORE_PIN30_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_37
  857. #define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_36
  858. #define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
  859. #define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
  860. #define CORE_PIN34_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_13
  861. #define CORE_PIN35_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_12
  862. #define CORE_PIN36_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_02
  863. #define CORE_PIN37_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_03
  864. #define CORE_PIN38_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_12
  865. #define CORE_PIN39_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_13
  866. #define CORE_PIN40_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_04
  867. #define CORE_PIN41_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_05
  868. #define CORE_PIN42_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_03
  869. #define CORE_PIN43_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_02
  870. #define CORE_PIN44_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_01
  871. #define CORE_PIN45_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_00
  872. #define CORE_PIN46_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_05
  873. #define CORE_PIN47_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_04
  874. // pad config registers control pullup/pulldown/keeper, drive strength, etc
  875. #define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
  876. #define CORE_PIN1_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_02
  877. #define CORE_PIN2_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04
  878. #define CORE_PIN3_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_05
  879. #define CORE_PIN4_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_06
  880. #define CORE_PIN5_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_08
  881. #define CORE_PIN6_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
  882. #define CORE_PIN7_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01
  883. #define CORE_PIN8_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_00
  884. #define CORE_PIN9_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_11
  885. #define CORE_PIN10_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_00
  886. #define CORE_PIN11_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_02
  887. #define CORE_PIN12_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_01
  888. #define CORE_PIN13_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03
  889. #define CORE_PIN14_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02
  890. #define CORE_PIN15_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_03
  891. #define CORE_PIN16_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_07
  892. #define CORE_PIN17_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_06
  893. #define CORE_PIN18_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01
  894. #define CORE_PIN19_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00
  895. #define CORE_PIN20_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_10
  896. #define CORE_PIN21_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11
  897. #define CORE_PIN22_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_08
  898. #define CORE_PIN23_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_09
  899. #define CORE_PIN24_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_12
  900. #define CORE_PIN25_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_13
  901. #define CORE_PIN26_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_14
  902. #define CORE_PIN27_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_15
  903. #define CORE_PIN28_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_32
  904. #define CORE_PIN29_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_31
  905. #define CORE_PIN30_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_37
  906. #define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_36
  907. #define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
  908. #define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
  909. #define CORE_PIN34_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_13
  910. #define CORE_PIN35_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_12
  911. #define CORE_PIN36_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_02
  912. #define CORE_PIN37_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_03
  913. #define CORE_PIN38_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_12
  914. #define CORE_PIN39_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_13
  915. #define CORE_PIN40_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_04
  916. #define CORE_PIN41_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_05
  917. #define CORE_PIN42_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_03
  918. #define CORE_PIN43_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_02
  919. #define CORE_PIN44_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_01
  920. #define CORE_PIN45_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_00
  921. #define CORE_PIN46_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_05
  922. #define CORE_PIN47_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_04
  923. #define CORE_LED0_PIN 13
  924. #define CORE_ADC0_PIN 14
  925. #define CORE_ADC1_PIN 15
  926. #define CORE_ADC2_PIN 16
  927. #define CORE_ADC3_PIN 17
  928. #define CORE_ADC4_PIN 18
  929. #define CORE_ADC5_PIN 19
  930. #define CORE_ADC6_PIN 20
  931. #define CORE_ADC7_PIN 21
  932. #define CORE_ADC8_PIN 22
  933. #define CORE_ADC9_PIN 23
  934. #define CORE_RXD0_PIN 0
  935. #define CORE_TXD0_PIN 1
  936. #define CORE_RXD1_PIN 7
  937. #define CORE_TXD1_PIN 8
  938. #define CORE_RXD2_PIN 15
  939. #define CORE_TXD2_PIN 14
  940. #define CORE_RXD3_PIN 16
  941. #define CORE_TXD3_PIN 17
  942. #define CORE_RXD4_PIN 21
  943. #define CORE_TXD4_PIN 20
  944. #define CORE_RXD5_PIN 25
  945. #define CORE_TXD5_PIN 24
  946. #define CORE_RXD6_PIN 28
  947. #define CORE_TXD6_PIN 29
  948. #define CORE_RXD7_PIN 34
  949. #define CORE_TXD7_PIN 35
  950. #define CORE_INT0_PIN 0
  951. #define CORE_INT1_PIN 1
  952. #define CORE_INT2_PIN 2
  953. #define CORE_INT3_PIN 3
  954. #define CORE_INT4_PIN 4
  955. #define CORE_INT5_PIN 5
  956. #define CORE_INT6_PIN 6
  957. #define CORE_INT7_PIN 7
  958. #define CORE_INT8_PIN 8
  959. #define CORE_INT9_PIN 9
  960. #define CORE_INT10_PIN 10
  961. #define CORE_INT11_PIN 11
  962. #define CORE_INT12_PIN 12
  963. #define CORE_INT13_PIN 13
  964. #define CORE_INT14_PIN 14
  965. #define CORE_INT15_PIN 15
  966. #define CORE_INT16_PIN 16
  967. #define CORE_INT17_PIN 17
  968. #define CORE_INT18_PIN 18
  969. #define CORE_INT19_PIN 19
  970. #define CORE_INT20_PIN 20
  971. #define CORE_INT21_PIN 21
  972. #define CORE_INT22_PIN 22
  973. #define CORE_INT23_PIN 23
  974. #define CORE_INT24_PIN 24
  975. #define CORE_INT25_PIN 25
  976. #define CORE_INT26_PIN 26
  977. #define CORE_INT27_PIN 27
  978. #define CORE_INT28_PIN 28
  979. #define CORE_INT29_PIN 29
  980. #define CORE_INT30_PIN 30
  981. #define CORE_INT31_PIN 31
  982. #define CORE_INT32_PIN 32
  983. #define CORE_INT33_PIN 33
  984. #define CORE_INT34_PIN 34
  985. #define CORE_INT35_PIN 35
  986. #define CORE_INT36_PIN 36
  987. #define CORE_INT37_PIN 37
  988. #define CORE_INT38_PIN 38
  989. #define CORE_INT39_PIN 39
  990. #define CORE_INT40_PIN 40
  991. #define CORE_INT41_PIN 41
  992. #define CORE_INT42_PIN 42
  993. #define CORE_INT43_PIN 43
  994. #define CORE_INT44_PIN 44
  995. #define CORE_INT45_PIN 45
  996. #define CORE_INT46_PIN 46
  997. #define CORE_INT47_PIN 47
  998. #define CORE_INT_EVERY_PIN 1
  999. #endif // __IMXRT1062__
  1000. #ifdef __cplusplus
  1001. extern "C" {
  1002. #endif
  1003. //TODO:
  1004. //#define analogInputToDigitalPin(p)
  1005. //#define digitalPinHasPWM(p)
  1006. #define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
  1007. void digitalWrite(uint8_t pin, uint8_t val);
  1008. static inline void digitalWriteFast(uint8_t pin, uint8_t val) __attribute__((always_inline, unused));
  1009. static inline void digitalWriteFast(uint8_t pin, uint8_t val)
  1010. {
  1011. if (__builtin_constant_p(pin)) {
  1012. if (val) {
  1013. if (pin == 0) {
  1014. CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
  1015. } else if (pin == 1) {
  1016. CORE_PIN1_PORTSET = CORE_PIN1_BITMASK;
  1017. } else if (pin == 2) {
  1018. CORE_PIN2_PORTSET = CORE_PIN2_BITMASK;
  1019. } else if (pin == 3) {
  1020. CORE_PIN3_PORTSET = CORE_PIN3_BITMASK;
  1021. } else if (pin == 4) {
  1022. CORE_PIN4_PORTSET = CORE_PIN4_BITMASK;
  1023. } else if (pin == 5) {
  1024. CORE_PIN5_PORTSET = CORE_PIN5_BITMASK;
  1025. } else if (pin == 6) {
  1026. CORE_PIN6_PORTSET = CORE_PIN6_BITMASK;
  1027. } else if (pin == 7) {
  1028. CORE_PIN7_PORTSET = CORE_PIN7_BITMASK;
  1029. } else if (pin == 8) {
  1030. CORE_PIN8_PORTSET = CORE_PIN8_BITMASK;
  1031. } else if (pin == 9) {
  1032. CORE_PIN9_PORTSET = CORE_PIN9_BITMASK;
  1033. } else if (pin == 10) {
  1034. CORE_PIN10_PORTSET = CORE_PIN10_BITMASK;
  1035. } else if (pin == 11) {
  1036. CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
  1037. } else if (pin == 12) {
  1038. CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
  1039. } else if (pin == 13) {
  1040. CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
  1041. } else if (pin == 14) {
  1042. CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
  1043. } else if (pin == 15) {
  1044. CORE_PIN15_PORTSET = CORE_PIN15_BITMASK;
  1045. } else if (pin == 16) {
  1046. CORE_PIN16_PORTSET = CORE_PIN16_BITMASK;
  1047. } else if (pin == 17) {
  1048. CORE_PIN17_PORTSET = CORE_PIN17_BITMASK;
  1049. } else if (pin == 18) {
  1050. CORE_PIN18_PORTSET = CORE_PIN18_BITMASK;
  1051. } else if (pin == 19) {
  1052. CORE_PIN19_PORTSET = CORE_PIN19_BITMASK;
  1053. } else if (pin == 20) {
  1054. CORE_PIN20_PORTSET = CORE_PIN20_BITMASK;
  1055. } else if (pin == 21) {
  1056. CORE_PIN21_PORTSET = CORE_PIN21_BITMASK;
  1057. } else if (pin == 22) {
  1058. CORE_PIN22_PORTSET = CORE_PIN22_BITMASK;
  1059. } else if (pin == 23) {
  1060. CORE_PIN23_PORTSET = CORE_PIN23_BITMASK;
  1061. } else if (pin == 24) {
  1062. CORE_PIN24_PORTSET = CORE_PIN24_BITMASK;
  1063. } else if (pin == 25) {
  1064. CORE_PIN25_PORTSET = CORE_PIN25_BITMASK;
  1065. } else if (pin == 26) {
  1066. CORE_PIN26_PORTSET = CORE_PIN26_BITMASK;
  1067. } else if (pin == 27) {
  1068. CORE_PIN27_PORTSET = CORE_PIN27_BITMASK;
  1069. } else if (pin == 28) {
  1070. CORE_PIN28_PORTSET = CORE_PIN28_BITMASK;
  1071. } else if (pin == 29) {
  1072. CORE_PIN29_PORTSET = CORE_PIN29_BITMASK;
  1073. } else if (pin == 30) {
  1074. CORE_PIN30_PORTSET = CORE_PIN30_BITMASK;
  1075. } else if (pin == 31) {
  1076. CORE_PIN31_PORTSET = CORE_PIN31_BITMASK;
  1077. } else if (pin == 32) {
  1078. CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
  1079. } else if (pin == 33) {
  1080. CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
  1081. #if defined(__IMXRT1062__)
  1082. } else if (pin == 34) {
  1083. CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
  1084. } else if (pin == 35) {
  1085. CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
  1086. } else if (pin == 36) {
  1087. CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
  1088. } else if (pin == 37) {
  1089. CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
  1090. } else if (pin == 38) {
  1091. CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
  1092. } else if (pin == 39) {
  1093. CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
  1094. #endif
  1095. }
  1096. } else {
  1097. if (pin == 0) {
  1098. CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;
  1099. } else if (pin == 1) {
  1100. CORE_PIN1_PORTCLEAR = CORE_PIN1_BITMASK;
  1101. } else if (pin == 2) {
  1102. CORE_PIN2_PORTCLEAR = CORE_PIN2_BITMASK;
  1103. } else if (pin == 3) {
  1104. CORE_PIN3_PORTCLEAR = CORE_PIN3_BITMASK;
  1105. } else if (pin == 4) {
  1106. CORE_PIN4_PORTCLEAR = CORE_PIN4_BITMASK;
  1107. } else if (pin == 5) {
  1108. CORE_PIN5_PORTCLEAR = CORE_PIN5_BITMASK;
  1109. } else if (pin == 6) {
  1110. CORE_PIN6_PORTCLEAR = CORE_PIN6_BITMASK;
  1111. } else if (pin == 7) {
  1112. CORE_PIN7_PORTCLEAR = CORE_PIN7_BITMASK;
  1113. } else if (pin == 8) {
  1114. CORE_PIN8_PORTCLEAR = CORE_PIN8_BITMASK;
  1115. } else if (pin == 9) {
  1116. CORE_PIN9_PORTCLEAR = CORE_PIN9_BITMASK;
  1117. } else if (pin == 10) {
  1118. CORE_PIN10_PORTCLEAR = CORE_PIN10_BITMASK;
  1119. } else if (pin == 11) {
  1120. CORE_PIN11_PORTCLEAR = CORE_PIN11_BITMASK;
  1121. } else if (pin == 12) {
  1122. CORE_PIN12_PORTCLEAR = CORE_PIN12_BITMASK;
  1123. } else if (pin == 13) {
  1124. CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
  1125. } else if (pin == 14) {
  1126. CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
  1127. } else if (pin == 15) {
  1128. CORE_PIN15_PORTCLEAR = CORE_PIN15_BITMASK;
  1129. } else if (pin == 16) {
  1130. CORE_PIN16_PORTCLEAR = CORE_PIN16_BITMASK;
  1131. } else if (pin == 17) {
  1132. CORE_PIN17_PORTCLEAR = CORE_PIN17_BITMASK;
  1133. } else if (pin == 18) {
  1134. CORE_PIN18_PORTCLEAR = CORE_PIN18_BITMASK;
  1135. } else if (pin == 19) {
  1136. CORE_PIN19_PORTCLEAR = CORE_PIN19_BITMASK;
  1137. } else if (pin == 20) {
  1138. CORE_PIN20_PORTCLEAR = CORE_PIN20_BITMASK;
  1139. } else if (pin == 21) {
  1140. CORE_PIN21_PORTCLEAR = CORE_PIN21_BITMASK;
  1141. } else if (pin == 22) {
  1142. CORE_PIN22_PORTCLEAR = CORE_PIN22_BITMASK;
  1143. } else if (pin == 23) {
  1144. CORE_PIN23_PORTCLEAR = CORE_PIN23_BITMASK;
  1145. } else if (pin == 24) {
  1146. CORE_PIN24_PORTCLEAR = CORE_PIN24_BITMASK;
  1147. } else if (pin == 25) {
  1148. CORE_PIN25_PORTCLEAR = CORE_PIN25_BITMASK;
  1149. } else if (pin == 26) {
  1150. CORE_PIN26_PORTCLEAR = CORE_PIN26_BITMASK;
  1151. } else if (pin == 27) {
  1152. CORE_PIN27_PORTCLEAR = CORE_PIN27_BITMASK;
  1153. } else if (pin == 28) {
  1154. CORE_PIN28_PORTCLEAR = CORE_PIN28_BITMASK;
  1155. } else if (pin == 29) {
  1156. CORE_PIN29_PORTCLEAR = CORE_PIN29_BITMASK;
  1157. } else if (pin == 30) {
  1158. CORE_PIN30_PORTCLEAR = CORE_PIN30_BITMASK;
  1159. } else if (pin == 31) {
  1160. CORE_PIN31_PORTCLEAR = CORE_PIN31_BITMASK;
  1161. } else if (pin == 32) {
  1162. CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
  1163. } else if (pin == 33) {
  1164. CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
  1165. #if defined(__IMXRT1062__)
  1166. } else if (pin == 34) {
  1167. CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
  1168. } else if (pin == 35) {
  1169. CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
  1170. } else if (pin == 36) {
  1171. CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
  1172. } else if (pin == 37) {
  1173. CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
  1174. } else if (pin == 38) {
  1175. CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
  1176. } else if (pin == 39) {
  1177. CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
  1178. #endif
  1179. }
  1180. }
  1181. } else {
  1182. if(val) *portSetRegister(pin) = digitalPinToBitMask(pin);
  1183. else *portClearRegister(pin) = digitalPinToBitMask(pin);
  1184. }
  1185. }
  1186. uint8_t digitalRead(uint8_t pin);
  1187. static inline uint8_t digitalReadFast(uint8_t pin) __attribute__((always_inline, unused));
  1188. static inline uint8_t digitalReadFast(uint8_t pin)
  1189. {
  1190. if (__builtin_constant_p(pin)) {
  1191. if (pin == 0) {
  1192. return (CORE_PIN0_PINREG & CORE_PIN0_BITMASK) ? 1 : 0;
  1193. } else if (pin == 1) {
  1194. return (CORE_PIN1_PINREG & CORE_PIN1_BITMASK) ? 1 : 0;
  1195. } else if (pin == 2) {
  1196. return (CORE_PIN2_PINREG & CORE_PIN2_BITMASK) ? 1 : 0;
  1197. } else if (pin == 3) {
  1198. return (CORE_PIN3_PINREG & CORE_PIN3_BITMASK) ? 1 : 0;
  1199. } else if (pin == 4) {
  1200. return (CORE_PIN4_PINREG & CORE_PIN4_BITMASK) ? 1 : 0;
  1201. } else if (pin == 5) {
  1202. return (CORE_PIN5_PINREG & CORE_PIN5_BITMASK) ? 1 : 0;
  1203. } else if (pin == 6) {
  1204. return (CORE_PIN6_PINREG & CORE_PIN6_BITMASK) ? 1 : 0;
  1205. } else if (pin == 7) {
  1206. return (CORE_PIN7_PINREG & CORE_PIN7_BITMASK) ? 1 : 0;
  1207. } else if (pin == 8) {
  1208. return (CORE_PIN8_PINREG & CORE_PIN8_BITMASK) ? 1 : 0;
  1209. } else if (pin == 9) {
  1210. return (CORE_PIN9_PINREG & CORE_PIN9_BITMASK) ? 1 : 0;
  1211. } else if (pin == 10) {
  1212. return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
  1213. } else if (pin == 11) {
  1214. return (CORE_PIN11_PINREG & CORE_PIN11_BITMASK) ? 1 : 0;
  1215. } else if (pin == 12) {
  1216. return (CORE_PIN12_PINREG & CORE_PIN12_BITMASK) ? 1 : 0;
  1217. } else if (pin == 13) {
  1218. return (CORE_PIN13_PINREG & CORE_PIN13_BITMASK) ? 1 : 0;
  1219. } else if (pin == 14) {
  1220. return (CORE_PIN14_PINREG & CORE_PIN14_BITMASK) ? 1 : 0;
  1221. } else if (pin == 15) {
  1222. return (CORE_PIN15_PINREG & CORE_PIN15_BITMASK) ? 1 : 0;
  1223. } else if (pin == 16) {
  1224. return (CORE_PIN16_PINREG & CORE_PIN16_BITMASK) ? 1 : 0;
  1225. } else if (pin == 17) {
  1226. return (CORE_PIN17_PINREG & CORE_PIN17_BITMASK) ? 1 : 0;
  1227. } else if (pin == 18) {
  1228. return (CORE_PIN18_PINREG & CORE_PIN18_BITMASK) ? 1 : 0;
  1229. } else if (pin == 19) {
  1230. return (CORE_PIN19_PINREG & CORE_PIN19_BITMASK) ? 1 : 0;
  1231. } else if (pin == 20) {
  1232. return (CORE_PIN20_PINREG & CORE_PIN20_BITMASK) ? 1 : 0;
  1233. } else if (pin == 21) {
  1234. return (CORE_PIN21_PINREG & CORE_PIN21_BITMASK) ? 1 : 0;
  1235. } else if (pin == 22) {
  1236. return (CORE_PIN22_PINREG & CORE_PIN22_BITMASK) ? 1 : 0;
  1237. } else if (pin == 23) {
  1238. return (CORE_PIN23_PINREG & CORE_PIN23_BITMASK) ? 1 : 0;
  1239. } else if (pin == 24) {
  1240. return (CORE_PIN24_PINREG & CORE_PIN24_BITMASK) ? 1 : 0;
  1241. } else if (pin == 25) {
  1242. return (CORE_PIN25_PINREG & CORE_PIN25_BITMASK) ? 1 : 0;
  1243. } else if (pin == 26) {
  1244. return (CORE_PIN26_PINREG & CORE_PIN26_BITMASK) ? 1 : 0;
  1245. } else if (pin == 27) {
  1246. return (CORE_PIN27_PINREG & CORE_PIN27_BITMASK) ? 1 : 0;
  1247. } else if (pin == 28) {
  1248. return (CORE_PIN28_PINREG & CORE_PIN28_BITMASK) ? 1 : 0;
  1249. } else if (pin == 29) {
  1250. return (CORE_PIN29_PINREG & CORE_PIN29_BITMASK) ? 1 : 0;
  1251. } else if (pin == 30) {
  1252. return (CORE_PIN30_PINREG & CORE_PIN30_BITMASK) ? 1 : 0;
  1253. } else if (pin == 31) {
  1254. return (CORE_PIN31_PINREG & CORE_PIN31_BITMASK) ? 1 : 0;
  1255. } else if (pin == 32) {
  1256. return (CORE_PIN32_PINREG & CORE_PIN32_BITMASK) ? 1 : 0;
  1257. } else if (pin == 33) {
  1258. return (CORE_PIN33_PINREG & CORE_PIN33_BITMASK) ? 1 : 0;
  1259. } else {
  1260. return 0;
  1261. }
  1262. } else {
  1263. return (*portInputRegister(pin) & digitalPinToBitMask(pin)) ? 1 : 0;
  1264. }
  1265. }
  1266. void pinMode(uint8_t pin, uint8_t mode);
  1267. void init_pins(void);
  1268. void analogWrite(uint8_t pin, int val);
  1269. uint32_t analogWriteRes(uint32_t bits);
  1270. static inline uint32_t analogWriteResolution(uint32_t bits) { return analogWriteRes(bits); }
  1271. void analogWriteFrequency(uint8_t pin, float frequency);
  1272. void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
  1273. void detachInterrupt(uint8_t pin);
  1274. void _init_Teensyduino_internal_(void);
  1275. int analogRead(uint8_t pin);
  1276. void analogReference(uint8_t type);
  1277. void analogReadRes(unsigned int bits);
  1278. static inline void analogReadResolution(unsigned int bits) { analogReadRes(bits); }
  1279. void analogReadAveraging(unsigned int num);
  1280. void analog_init(void);
  1281. int touchRead(uint8_t pin);
  1282. static inline void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1283. extern void _shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) __attribute__((noinline));
  1284. extern void shiftOut_lsbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1285. extern void shiftOut_msbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1286. static inline void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
  1287. {
  1288. if (__builtin_constant_p(bitOrder)) {
  1289. if (bitOrder == LSBFIRST) {
  1290. shiftOut_lsbFirst(dataPin, clockPin, value);
  1291. } else {
  1292. shiftOut_msbFirst(dataPin, clockPin, value);
  1293. }
  1294. } else {
  1295. _shiftOut(dataPin, clockPin, bitOrder, value);
  1296. }
  1297. }
  1298. static inline uint8_t shiftIn(uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1299. extern uint8_t _shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) __attribute__((noinline));
  1300. extern uint8_t shiftIn_lsbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1301. extern uint8_t shiftIn_msbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1302. static inline uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
  1303. {
  1304. if (__builtin_constant_p(bitOrder)) {
  1305. if (bitOrder == LSBFIRST) {
  1306. return shiftIn_lsbFirst(dataPin, clockPin);
  1307. } else {
  1308. return shiftIn_msbFirst(dataPin, clockPin);
  1309. }
  1310. } else {
  1311. return _shiftIn(dataPin, clockPin, bitOrder);
  1312. }
  1313. }
  1314. void _reboot_Teensyduino_(void) __attribute__((noreturn));
  1315. void _restart_Teensyduino_(void) __attribute__((noreturn));
  1316. void yield(void);
  1317. void delay(uint32_t msec);
  1318. extern volatile uint32_t F_CPU_ACTUAL;
  1319. extern volatile uint32_t F_BUS_ACTUAL;
  1320. extern volatile uint32_t scale_cpu_cycles_to_microseconds;
  1321. extern volatile uint32_t systick_millis_count;
  1322. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  1323. static inline uint32_t millis(void)
  1324. {
  1325. return systick_millis_count;
  1326. }
  1327. uint32_t micros(void);
  1328. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  1329. static inline void delayMicroseconds(uint32_t usec)
  1330. {
  1331. uint32_t begin = ARM_DWT_CYCCNT;
  1332. uint32_t cycles = F_CPU_ACTUAL / 1000000 * usec;
  1333. // TODO: check if cycles is large, do a wait with yield calls until it's smaller
  1334. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1335. }
  1336. static inline void delayNanoseconds(uint32_t) __attribute__((always_inline, unused));
  1337. static inline void delayNanoseconds(uint32_t nsec)
  1338. {
  1339. uint32_t begin = ARM_DWT_CYCCNT;
  1340. uint32_t cycles = ((F_CPU_ACTUAL>>16) * nsec) / (1000000000UL>>16);
  1341. while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
  1342. }
  1343. unsigned long rtc_get(void);
  1344. void rtc_set(unsigned long t);
  1345. void rtc_compensate(int adjust);
  1346. void tempmon_init(void);
  1347. float tempmonGetTemp(void);
  1348. void tempmon_Start();
  1349. void tempmon_Stop();
  1350. void tempmon_PwrDwn();
  1351. #ifdef __cplusplus
  1352. }
  1353. class teensy3_clock_class
  1354. {
  1355. public:
  1356. static unsigned long get(void) __attribute__((always_inline)) { return rtc_get(); }
  1357. static void set(unsigned long t) __attribute__((always_inline)) { rtc_set(t); }
  1358. static void compensate(int adj) __attribute__((always_inline)) { rtc_compensate(adj); }
  1359. };
  1360. extern teensy3_clock_class Teensy3Clock;
  1361. #endif // __cplusplus