Teensy 4.1 core updated for C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

core_pins.h 55KB

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