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.

1840 lines
69KB

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