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 63KB

8 years ago
8 years ago
8 years ago
8 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 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. #ifndef _core_pins_h_
  31. #define _core_pins_h_
  32. #include "kinetis.h"
  33. #include "pins_arduino.h"
  34. #define HIGH 1
  35. #define LOW 0
  36. #define INPUT 0
  37. #define OUTPUT 1
  38. #define INPUT_PULLUP 2
  39. #define INPUT_PULLDOWN 3
  40. #define OUTPUT_OPENDRAIN 4
  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. // Pin Arduino
  48. // 0 B16 RXD
  49. // 1 B17 TXD
  50. // 2 D0
  51. // 3 A12 FTM1_CH0
  52. // 4 A13 FTM1_CH1
  53. // 5 D7 FTM0_CH7 OC0B/T1
  54. // 6 D4 FTM0_CH4 OC0A
  55. // 7 D2
  56. // 8 D3 ICP1
  57. // 9 C3 FTM0_CH2 OC1A
  58. // 10 C4 FTM0_CH3 SS/OC1B
  59. // 11 C6 MOSI/OC2A
  60. // 12 C7 MISO
  61. // 13 C5 SCK
  62. // 14 D1
  63. // 15 C0
  64. // 16 B0 (FTM1_CH0)
  65. // 17 B1 (FTM1_CH1)
  66. // 18 B3 SDA
  67. // 19 B2 SCL
  68. // 20 D5 FTM0_CH5
  69. // 21 D6 FTM0_CH6
  70. // 22 C1 FTM0_CH0
  71. // 23 C2 FTM0_CH1
  72. // 24 A5 (FTM0_CH2)
  73. // 25 B19
  74. // 26 E1
  75. // 27 C9
  76. // 28 C8
  77. // 29 C10
  78. // 30 C11
  79. // 31 E0
  80. // 32 B18
  81. // 33 A4 (FTM0_CH1)
  82. // (34) analog only
  83. // (35) analog only
  84. // (36) analog only
  85. // (37) analog only
  86. // not available to user:
  87. // A0 FTM0_CH5 SWD Clock
  88. // A1 FTM0_CH6 USB ID
  89. // A2 FTM0_CH7 SWD Trace
  90. // A3 FTM0_CH0 SWD Data
  91. #if defined(__MK20DX128__)
  92. #define CORE_NUM_TOTAL_PINS 34
  93. #define CORE_NUM_DIGITAL 34
  94. #define CORE_NUM_INTERRUPT 34
  95. #define CORE_NUM_ANALOG 14
  96. #define CORE_NUM_PWM 10
  97. #elif defined(__MK20DX256__)
  98. #define CORE_NUM_TOTAL_PINS 34
  99. #define CORE_NUM_DIGITAL 34
  100. #define CORE_NUM_INTERRUPT 34
  101. #define CORE_NUM_ANALOG 21
  102. #define CORE_NUM_PWM 12
  103. #elif defined(__MKL26Z64__)
  104. #define CORE_NUM_TOTAL_PINS 27
  105. #define CORE_NUM_DIGITAL 27
  106. #define CORE_NUM_INTERRUPT 24 // really only 18, but 6 "holes"
  107. #define CORE_NUM_ANALOG 13
  108. #define CORE_NUM_PWM 10
  109. #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
  110. #define CORE_NUM_TOTAL_PINS 58
  111. #define CORE_NUM_DIGITAL 58
  112. #define CORE_NUM_INTERRUPT 58
  113. #define CORE_NUM_ANALOG 23
  114. #define CORE_NUM_PWM 20
  115. #endif
  116. #if defined(__MK20DX128__) || defined(__MK20DX256__)
  117. #define CORE_PIN0_BIT 16
  118. #define CORE_PIN1_BIT 17
  119. #define CORE_PIN2_BIT 0
  120. #define CORE_PIN3_BIT 12
  121. #define CORE_PIN4_BIT 13
  122. #define CORE_PIN5_BIT 7
  123. #define CORE_PIN6_BIT 4
  124. #define CORE_PIN7_BIT 2
  125. #define CORE_PIN8_BIT 3
  126. #define CORE_PIN9_BIT 3
  127. #define CORE_PIN10_BIT 4
  128. #define CORE_PIN11_BIT 6
  129. #define CORE_PIN12_BIT 7
  130. #define CORE_PIN13_BIT 5
  131. #define CORE_PIN14_BIT 1
  132. #define CORE_PIN15_BIT 0
  133. #define CORE_PIN16_BIT 0
  134. #define CORE_PIN17_BIT 1
  135. #define CORE_PIN18_BIT 3
  136. #define CORE_PIN19_BIT 2
  137. #define CORE_PIN20_BIT 5
  138. #define CORE_PIN21_BIT 6
  139. #define CORE_PIN22_BIT 1
  140. #define CORE_PIN23_BIT 2
  141. #define CORE_PIN24_BIT 5
  142. #define CORE_PIN25_BIT 19
  143. #define CORE_PIN26_BIT 1
  144. #define CORE_PIN27_BIT 9
  145. #define CORE_PIN28_BIT 8
  146. #define CORE_PIN29_BIT 10
  147. #define CORE_PIN30_BIT 11
  148. #define CORE_PIN31_BIT 0
  149. #define CORE_PIN32_BIT 18
  150. #define CORE_PIN33_BIT 4
  151. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  152. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  153. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  154. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  155. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  156. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  157. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  158. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  159. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  160. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  161. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  162. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  163. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  164. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  165. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  166. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  167. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  168. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  169. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  170. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  171. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  172. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  173. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  174. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  175. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  176. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  177. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  178. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  179. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  180. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  181. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  182. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  183. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  184. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  185. #define CORE_PIN0_PORTREG GPIOB_PDOR
  186. #define CORE_PIN1_PORTREG GPIOB_PDOR
  187. #define CORE_PIN2_PORTREG GPIOD_PDOR
  188. #define CORE_PIN3_PORTREG GPIOA_PDOR
  189. #define CORE_PIN4_PORTREG GPIOA_PDOR
  190. #define CORE_PIN5_PORTREG GPIOD_PDOR
  191. #define CORE_PIN6_PORTREG GPIOD_PDOR
  192. #define CORE_PIN7_PORTREG GPIOD_PDOR
  193. #define CORE_PIN8_PORTREG GPIOD_PDOR
  194. #define CORE_PIN9_PORTREG GPIOC_PDOR
  195. #define CORE_PIN10_PORTREG GPIOC_PDOR
  196. #define CORE_PIN11_PORTREG GPIOC_PDOR
  197. #define CORE_PIN12_PORTREG GPIOC_PDOR
  198. #define CORE_PIN13_PORTREG GPIOC_PDOR
  199. #define CORE_PIN14_PORTREG GPIOD_PDOR
  200. #define CORE_PIN15_PORTREG GPIOC_PDOR
  201. #define CORE_PIN16_PORTREG GPIOB_PDOR
  202. #define CORE_PIN17_PORTREG GPIOB_PDOR
  203. #define CORE_PIN18_PORTREG GPIOB_PDOR
  204. #define CORE_PIN19_PORTREG GPIOB_PDOR
  205. #define CORE_PIN20_PORTREG GPIOD_PDOR
  206. #define CORE_PIN21_PORTREG GPIOD_PDOR
  207. #define CORE_PIN22_PORTREG GPIOC_PDOR
  208. #define CORE_PIN23_PORTREG GPIOC_PDOR
  209. #define CORE_PIN24_PORTREG GPIOA_PDOR
  210. #define CORE_PIN25_PORTREG GPIOB_PDOR
  211. #define CORE_PIN26_PORTREG GPIOE_PDOR
  212. #define CORE_PIN27_PORTREG GPIOC_PDOR
  213. #define CORE_PIN28_PORTREG GPIOC_PDOR
  214. #define CORE_PIN29_PORTREG GPIOC_PDOR
  215. #define CORE_PIN30_PORTREG GPIOC_PDOR
  216. #define CORE_PIN31_PORTREG GPIOE_PDOR
  217. #define CORE_PIN32_PORTREG GPIOB_PDOR
  218. #define CORE_PIN33_PORTREG GPIOA_PDOR
  219. #define CORE_PIN0_PORTSET GPIOB_PSOR
  220. #define CORE_PIN1_PORTSET GPIOB_PSOR
  221. #define CORE_PIN2_PORTSET GPIOD_PSOR
  222. #define CORE_PIN3_PORTSET GPIOA_PSOR
  223. #define CORE_PIN4_PORTSET GPIOA_PSOR
  224. #define CORE_PIN5_PORTSET GPIOD_PSOR
  225. #define CORE_PIN6_PORTSET GPIOD_PSOR
  226. #define CORE_PIN7_PORTSET GPIOD_PSOR
  227. #define CORE_PIN8_PORTSET GPIOD_PSOR
  228. #define CORE_PIN9_PORTSET GPIOC_PSOR
  229. #define CORE_PIN10_PORTSET GPIOC_PSOR
  230. #define CORE_PIN11_PORTSET GPIOC_PSOR
  231. #define CORE_PIN12_PORTSET GPIOC_PSOR
  232. #define CORE_PIN13_PORTSET GPIOC_PSOR
  233. #define CORE_PIN14_PORTSET GPIOD_PSOR
  234. #define CORE_PIN15_PORTSET GPIOC_PSOR
  235. #define CORE_PIN16_PORTSET GPIOB_PSOR
  236. #define CORE_PIN17_PORTSET GPIOB_PSOR
  237. #define CORE_PIN18_PORTSET GPIOB_PSOR
  238. #define CORE_PIN19_PORTSET GPIOB_PSOR
  239. #define CORE_PIN20_PORTSET GPIOD_PSOR
  240. #define CORE_PIN21_PORTSET GPIOD_PSOR
  241. #define CORE_PIN22_PORTSET GPIOC_PSOR
  242. #define CORE_PIN23_PORTSET GPIOC_PSOR
  243. #define CORE_PIN24_PORTSET GPIOA_PSOR
  244. #define CORE_PIN25_PORTSET GPIOB_PSOR
  245. #define CORE_PIN26_PORTSET GPIOE_PSOR
  246. #define CORE_PIN27_PORTSET GPIOC_PSOR
  247. #define CORE_PIN28_PORTSET GPIOC_PSOR
  248. #define CORE_PIN29_PORTSET GPIOC_PSOR
  249. #define CORE_PIN30_PORTSET GPIOC_PSOR
  250. #define CORE_PIN31_PORTSET GPIOE_PSOR
  251. #define CORE_PIN32_PORTSET GPIOB_PSOR
  252. #define CORE_PIN33_PORTSET GPIOA_PSOR
  253. #define CORE_PIN0_PORTCLEAR GPIOB_PCOR
  254. #define CORE_PIN1_PORTCLEAR GPIOB_PCOR
  255. #define CORE_PIN2_PORTCLEAR GPIOD_PCOR
  256. #define CORE_PIN3_PORTCLEAR GPIOA_PCOR
  257. #define CORE_PIN4_PORTCLEAR GPIOA_PCOR
  258. #define CORE_PIN5_PORTCLEAR GPIOD_PCOR
  259. #define CORE_PIN6_PORTCLEAR GPIOD_PCOR
  260. #define CORE_PIN7_PORTCLEAR GPIOD_PCOR
  261. #define CORE_PIN8_PORTCLEAR GPIOD_PCOR
  262. #define CORE_PIN9_PORTCLEAR GPIOC_PCOR
  263. #define CORE_PIN10_PORTCLEAR GPIOC_PCOR
  264. #define CORE_PIN11_PORTCLEAR GPIOC_PCOR
  265. #define CORE_PIN12_PORTCLEAR GPIOC_PCOR
  266. #define CORE_PIN13_PORTCLEAR GPIOC_PCOR
  267. #define CORE_PIN14_PORTCLEAR GPIOD_PCOR
  268. #define CORE_PIN15_PORTCLEAR GPIOC_PCOR
  269. #define CORE_PIN16_PORTCLEAR GPIOB_PCOR
  270. #define CORE_PIN17_PORTCLEAR GPIOB_PCOR
  271. #define CORE_PIN18_PORTCLEAR GPIOB_PCOR
  272. #define CORE_PIN19_PORTCLEAR GPIOB_PCOR
  273. #define CORE_PIN20_PORTCLEAR GPIOD_PCOR
  274. #define CORE_PIN21_PORTCLEAR GPIOD_PCOR
  275. #define CORE_PIN22_PORTCLEAR GPIOC_PCOR
  276. #define CORE_PIN23_PORTCLEAR GPIOC_PCOR
  277. #define CORE_PIN24_PORTCLEAR GPIOA_PCOR
  278. #define CORE_PIN25_PORTCLEAR GPIOB_PCOR
  279. #define CORE_PIN26_PORTCLEAR GPIOE_PCOR
  280. #define CORE_PIN27_PORTCLEAR GPIOC_PCOR
  281. #define CORE_PIN28_PORTCLEAR GPIOC_PCOR
  282. #define CORE_PIN29_PORTCLEAR GPIOC_PCOR
  283. #define CORE_PIN30_PORTCLEAR GPIOC_PCOR
  284. #define CORE_PIN31_PORTCLEAR GPIOE_PCOR
  285. #define CORE_PIN32_PORTCLEAR GPIOB_PCOR
  286. #define CORE_PIN33_PORTCLEAR GPIOA_PCOR
  287. #define CORE_PIN0_DDRREG GPIOB_PDDR
  288. #define CORE_PIN1_DDRREG GPIOB_PDDR
  289. #define CORE_PIN2_DDRREG GPIOD_PDDR
  290. #define CORE_PIN3_DDRREG GPIOA_PDDR
  291. #define CORE_PIN4_DDRREG GPIOA_PDDR
  292. #define CORE_PIN5_DDRREG GPIOD_PDDR
  293. #define CORE_PIN6_DDRREG GPIOD_PDDR
  294. #define CORE_PIN7_DDRREG GPIOD_PDDR
  295. #define CORE_PIN8_DDRREG GPIOD_PDDR
  296. #define CORE_PIN9_DDRREG GPIOC_PDDR
  297. #define CORE_PIN10_DDRREG GPIOC_PDDR
  298. #define CORE_PIN11_DDRREG GPIOC_PDDR
  299. #define CORE_PIN12_DDRREG GPIOC_PDDR
  300. #define CORE_PIN13_DDRREG GPIOC_PDDR
  301. #define CORE_PIN14_DDRREG GPIOD_PDDR
  302. #define CORE_PIN15_DDRREG GPIOC_PDDR
  303. #define CORE_PIN16_DDRREG GPIOB_PDDR
  304. #define CORE_PIN17_DDRREG GPIOB_PDDR
  305. #define CORE_PIN18_DDRREG GPIOB_PDDR
  306. #define CORE_PIN19_DDRREG GPIOB_PDDR
  307. #define CORE_PIN20_DDRREG GPIOD_PDDR
  308. #define CORE_PIN21_DDRREG GPIOD_PDDR
  309. #define CORE_PIN22_DDRREG GPIOC_PDDR
  310. #define CORE_PIN23_DDRREG GPIOC_PDDR
  311. #define CORE_PIN24_DDRREG GPIOA_PDDR
  312. #define CORE_PIN25_DDRREG GPIOB_PDDR
  313. #define CORE_PIN26_DDRREG GPIOE_PDDR
  314. #define CORE_PIN27_DDRREG GPIOC_PDDR
  315. #define CORE_PIN28_DDRREG GPIOC_PDDR
  316. #define CORE_PIN29_DDRREG GPIOC_PDDR
  317. #define CORE_PIN30_DDRREG GPIOC_PDDR
  318. #define CORE_PIN31_DDRREG GPIOE_PDDR
  319. #define CORE_PIN32_DDRREG GPIOB_PDDR
  320. #define CORE_PIN33_DDRREG GPIOA_PDDR
  321. #define CORE_PIN0_PINREG GPIOB_PDIR
  322. #define CORE_PIN1_PINREG GPIOB_PDIR
  323. #define CORE_PIN2_PINREG GPIOD_PDIR
  324. #define CORE_PIN3_PINREG GPIOA_PDIR
  325. #define CORE_PIN4_PINREG GPIOA_PDIR
  326. #define CORE_PIN5_PINREG GPIOD_PDIR
  327. #define CORE_PIN6_PINREG GPIOD_PDIR
  328. #define CORE_PIN7_PINREG GPIOD_PDIR
  329. #define CORE_PIN8_PINREG GPIOD_PDIR
  330. #define CORE_PIN9_PINREG GPIOC_PDIR
  331. #define CORE_PIN10_PINREG GPIOC_PDIR
  332. #define CORE_PIN11_PINREG GPIOC_PDIR
  333. #define CORE_PIN12_PINREG GPIOC_PDIR
  334. #define CORE_PIN13_PINREG GPIOC_PDIR
  335. #define CORE_PIN14_PINREG GPIOD_PDIR
  336. #define CORE_PIN15_PINREG GPIOC_PDIR
  337. #define CORE_PIN16_PINREG GPIOB_PDIR
  338. #define CORE_PIN17_PINREG GPIOB_PDIR
  339. #define CORE_PIN18_PINREG GPIOB_PDIR
  340. #define CORE_PIN19_PINREG GPIOB_PDIR
  341. #define CORE_PIN20_PINREG GPIOD_PDIR
  342. #define CORE_PIN21_PINREG GPIOD_PDIR
  343. #define CORE_PIN22_PINREG GPIOC_PDIR
  344. #define CORE_PIN23_PINREG GPIOC_PDIR
  345. #define CORE_PIN24_PINREG GPIOA_PDIR
  346. #define CORE_PIN25_PINREG GPIOB_PDIR
  347. #define CORE_PIN26_PINREG GPIOE_PDIR
  348. #define CORE_PIN27_PINREG GPIOC_PDIR
  349. #define CORE_PIN28_PINREG GPIOC_PDIR
  350. #define CORE_PIN29_PINREG GPIOC_PDIR
  351. #define CORE_PIN30_PINREG GPIOC_PDIR
  352. #define CORE_PIN31_PINREG GPIOE_PDIR
  353. #define CORE_PIN32_PINREG GPIOB_PDIR
  354. #define CORE_PIN33_PINREG GPIOA_PDIR
  355. #define CORE_PIN0_CONFIG PORTB_PCR16
  356. #define CORE_PIN1_CONFIG PORTB_PCR17
  357. #define CORE_PIN2_CONFIG PORTD_PCR0
  358. #define CORE_PIN3_CONFIG PORTA_PCR12
  359. #define CORE_PIN4_CONFIG PORTA_PCR13
  360. #define CORE_PIN5_CONFIG PORTD_PCR7
  361. #define CORE_PIN6_CONFIG PORTD_PCR4
  362. #define CORE_PIN7_CONFIG PORTD_PCR2
  363. #define CORE_PIN8_CONFIG PORTD_PCR3
  364. #define CORE_PIN9_CONFIG PORTC_PCR3
  365. #define CORE_PIN10_CONFIG PORTC_PCR4
  366. #define CORE_PIN11_CONFIG PORTC_PCR6
  367. #define CORE_PIN12_CONFIG PORTC_PCR7
  368. #define CORE_PIN13_CONFIG PORTC_PCR5
  369. #define CORE_PIN14_CONFIG PORTD_PCR1
  370. #define CORE_PIN15_CONFIG PORTC_PCR0
  371. #define CORE_PIN16_CONFIG PORTB_PCR0
  372. #define CORE_PIN17_CONFIG PORTB_PCR1
  373. #define CORE_PIN18_CONFIG PORTB_PCR3
  374. #define CORE_PIN19_CONFIG PORTB_PCR2
  375. #define CORE_PIN20_CONFIG PORTD_PCR5
  376. #define CORE_PIN21_CONFIG PORTD_PCR6
  377. #define CORE_PIN22_CONFIG PORTC_PCR1
  378. #define CORE_PIN23_CONFIG PORTC_PCR2
  379. #define CORE_PIN24_CONFIG PORTA_PCR5
  380. #define CORE_PIN25_CONFIG PORTB_PCR19
  381. #define CORE_PIN26_CONFIG PORTE_PCR1
  382. #define CORE_PIN27_CONFIG PORTC_PCR9
  383. #define CORE_PIN28_CONFIG PORTC_PCR8
  384. #define CORE_PIN29_CONFIG PORTC_PCR10
  385. #define CORE_PIN30_CONFIG PORTC_PCR11
  386. #define CORE_PIN31_CONFIG PORTE_PCR0
  387. #define CORE_PIN32_CONFIG PORTB_PCR18
  388. #define CORE_PIN33_CONFIG PORTA_PCR4
  389. #define CORE_ADC0_PIN 14
  390. #define CORE_ADC1_PIN 15
  391. #define CORE_ADC2_PIN 16
  392. #define CORE_ADC3_PIN 17
  393. #define CORE_ADC4_PIN 18
  394. #define CORE_ADC5_PIN 19
  395. #define CORE_ADC6_PIN 20
  396. #define CORE_ADC7_PIN 21
  397. #define CORE_ADC8_PIN 22
  398. #define CORE_ADC9_PIN 23
  399. #define CORE_ADC10_PIN 34
  400. #define CORE_ADC11_PIN 35
  401. #define CORE_ADC12_PIN 36
  402. #define CORE_ADC13_PIN 37
  403. #define CORE_RXD0_PIN 0
  404. #define CORE_TXD0_PIN 1
  405. #define CORE_RXD1_PIN 9
  406. #define CORE_TXD1_PIN 10
  407. #define CORE_RXD2_PIN 7
  408. #define CORE_TXD2_PIN 8
  409. #define CORE_INT0_PIN 0
  410. #define CORE_INT1_PIN 1
  411. #define CORE_INT2_PIN 2
  412. #define CORE_INT3_PIN 3
  413. #define CORE_INT4_PIN 4
  414. #define CORE_INT5_PIN 5
  415. #define CORE_INT6_PIN 6
  416. #define CORE_INT7_PIN 7
  417. #define CORE_INT8_PIN 8
  418. #define CORE_INT9_PIN 9
  419. #define CORE_INT10_PIN 10
  420. #define CORE_INT11_PIN 11
  421. #define CORE_INT12_PIN 12
  422. #define CORE_INT13_PIN 13
  423. #define CORE_INT14_PIN 14
  424. #define CORE_INT15_PIN 15
  425. #define CORE_INT16_PIN 16
  426. #define CORE_INT17_PIN 17
  427. #define CORE_INT18_PIN 18
  428. #define CORE_INT19_PIN 19
  429. #define CORE_INT20_PIN 20
  430. #define CORE_INT21_PIN 21
  431. #define CORE_INT22_PIN 22
  432. #define CORE_INT23_PIN 23
  433. #define CORE_INT24_PIN 24
  434. #define CORE_INT25_PIN 25
  435. #define CORE_INT26_PIN 26
  436. #define CORE_INT27_PIN 27
  437. #define CORE_INT28_PIN 28
  438. #define CORE_INT29_PIN 29
  439. #define CORE_INT30_PIN 30
  440. #define CORE_INT31_PIN 31
  441. #define CORE_INT32_PIN 32
  442. #define CORE_INT33_PIN 33
  443. #define CORE_INT_EVERY_PIN 1
  444. #elif defined(__MKL26Z64__)
  445. #define CORE_PIN0_BIT 16
  446. #define CORE_PIN1_BIT 17
  447. #define CORE_PIN2_BIT 0
  448. #define CORE_PIN3_BIT 1
  449. #define CORE_PIN4_BIT 2
  450. #define CORE_PIN5_BIT 7
  451. #define CORE_PIN6_BIT 4
  452. #define CORE_PIN7_BIT 2
  453. #define CORE_PIN8_BIT 3
  454. #define CORE_PIN9_BIT 3
  455. #define CORE_PIN10_BIT 4
  456. #define CORE_PIN11_BIT 6
  457. #define CORE_PIN12_BIT 7
  458. #define CORE_PIN13_BIT 5
  459. #define CORE_PIN14_BIT 1
  460. #define CORE_PIN15_BIT 0
  461. #define CORE_PIN16_BIT 0
  462. #define CORE_PIN17_BIT 1
  463. #define CORE_PIN18_BIT 3
  464. #define CORE_PIN19_BIT 2
  465. #define CORE_PIN20_BIT 5
  466. #define CORE_PIN21_BIT 6
  467. #define CORE_PIN22_BIT 1
  468. #define CORE_PIN23_BIT 2
  469. #define CORE_PIN24_BIT 20
  470. #define CORE_PIN25_BIT 21
  471. #define CORE_PIN26_BIT 30
  472. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  473. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  474. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  475. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  476. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  477. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  478. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  479. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  480. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  481. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  482. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  483. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  484. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  485. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  486. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  487. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  488. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  489. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  490. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  491. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  492. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  493. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  494. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  495. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  496. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  497. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  498. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  499. #define CORE_PIN0_PORTREG FGPIOB_PDOR
  500. #define CORE_PIN1_PORTREG FGPIOB_PDOR
  501. #define CORE_PIN2_PORTREG FGPIOD_PDOR
  502. #define CORE_PIN3_PORTREG FGPIOA_PDOR
  503. #define CORE_PIN4_PORTREG FGPIOA_PDOR
  504. #define CORE_PIN5_PORTREG FGPIOD_PDOR
  505. #define CORE_PIN6_PORTREG FGPIOD_PDOR
  506. #define CORE_PIN7_PORTREG FGPIOD_PDOR
  507. #define CORE_PIN8_PORTREG FGPIOD_PDOR
  508. #define CORE_PIN9_PORTREG FGPIOC_PDOR
  509. #define CORE_PIN10_PORTREG FGPIOC_PDOR
  510. #define CORE_PIN11_PORTREG FGPIOC_PDOR
  511. #define CORE_PIN12_PORTREG FGPIOC_PDOR
  512. #define CORE_PIN13_PORTREG FGPIOC_PDOR
  513. #define CORE_PIN14_PORTREG FGPIOD_PDOR
  514. #define CORE_PIN15_PORTREG FGPIOC_PDOR
  515. #define CORE_PIN16_PORTREG FGPIOB_PDOR
  516. #define CORE_PIN17_PORTREG FGPIOB_PDOR
  517. #define CORE_PIN18_PORTREG FGPIOB_PDOR
  518. #define CORE_PIN19_PORTREG FGPIOB_PDOR
  519. #define CORE_PIN20_PORTREG FGPIOD_PDOR
  520. #define CORE_PIN21_PORTREG FGPIOD_PDOR
  521. #define CORE_PIN22_PORTREG FGPIOC_PDOR
  522. #define CORE_PIN23_PORTREG FGPIOC_PDOR
  523. #define CORE_PIN24_PORTREG FGPIOE_PDOR
  524. #define CORE_PIN25_PORTREG FGPIOE_PDOR
  525. #define CORE_PIN26_PORTREG FGPIOE_PDOR
  526. #define CORE_PIN0_PORTSET FGPIOB_PSOR
  527. #define CORE_PIN1_PORTSET FGPIOB_PSOR
  528. #define CORE_PIN2_PORTSET FGPIOD_PSOR
  529. #define CORE_PIN3_PORTSET FGPIOA_PSOR
  530. #define CORE_PIN4_PORTSET FGPIOA_PSOR
  531. #define CORE_PIN5_PORTSET FGPIOD_PSOR
  532. #define CORE_PIN6_PORTSET FGPIOD_PSOR
  533. #define CORE_PIN7_PORTSET FGPIOD_PSOR
  534. #define CORE_PIN8_PORTSET FGPIOD_PSOR
  535. #define CORE_PIN9_PORTSET FGPIOC_PSOR
  536. #define CORE_PIN10_PORTSET FGPIOC_PSOR
  537. #define CORE_PIN11_PORTSET FGPIOC_PSOR
  538. #define CORE_PIN12_PORTSET FGPIOC_PSOR
  539. #define CORE_PIN13_PORTSET FGPIOC_PSOR
  540. #define CORE_PIN14_PORTSET FGPIOD_PSOR
  541. #define CORE_PIN15_PORTSET FGPIOC_PSOR
  542. #define CORE_PIN16_PORTSET FGPIOB_PSOR
  543. #define CORE_PIN17_PORTSET FGPIOB_PSOR
  544. #define CORE_PIN18_PORTSET FGPIOB_PSOR
  545. #define CORE_PIN19_PORTSET FGPIOB_PSOR
  546. #define CORE_PIN20_PORTSET FGPIOD_PSOR
  547. #define CORE_PIN21_PORTSET FGPIOD_PSOR
  548. #define CORE_PIN22_PORTSET FGPIOC_PSOR
  549. #define CORE_PIN23_PORTSET FGPIOC_PSOR
  550. #define CORE_PIN24_PORTSET FGPIOE_PSOR
  551. #define CORE_PIN25_PORTSET FGPIOE_PSOR
  552. #define CORE_PIN26_PORTSET FGPIOE_PSOR
  553. #define CORE_PIN0_PORTCLEAR FGPIOB_PCOR
  554. #define CORE_PIN1_PORTCLEAR FGPIOB_PCOR
  555. #define CORE_PIN2_PORTCLEAR FGPIOD_PCOR
  556. #define CORE_PIN3_PORTCLEAR FGPIOA_PCOR
  557. #define CORE_PIN4_PORTCLEAR FGPIOA_PCOR
  558. #define CORE_PIN5_PORTCLEAR FGPIOD_PCOR
  559. #define CORE_PIN6_PORTCLEAR FGPIOD_PCOR
  560. #define CORE_PIN7_PORTCLEAR FGPIOD_PCOR
  561. #define CORE_PIN8_PORTCLEAR FGPIOD_PCOR
  562. #define CORE_PIN9_PORTCLEAR FGPIOC_PCOR
  563. #define CORE_PIN10_PORTCLEAR FGPIOC_PCOR
  564. #define CORE_PIN11_PORTCLEAR FGPIOC_PCOR
  565. #define CORE_PIN12_PORTCLEAR FGPIOC_PCOR
  566. #define CORE_PIN13_PORTCLEAR FGPIOC_PCOR
  567. #define CORE_PIN14_PORTCLEAR FGPIOD_PCOR
  568. #define CORE_PIN15_PORTCLEAR FGPIOC_PCOR
  569. #define CORE_PIN16_PORTCLEAR FGPIOB_PCOR
  570. #define CORE_PIN17_PORTCLEAR FGPIOB_PCOR
  571. #define CORE_PIN18_PORTCLEAR FGPIOB_PCOR
  572. #define CORE_PIN19_PORTCLEAR FGPIOB_PCOR
  573. #define CORE_PIN20_PORTCLEAR FGPIOD_PCOR
  574. #define CORE_PIN21_PORTCLEAR FGPIOD_PCOR
  575. #define CORE_PIN22_PORTCLEAR FGPIOC_PCOR
  576. #define CORE_PIN23_PORTCLEAR FGPIOC_PCOR
  577. #define CORE_PIN24_PORTCLEAR FGPIOE_PCOR
  578. #define CORE_PIN25_PORTCLEAR FGPIOE_PCOR
  579. #define CORE_PIN26_PORTCLEAR FGPIOE_PCOR
  580. #define CORE_PIN0_DDRREG FGPIOB_PDDR
  581. #define CORE_PIN1_DDRREG FGPIOB_PDDR
  582. #define CORE_PIN2_DDRREG FGPIOD_PDDR
  583. #define CORE_PIN3_DDRREG FGPIOA_PDDR
  584. #define CORE_PIN4_DDRREG FGPIOA_PDDR
  585. #define CORE_PIN5_DDRREG FGPIOD_PDDR
  586. #define CORE_PIN6_DDRREG FGPIOD_PDDR
  587. #define CORE_PIN7_DDRREG FGPIOD_PDDR
  588. #define CORE_PIN8_DDRREG FGPIOD_PDDR
  589. #define CORE_PIN9_DDRREG FGPIOC_PDDR
  590. #define CORE_PIN10_DDRREG FGPIOC_PDDR
  591. #define CORE_PIN11_DDRREG FGPIOC_PDDR
  592. #define CORE_PIN12_DDRREG FGPIOC_PDDR
  593. #define CORE_PIN13_DDRREG FGPIOC_PDDR
  594. #define CORE_PIN14_DDRREG FGPIOD_PDDR
  595. #define CORE_PIN15_DDRREG FGPIOC_PDDR
  596. #define CORE_PIN16_DDRREG FGPIOB_PDDR
  597. #define CORE_PIN17_DDRREG FGPIOB_PDDR
  598. #define CORE_PIN18_DDRREG FGPIOB_PDDR
  599. #define CORE_PIN19_DDRREG FGPIOB_PDDR
  600. #define CORE_PIN20_DDRREG FGPIOD_PDDR
  601. #define CORE_PIN21_DDRREG FGPIOD_PDDR
  602. #define CORE_PIN22_DDRREG FGPIOC_PDDR
  603. #define CORE_PIN23_DDRREG FGPIOC_PDDR
  604. #define CORE_PIN24_DDRREG FGPIOE_PDDR
  605. #define CORE_PIN25_DDRREG FGPIOE_PDDR
  606. #define CORE_PIN26_DDRREG FGPIOE_PDDR
  607. #define CORE_PIN0_PINREG FGPIOB_PDIR
  608. #define CORE_PIN1_PINREG FGPIOB_PDIR
  609. #define CORE_PIN2_PINREG FGPIOD_PDIR
  610. #define CORE_PIN3_PINREG FGPIOA_PDIR
  611. #define CORE_PIN4_PINREG FGPIOA_PDIR
  612. #define CORE_PIN5_PINREG FGPIOD_PDIR
  613. #define CORE_PIN6_PINREG FGPIOD_PDIR
  614. #define CORE_PIN7_PINREG FGPIOD_PDIR
  615. #define CORE_PIN8_PINREG FGPIOD_PDIR
  616. #define CORE_PIN9_PINREG FGPIOC_PDIR
  617. #define CORE_PIN10_PINREG FGPIOC_PDIR
  618. #define CORE_PIN11_PINREG FGPIOC_PDIR
  619. #define CORE_PIN12_PINREG FGPIOC_PDIR
  620. #define CORE_PIN13_PINREG FGPIOC_PDIR
  621. #define CORE_PIN14_PINREG FGPIOD_PDIR
  622. #define CORE_PIN15_PINREG FGPIOC_PDIR
  623. #define CORE_PIN16_PINREG FGPIOB_PDIR
  624. #define CORE_PIN17_PINREG FGPIOB_PDIR
  625. #define CORE_PIN18_PINREG FGPIOB_PDIR
  626. #define CORE_PIN19_PINREG FGPIOB_PDIR
  627. #define CORE_PIN20_PINREG FGPIOD_PDIR
  628. #define CORE_PIN21_PINREG FGPIOD_PDIR
  629. #define CORE_PIN22_PINREG FGPIOC_PDIR
  630. #define CORE_PIN23_PINREG FGPIOC_PDIR
  631. #define CORE_PIN24_PINREG FGPIOE_PDIR
  632. #define CORE_PIN25_PINREG FGPIOE_PDIR
  633. #define CORE_PIN26_PINREG FGPIOE_PDIR
  634. #define CORE_PIN0_CONFIG PORTB_PCR16
  635. #define CORE_PIN1_CONFIG PORTB_PCR17
  636. #define CORE_PIN2_CONFIG PORTD_PCR0
  637. #define CORE_PIN3_CONFIG PORTA_PCR1
  638. #define CORE_PIN4_CONFIG PORTA_PCR2
  639. #define CORE_PIN5_CONFIG PORTD_PCR7
  640. #define CORE_PIN6_CONFIG PORTD_PCR4
  641. #define CORE_PIN7_CONFIG PORTD_PCR2
  642. #define CORE_PIN8_CONFIG PORTD_PCR3
  643. #define CORE_PIN9_CONFIG PORTC_PCR3
  644. #define CORE_PIN10_CONFIG PORTC_PCR4
  645. #define CORE_PIN11_CONFIG PORTC_PCR6
  646. #define CORE_PIN12_CONFIG PORTC_PCR7
  647. #define CORE_PIN13_CONFIG PORTC_PCR5
  648. #define CORE_PIN14_CONFIG PORTD_PCR1
  649. #define CORE_PIN15_CONFIG PORTC_PCR0
  650. #define CORE_PIN16_CONFIG PORTB_PCR0
  651. #define CORE_PIN17_CONFIG PORTB_PCR1
  652. #define CORE_PIN18_CONFIG PORTB_PCR3
  653. #define CORE_PIN19_CONFIG PORTB_PCR2
  654. #define CORE_PIN20_CONFIG PORTD_PCR5
  655. #define CORE_PIN21_CONFIG PORTD_PCR6
  656. #define CORE_PIN22_CONFIG PORTC_PCR1
  657. #define CORE_PIN23_CONFIG PORTC_PCR2
  658. #define CORE_PIN24_CONFIG PORTE_PCR20
  659. #define CORE_PIN25_CONFIG PORTE_PCR21
  660. #define CORE_PIN26_CONFIG PORTE_PCR30
  661. #define CORE_ADC0_PIN 14
  662. #define CORE_ADC1_PIN 15
  663. #define CORE_ADC2_PIN 16
  664. #define CORE_ADC3_PIN 17
  665. #define CORE_ADC4_PIN 18
  666. #define CORE_ADC5_PIN 19
  667. #define CORE_ADC6_PIN 20
  668. #define CORE_ADC7_PIN 21
  669. #define CORE_ADC8_PIN 22
  670. #define CORE_ADC9_PIN 23
  671. #define CORE_ADC10_PIN 24
  672. #define CORE_ADC11_PIN 25
  673. #define CORE_ADC12_PIN 26
  674. #define CORE_RXD0_PIN 0
  675. #define CORE_TXD0_PIN 1
  676. #define CORE_RXD1_PIN 9
  677. #define CORE_TXD1_PIN 10
  678. #define CORE_RXD2_PIN 7
  679. #define CORE_TXD2_PIN 8
  680. #define CORE_INT2_PIN 2
  681. #define CORE_INT3_PIN 3
  682. #define CORE_INT4_PIN 4
  683. #define CORE_INT5_PIN 5
  684. #define CORE_INT6_PIN 6
  685. #define CORE_INT7_PIN 7
  686. #define CORE_INT8_PIN 8
  687. #define CORE_INT9_PIN 9
  688. #define CORE_INT10_PIN 10
  689. #define CORE_INT11_PIN 11
  690. #define CORE_INT12_PIN 12
  691. #define CORE_INT13_PIN 13
  692. #define CORE_INT14_PIN 14
  693. #define CORE_INT15_PIN 15
  694. #define CORE_INT20_PIN 20
  695. #define CORE_INT21_PIN 21
  696. #define CORE_INT22_PIN 22
  697. #define CORE_INT23_PIN 23
  698. #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
  699. #define CORE_PIN0_BIT 16
  700. #define CORE_PIN1_BIT 17
  701. #define CORE_PIN2_BIT 0
  702. #define CORE_PIN3_BIT 12
  703. #define CORE_PIN4_BIT 13
  704. #define CORE_PIN5_BIT 7
  705. #define CORE_PIN6_BIT 4
  706. #define CORE_PIN7_BIT 2
  707. #define CORE_PIN8_BIT 3
  708. #define CORE_PIN9_BIT 3
  709. #define CORE_PIN10_BIT 4
  710. #define CORE_PIN11_BIT 6
  711. #define CORE_PIN12_BIT 7
  712. #define CORE_PIN13_BIT 5
  713. #define CORE_PIN14_BIT 1
  714. #define CORE_PIN15_BIT 0
  715. #define CORE_PIN16_BIT 0
  716. #define CORE_PIN17_BIT 1
  717. #define CORE_PIN18_BIT 3
  718. #define CORE_PIN19_BIT 2
  719. #define CORE_PIN20_BIT 5
  720. #define CORE_PIN21_BIT 6
  721. #define CORE_PIN22_BIT 1
  722. #define CORE_PIN23_BIT 2
  723. #define CORE_PIN24_BIT 26
  724. #define CORE_PIN25_BIT 5
  725. #define CORE_PIN26_BIT 14
  726. #define CORE_PIN27_BIT 15
  727. #define CORE_PIN28_BIT 16
  728. #define CORE_PIN29_BIT 18
  729. #define CORE_PIN30_BIT 19
  730. #define CORE_PIN31_BIT 10
  731. #define CORE_PIN32_BIT 11
  732. #define CORE_PIN33_BIT 24
  733. #define CORE_PIN34_BIT 25
  734. #define CORE_PIN35_BIT 8
  735. #define CORE_PIN36_BIT 9
  736. #define CORE_PIN37_BIT 10
  737. #define CORE_PIN38_BIT 11
  738. #define CORE_PIN39_BIT 17
  739. #define CORE_PIN40_BIT 28
  740. #define CORE_PIN41_BIT 29
  741. #define CORE_PIN42_BIT 26
  742. #define CORE_PIN43_BIT 20
  743. #define CORE_PIN44_BIT 22
  744. #define CORE_PIN45_BIT 23
  745. #define CORE_PIN46_BIT 21
  746. #define CORE_PIN47_BIT 8
  747. #define CORE_PIN48_BIT 9
  748. #define CORE_PIN49_BIT 4
  749. #define CORE_PIN50_BIT 5
  750. #define CORE_PIN51_BIT 14
  751. #define CORE_PIN52_BIT 13
  752. #define CORE_PIN53_BIT 12
  753. #define CORE_PIN54_BIT 15
  754. #define CORE_PIN55_BIT 11
  755. #define CORE_PIN56_BIT 10
  756. #define CORE_PIN57_BIT 11
  757. #define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
  758. #define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
  759. #define CORE_PIN2_BITMASK (1<<(CORE_PIN2_BIT))
  760. #define CORE_PIN3_BITMASK (1<<(CORE_PIN3_BIT))
  761. #define CORE_PIN4_BITMASK (1<<(CORE_PIN4_BIT))
  762. #define CORE_PIN5_BITMASK (1<<(CORE_PIN5_BIT))
  763. #define CORE_PIN6_BITMASK (1<<(CORE_PIN6_BIT))
  764. #define CORE_PIN7_BITMASK (1<<(CORE_PIN7_BIT))
  765. #define CORE_PIN8_BITMASK (1<<(CORE_PIN8_BIT))
  766. #define CORE_PIN9_BITMASK (1<<(CORE_PIN9_BIT))
  767. #define CORE_PIN10_BITMASK (1<<(CORE_PIN10_BIT))
  768. #define CORE_PIN11_BITMASK (1<<(CORE_PIN11_BIT))
  769. #define CORE_PIN12_BITMASK (1<<(CORE_PIN12_BIT))
  770. #define CORE_PIN13_BITMASK (1<<(CORE_PIN13_BIT))
  771. #define CORE_PIN14_BITMASK (1<<(CORE_PIN14_BIT))
  772. #define CORE_PIN15_BITMASK (1<<(CORE_PIN15_BIT))
  773. #define CORE_PIN16_BITMASK (1<<(CORE_PIN16_BIT))
  774. #define CORE_PIN17_BITMASK (1<<(CORE_PIN17_BIT))
  775. #define CORE_PIN18_BITMASK (1<<(CORE_PIN18_BIT))
  776. #define CORE_PIN19_BITMASK (1<<(CORE_PIN19_BIT))
  777. #define CORE_PIN20_BITMASK (1<<(CORE_PIN20_BIT))
  778. #define CORE_PIN21_BITMASK (1<<(CORE_PIN21_BIT))
  779. #define CORE_PIN22_BITMASK (1<<(CORE_PIN22_BIT))
  780. #define CORE_PIN23_BITMASK (1<<(CORE_PIN23_BIT))
  781. #define CORE_PIN24_BITMASK (1<<(CORE_PIN24_BIT))
  782. #define CORE_PIN25_BITMASK (1<<(CORE_PIN25_BIT))
  783. #define CORE_PIN26_BITMASK (1<<(CORE_PIN26_BIT))
  784. #define CORE_PIN27_BITMASK (1<<(CORE_PIN27_BIT))
  785. #define CORE_PIN28_BITMASK (1<<(CORE_PIN28_BIT))
  786. #define CORE_PIN29_BITMASK (1<<(CORE_PIN29_BIT))
  787. #define CORE_PIN30_BITMASK (1<<(CORE_PIN30_BIT))
  788. #define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
  789. #define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
  790. #define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
  791. #define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
  792. #define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
  793. #define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
  794. #define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
  795. #define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
  796. #define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))
  797. #define CORE_PIN40_BITMASK (1<<(CORE_PIN40_BIT))
  798. #define CORE_PIN41_BITMASK (1<<(CORE_PIN41_BIT))
  799. #define CORE_PIN42_BITMASK (1<<(CORE_PIN42_BIT))
  800. #define CORE_PIN43_BITMASK (1<<(CORE_PIN43_BIT))
  801. #define CORE_PIN44_BITMASK (1<<(CORE_PIN44_BIT))
  802. #define CORE_PIN45_BITMASK (1<<(CORE_PIN45_BIT))
  803. #define CORE_PIN46_BITMASK (1<<(CORE_PIN46_BIT))
  804. #define CORE_PIN47_BITMASK (1<<(CORE_PIN47_BIT))
  805. #define CORE_PIN48_BITMASK (1<<(CORE_PIN48_BIT))
  806. #define CORE_PIN49_BITMASK (1<<(CORE_PIN49_BIT))
  807. #define CORE_PIN50_BITMASK (1<<(CORE_PIN50_BIT))
  808. #define CORE_PIN51_BITMASK (1<<(CORE_PIN51_BIT))
  809. #define CORE_PIN52_BITMASK (1<<(CORE_PIN52_BIT))
  810. #define CORE_PIN53_BITMASK (1<<(CORE_PIN53_BIT))
  811. #define CORE_PIN54_BITMASK (1<<(CORE_PIN54_BIT))
  812. #define CORE_PIN55_BITMASK (1<<(CORE_PIN55_BIT))
  813. #define CORE_PIN56_BITMASK (1<<(CORE_PIN56_BIT))
  814. #define CORE_PIN57_BITMASK (1<<(CORE_PIN57_BIT))
  815. #define CORE_PIN0_PORTREG GPIOB_PDOR
  816. #define CORE_PIN1_PORTREG GPIOB_PDOR
  817. #define CORE_PIN2_PORTREG GPIOD_PDOR
  818. #define CORE_PIN3_PORTREG GPIOA_PDOR
  819. #define CORE_PIN4_PORTREG GPIOA_PDOR
  820. #define CORE_PIN5_PORTREG GPIOD_PDOR
  821. #define CORE_PIN6_PORTREG GPIOD_PDOR
  822. #define CORE_PIN7_PORTREG GPIOD_PDOR
  823. #define CORE_PIN8_PORTREG GPIOD_PDOR
  824. #define CORE_PIN9_PORTREG GPIOC_PDOR
  825. #define CORE_PIN10_PORTREG GPIOC_PDOR
  826. #define CORE_PIN11_PORTREG GPIOC_PDOR
  827. #define CORE_PIN12_PORTREG GPIOC_PDOR
  828. #define CORE_PIN13_PORTREG GPIOC_PDOR
  829. #define CORE_PIN14_PORTREG GPIOD_PDOR
  830. #define CORE_PIN15_PORTREG GPIOC_PDOR
  831. #define CORE_PIN16_PORTREG GPIOB_PDOR
  832. #define CORE_PIN17_PORTREG GPIOB_PDOR
  833. #define CORE_PIN18_PORTREG GPIOB_PDOR
  834. #define CORE_PIN19_PORTREG GPIOB_PDOR
  835. #define CORE_PIN20_PORTREG GPIOD_PDOR
  836. #define CORE_PIN21_PORTREG GPIOD_PDOR
  837. #define CORE_PIN22_PORTREG GPIOC_PDOR
  838. #define CORE_PIN23_PORTREG GPIOC_PDOR
  839. #define CORE_PIN24_PORTREG GPIOE_PDOR
  840. #define CORE_PIN25_PORTREG GPIOA_PDOR
  841. #define CORE_PIN26_PORTREG GPIOA_PDOR
  842. #define CORE_PIN27_PORTREG GPIOA_PDOR
  843. #define CORE_PIN28_PORTREG GPIOA_PDOR
  844. #define CORE_PIN29_PORTREG GPIOB_PDOR
  845. #define CORE_PIN30_PORTREG GPIOB_PDOR
  846. #define CORE_PIN31_PORTREG GPIOB_PDOR
  847. #define CORE_PIN32_PORTREG GPIOB_PDOR
  848. #define CORE_PIN33_PORTREG GPIOE_PDOR
  849. #define CORE_PIN34_PORTREG GPIOE_PDOR
  850. #define CORE_PIN35_PORTREG GPIOC_PDOR
  851. #define CORE_PIN36_PORTREG GPIOC_PDOR
  852. #define CORE_PIN37_PORTREG GPIOC_PDOR
  853. #define CORE_PIN38_PORTREG GPIOC_PDOR
  854. #define CORE_PIN39_PORTREG GPIOA_PDOR
  855. #define CORE_PIN40_PORTREG GPIOA_PDOR
  856. #define CORE_PIN41_PORTREG GPIOA_PDOR
  857. #define CORE_PIN42_PORTREG GPIOA_PDOR
  858. #define CORE_PIN43_PORTREG GPIOB_PDOR
  859. #define CORE_PIN44_PORTREG GPIOB_PDOR
  860. #define CORE_PIN45_PORTREG GPIOB_PDOR
  861. #define CORE_PIN46_PORTREG GPIOB_PDOR
  862. #define CORE_PIN47_PORTREG GPIOD_PDOR
  863. #define CORE_PIN48_PORTREG GPIOD_PDOR
  864. #define CORE_PIN49_PORTREG GPIOB_PDOR
  865. #define CORE_PIN50_PORTREG GPIOB_PDOR
  866. #define CORE_PIN51_PORTREG GPIOD_PDOR
  867. #define CORE_PIN52_PORTREG GPIOD_PDOR
  868. #define CORE_PIN53_PORTREG GPIOD_PDOR
  869. #define CORE_PIN54_PORTREG GPIOD_PDOR
  870. #define CORE_PIN55_PORTREG GPIOD_PDOR
  871. #define CORE_PIN56_PORTREG GPIOE_PDOR
  872. #define CORE_PIN57_PORTREG GPIOE_PDOR
  873. #define CORE_PIN0_PORTSET GPIOB_PSOR
  874. #define CORE_PIN1_PORTSET GPIOB_PSOR
  875. #define CORE_PIN2_PORTSET GPIOD_PSOR
  876. #define CORE_PIN3_PORTSET GPIOA_PSOR
  877. #define CORE_PIN4_PORTSET GPIOA_PSOR
  878. #define CORE_PIN5_PORTSET GPIOD_PSOR
  879. #define CORE_PIN6_PORTSET GPIOD_PSOR
  880. #define CORE_PIN7_PORTSET GPIOD_PSOR
  881. #define CORE_PIN8_PORTSET GPIOD_PSOR
  882. #define CORE_PIN9_PORTSET GPIOC_PSOR
  883. #define CORE_PIN10_PORTSET GPIOC_PSOR
  884. #define CORE_PIN11_PORTSET GPIOC_PSOR
  885. #define CORE_PIN12_PORTSET GPIOC_PSOR
  886. #define CORE_PIN13_PORTSET GPIOC_PSOR
  887. #define CORE_PIN14_PORTSET GPIOD_PSOR
  888. #define CORE_PIN15_PORTSET GPIOC_PSOR
  889. #define CORE_PIN16_PORTSET GPIOB_PSOR
  890. #define CORE_PIN17_PORTSET GPIOB_PSOR
  891. #define CORE_PIN18_PORTSET GPIOB_PSOR
  892. #define CORE_PIN19_PORTSET GPIOB_PSOR
  893. #define CORE_PIN20_PORTSET GPIOD_PSOR
  894. #define CORE_PIN21_PORTSET GPIOD_PSOR
  895. #define CORE_PIN22_PORTSET GPIOC_PSOR
  896. #define CORE_PIN23_PORTSET GPIOC_PSOR
  897. #define CORE_PIN24_PORTSET GPIOE_PSOR
  898. #define CORE_PIN25_PORTSET GPIOA_PSOR
  899. #define CORE_PIN26_PORTSET GPIOA_PSOR
  900. #define CORE_PIN27_PORTSET GPIOA_PSOR
  901. #define CORE_PIN28_PORTSET GPIOA_PSOR
  902. #define CORE_PIN29_PORTSET GPIOB_PSOR
  903. #define CORE_PIN30_PORTSET GPIOB_PSOR
  904. #define CORE_PIN31_PORTSET GPIOB_PSOR
  905. #define CORE_PIN32_PORTSET GPIOB_PSOR
  906. #define CORE_PIN33_PORTSET GPIOE_PSOR
  907. #define CORE_PIN34_PORTSET GPIOE_PSOR
  908. #define CORE_PIN35_PORTSET GPIOC_PSOR
  909. #define CORE_PIN36_PORTSET GPIOC_PSOR
  910. #define CORE_PIN37_PORTSET GPIOC_PSOR
  911. #define CORE_PIN38_PORTSET GPIOC_PSOR
  912. #define CORE_PIN39_PORTSET GPIOA_PSOR
  913. #define CORE_PIN40_PORTSET GPIOA_PSOR
  914. #define CORE_PIN41_PORTSET GPIOA_PSOR
  915. #define CORE_PIN42_PORTSET GPIOA_PSOR
  916. #define CORE_PIN43_PORTSET GPIOB_PSOR
  917. #define CORE_PIN44_PORTSET GPIOB_PSOR
  918. #define CORE_PIN45_PORTSET GPIOB_PSOR
  919. #define CORE_PIN46_PORTSET GPIOB_PSOR
  920. #define CORE_PIN47_PORTSET GPIOD_PSOR
  921. #define CORE_PIN48_PORTSET GPIOD_PSOR
  922. #define CORE_PIN49_PORTSET GPIOB_PSOR
  923. #define CORE_PIN50_PORTSET GPIOB_PSOR
  924. #define CORE_PIN51_PORTSET GPIOD_PSOR
  925. #define CORE_PIN52_PORTSET GPIOD_PSOR
  926. #define CORE_PIN53_PORTSET GPIOD_PSOR
  927. #define CORE_PIN54_PORTSET GPIOD_PSOR
  928. #define CORE_PIN55_PORTSET GPIOD_PSOR
  929. #define CORE_PIN56_PORTSET GPIOE_PSOR
  930. #define CORE_PIN57_PORTSET GPIOE_PSOR
  931. #define CORE_PIN0_PORTCLEAR GPIOB_PCOR
  932. #define CORE_PIN1_PORTCLEAR GPIOB_PCOR
  933. #define CORE_PIN2_PORTCLEAR GPIOD_PCOR
  934. #define CORE_PIN3_PORTCLEAR GPIOA_PCOR
  935. #define CORE_PIN4_PORTCLEAR GPIOA_PCOR
  936. #define CORE_PIN5_PORTCLEAR GPIOD_PCOR
  937. #define CORE_PIN6_PORTCLEAR GPIOD_PCOR
  938. #define CORE_PIN7_PORTCLEAR GPIOD_PCOR
  939. #define CORE_PIN8_PORTCLEAR GPIOD_PCOR
  940. #define CORE_PIN9_PORTCLEAR GPIOC_PCOR
  941. #define CORE_PIN10_PORTCLEAR GPIOC_PCOR
  942. #define CORE_PIN11_PORTCLEAR GPIOC_PCOR
  943. #define CORE_PIN12_PORTCLEAR GPIOC_PCOR
  944. #define CORE_PIN13_PORTCLEAR GPIOC_PCOR
  945. #define CORE_PIN14_PORTCLEAR GPIOD_PCOR
  946. #define CORE_PIN15_PORTCLEAR GPIOC_PCOR
  947. #define CORE_PIN16_PORTCLEAR GPIOB_PCOR
  948. #define CORE_PIN17_PORTCLEAR GPIOB_PCOR
  949. #define CORE_PIN18_PORTCLEAR GPIOB_PCOR
  950. #define CORE_PIN19_PORTCLEAR GPIOB_PCOR
  951. #define CORE_PIN20_PORTCLEAR GPIOD_PCOR
  952. #define CORE_PIN21_PORTCLEAR GPIOD_PCOR
  953. #define CORE_PIN22_PORTCLEAR GPIOC_PCOR
  954. #define CORE_PIN23_PORTCLEAR GPIOC_PCOR
  955. #define CORE_PIN24_PORTCLEAR GPIOE_PCOR
  956. #define CORE_PIN25_PORTCLEAR GPIOA_PCOR
  957. #define CORE_PIN26_PORTCLEAR GPIOA_PCOR
  958. #define CORE_PIN27_PORTCLEAR GPIOA_PCOR
  959. #define CORE_PIN28_PORTCLEAR GPIOA_PCOR
  960. #define CORE_PIN29_PORTCLEAR GPIOB_PCOR
  961. #define CORE_PIN30_PORTCLEAR GPIOB_PCOR
  962. #define CORE_PIN31_PORTCLEAR GPIOB_PCOR
  963. #define CORE_PIN32_PORTCLEAR GPIOB_PCOR
  964. #define CORE_PIN33_PORTCLEAR GPIOE_PCOR
  965. #define CORE_PIN34_PORTCLEAR GPIOE_PCOR
  966. #define CORE_PIN35_PORTCLEAR GPIOC_PCOR
  967. #define CORE_PIN36_PORTCLEAR GPIOC_PCOR
  968. #define CORE_PIN37_PORTCLEAR GPIOC_PCOR
  969. #define CORE_PIN38_PORTCLEAR GPIOC_PCOR
  970. #define CORE_PIN39_PORTCLEAR GPIOA_PCOR
  971. #define CORE_PIN40_PORTCLEAR GPIOA_PCOR
  972. #define CORE_PIN41_PORTCLEAR GPIOA_PCOR
  973. #define CORE_PIN42_PORTCLEAR GPIOA_PCOR
  974. #define CORE_PIN43_PORTCLEAR GPIOB_PCOR
  975. #define CORE_PIN44_PORTCLEAR GPIOB_PCOR
  976. #define CORE_PIN45_PORTCLEAR GPIOB_PCOR
  977. #define CORE_PIN46_PORTCLEAR GPIOB_PCOR
  978. #define CORE_PIN47_PORTCLEAR GPIOD_PCOR
  979. #define CORE_PIN48_PORTCLEAR GPIOD_PCOR
  980. #define CORE_PIN49_PORTCLEAR GPIOB_PCOR
  981. #define CORE_PIN50_PORTCLEAR GPIOB_PCOR
  982. #define CORE_PIN51_PORTCLEAR GPIOD_PCOR
  983. #define CORE_PIN52_PORTCLEAR GPIOD_PCOR
  984. #define CORE_PIN53_PORTCLEAR GPIOD_PCOR
  985. #define CORE_PIN54_PORTCLEAR GPIOD_PCOR
  986. #define CORE_PIN55_PORTCLEAR GPIOD_PCOR
  987. #define CORE_PIN56_PORTCLEAR GPIOE_PCOR
  988. #define CORE_PIN57_PORTCLEAR GPIOE_PCOR
  989. #define CORE_PIN0_DDRREG GPIOB_PDDR
  990. #define CORE_PIN1_DDRREG GPIOB_PDDR
  991. #define CORE_PIN2_DDRREG GPIOD_PDDR
  992. #define CORE_PIN3_DDRREG GPIOA_PDDR
  993. #define CORE_PIN4_DDRREG GPIOA_PDDR
  994. #define CORE_PIN5_DDRREG GPIOD_PDDR
  995. #define CORE_PIN6_DDRREG GPIOD_PDDR
  996. #define CORE_PIN7_DDRREG GPIOD_PDDR
  997. #define CORE_PIN8_DDRREG GPIOD_PDDR
  998. #define CORE_PIN9_DDRREG GPIOC_PDDR
  999. #define CORE_PIN10_DDRREG GPIOC_PDDR
  1000. #define CORE_PIN11_DDRREG GPIOC_PDDR
  1001. #define CORE_PIN12_DDRREG GPIOC_PDDR
  1002. #define CORE_PIN13_DDRREG GPIOC_PDDR
  1003. #define CORE_PIN14_DDRREG GPIOD_PDDR
  1004. #define CORE_PIN15_DDRREG GPIOC_PDDR
  1005. #define CORE_PIN16_DDRREG GPIOB_PDDR
  1006. #define CORE_PIN17_DDRREG GPIOB_PDDR
  1007. #define CORE_PIN18_DDRREG GPIOB_PDDR
  1008. #define CORE_PIN19_DDRREG GPIOB_PDDR
  1009. #define CORE_PIN20_DDRREG GPIOD_PDDR
  1010. #define CORE_PIN21_DDRREG GPIOD_PDDR
  1011. #define CORE_PIN22_DDRREG GPIOC_PDDR
  1012. #define CORE_PIN23_DDRREG GPIOC_PDDR
  1013. #define CORE_PIN24_DDRREG GPIOE_PDDR
  1014. #define CORE_PIN25_DDRREG GPIOA_PDDR
  1015. #define CORE_PIN26_DDRREG GPIOA_PDDR
  1016. #define CORE_PIN27_DDRREG GPIOA_PDDR
  1017. #define CORE_PIN28_DDRREG GPIOA_PDDR
  1018. #define CORE_PIN29_DDRREG GPIOB_PDDR
  1019. #define CORE_PIN30_DDRREG GPIOB_PDDR
  1020. #define CORE_PIN31_DDRREG GPIOB_PDDR
  1021. #define CORE_PIN32_DDRREG GPIOB_PDDR
  1022. #define CORE_PIN33_DDRREG GPIOE_PDDR
  1023. #define CORE_PIN34_DDRREG GPIOE_PDDR
  1024. #define CORE_PIN35_DDRREG GPIOC_PDDR
  1025. #define CORE_PIN36_DDRREG GPIOC_PDDR
  1026. #define CORE_PIN37_DDRREG GPIOC_PDDR
  1027. #define CORE_PIN38_DDRREG GPIOC_PDDR
  1028. #define CORE_PIN39_DDRREG GPIOA_PDDR
  1029. #define CORE_PIN40_DDRREG GPIOA_PDDR
  1030. #define CORE_PIN41_DDRREG GPIOA_PDDR
  1031. #define CORE_PIN42_DDRREG GPIOA_PDDR
  1032. #define CORE_PIN43_DDRREG GPIOB_PDDR
  1033. #define CORE_PIN44_DDRREG GPIOB_PDDR
  1034. #define CORE_PIN45_DDRREG GPIOB_PDDR
  1035. #define CORE_PIN46_DDRREG GPIOB_PDDR
  1036. #define CORE_PIN47_DDRREG GPIOD_PDDR
  1037. #define CORE_PIN48_DDRREG GPIOD_PDDR
  1038. #define CORE_PIN49_DDRREG GPIOB_PDDR
  1039. #define CORE_PIN50_DDRREG GPIOB_PDDR
  1040. #define CORE_PIN51_DDRREG GPIOD_PDDR
  1041. #define CORE_PIN52_DDRREG GPIOD_PDDR
  1042. #define CORE_PIN53_DDRREG GPIOD_PDDR
  1043. #define CORE_PIN54_DDRREG GPIOD_PDDR
  1044. #define CORE_PIN55_DDRREG GPIOD_PDDR
  1045. #define CORE_PIN56_DDRREG GPIOE_PDDR
  1046. #define CORE_PIN57_DDRREG GPIOE_PDDR
  1047. #define CORE_PIN0_PINREG GPIOB_PDIR
  1048. #define CORE_PIN1_PINREG GPIOB_PDIR
  1049. #define CORE_PIN2_PINREG GPIOD_PDIR
  1050. #define CORE_PIN3_PINREG GPIOA_PDIR
  1051. #define CORE_PIN4_PINREG GPIOA_PDIR
  1052. #define CORE_PIN5_PINREG GPIOD_PDIR
  1053. #define CORE_PIN6_PINREG GPIOD_PDIR
  1054. #define CORE_PIN7_PINREG GPIOD_PDIR
  1055. #define CORE_PIN8_PINREG GPIOD_PDIR
  1056. #define CORE_PIN9_PINREG GPIOC_PDIR
  1057. #define CORE_PIN10_PINREG GPIOC_PDIR
  1058. #define CORE_PIN11_PINREG GPIOC_PDIR
  1059. #define CORE_PIN12_PINREG GPIOC_PDIR
  1060. #define CORE_PIN13_PINREG GPIOC_PDIR
  1061. #define CORE_PIN14_PINREG GPIOD_PDIR
  1062. #define CORE_PIN15_PINREG GPIOC_PDIR
  1063. #define CORE_PIN16_PINREG GPIOB_PDIR
  1064. #define CORE_PIN17_PINREG GPIOB_PDIR
  1065. #define CORE_PIN18_PINREG GPIOB_PDIR
  1066. #define CORE_PIN19_PINREG GPIOB_PDIR
  1067. #define CORE_PIN20_PINREG GPIOD_PDIR
  1068. #define CORE_PIN21_PINREG GPIOD_PDIR
  1069. #define CORE_PIN22_PINREG GPIOC_PDIR
  1070. #define CORE_PIN23_PINREG GPIOC_PDIR
  1071. #define CORE_PIN24_PINREG GPIOE_PDIR
  1072. #define CORE_PIN25_PINREG GPIOA_PDIR
  1073. #define CORE_PIN26_PINREG GPIOA_PDIR
  1074. #define CORE_PIN27_PINREG GPIOA_PDIR
  1075. #define CORE_PIN28_PINREG GPIOA_PDIR
  1076. #define CORE_PIN29_PINREG GPIOB_PDIR
  1077. #define CORE_PIN30_PINREG GPIOB_PDIR
  1078. #define CORE_PIN31_PINREG GPIOB_PDIR
  1079. #define CORE_PIN32_PINREG GPIOB_PDIR
  1080. #define CORE_PIN33_PINREG GPIOE_PDIR
  1081. #define CORE_PIN34_PINREG GPIOE_PDIR
  1082. #define CORE_PIN35_PINREG GPIOC_PDIR
  1083. #define CORE_PIN36_PINREG GPIOC_PDIR
  1084. #define CORE_PIN37_PINREG GPIOC_PDIR
  1085. #define CORE_PIN38_PINREG GPIOC_PDIR
  1086. #define CORE_PIN39_PINREG GPIOA_PDIR
  1087. #define CORE_PIN40_PINREG GPIOA_PDIR
  1088. #define CORE_PIN41_PINREG GPIOA_PDIR
  1089. #define CORE_PIN42_PINREG GPIOA_PDIR
  1090. #define CORE_PIN43_PINREG GPIOB_PDIR
  1091. #define CORE_PIN44_PINREG GPIOB_PDIR
  1092. #define CORE_PIN45_PINREG GPIOB_PDIR
  1093. #define CORE_PIN46_PINREG GPIOB_PDIR
  1094. #define CORE_PIN47_PINREG GPIOD_PDIR
  1095. #define CORE_PIN48_PINREG GPIOD_PDIR
  1096. #define CORE_PIN49_PINREG GPIOB_PDIR
  1097. #define CORE_PIN50_PINREG GPIOB_PDIR
  1098. #define CORE_PIN51_PINREG GPIOD_PDIR
  1099. #define CORE_PIN52_PINREG GPIOD_PDIR
  1100. #define CORE_PIN53_PINREG GPIOD_PDIR
  1101. #define CORE_PIN54_PINREG GPIOD_PDIR
  1102. #define CORE_PIN55_PINREG GPIOD_PDIR
  1103. #define CORE_PIN56_PINREG GPIOE_PDIR
  1104. #define CORE_PIN57_PINREG GPIOE_PDIR
  1105. #define CORE_PIN0_CONFIG PORTB_PCR16
  1106. #define CORE_PIN1_CONFIG PORTB_PCR17
  1107. #define CORE_PIN2_CONFIG PORTD_PCR0
  1108. #define CORE_PIN3_CONFIG PORTA_PCR12
  1109. #define CORE_PIN4_CONFIG PORTA_PCR13
  1110. #define CORE_PIN5_CONFIG PORTD_PCR7
  1111. #define CORE_PIN6_CONFIG PORTD_PCR4
  1112. #define CORE_PIN7_CONFIG PORTD_PCR2
  1113. #define CORE_PIN8_CONFIG PORTD_PCR3
  1114. #define CORE_PIN9_CONFIG PORTC_PCR3
  1115. #define CORE_PIN10_CONFIG PORTC_PCR4
  1116. #define CORE_PIN11_CONFIG PORTC_PCR6
  1117. #define CORE_PIN12_CONFIG PORTC_PCR7
  1118. #define CORE_PIN13_CONFIG PORTC_PCR5
  1119. #define CORE_PIN14_CONFIG PORTD_PCR1
  1120. #define CORE_PIN15_CONFIG PORTC_PCR0
  1121. #define CORE_PIN16_CONFIG PORTB_PCR0
  1122. #define CORE_PIN17_CONFIG PORTB_PCR1
  1123. #define CORE_PIN18_CONFIG PORTB_PCR3
  1124. #define CORE_PIN19_CONFIG PORTB_PCR2
  1125. #define CORE_PIN20_CONFIG PORTD_PCR5
  1126. #define CORE_PIN21_CONFIG PORTD_PCR6
  1127. #define CORE_PIN22_CONFIG PORTC_PCR1
  1128. #define CORE_PIN23_CONFIG PORTC_PCR2
  1129. #define CORE_PIN24_CONFIG PORTE_PCR26
  1130. #define CORE_PIN25_CONFIG PORTA_PCR5
  1131. #define CORE_PIN26_CONFIG PORTA_PCR14
  1132. #define CORE_PIN27_CONFIG PORTA_PCR15
  1133. #define CORE_PIN28_CONFIG PORTA_PCR16
  1134. #define CORE_PIN29_CONFIG PORTB_PCR18
  1135. #define CORE_PIN30_CONFIG PORTB_PCR19
  1136. #define CORE_PIN31_CONFIG PORTB_PCR10
  1137. #define CORE_PIN32_CONFIG PORTB_PCR11
  1138. #define CORE_PIN33_CONFIG PORTE_PCR24
  1139. #define CORE_PIN34_CONFIG PORTE_PCR25
  1140. #define CORE_PIN35_CONFIG PORTC_PCR8
  1141. #define CORE_PIN36_CONFIG PORTC_PCR9
  1142. #define CORE_PIN37_CONFIG PORTC_PCR10
  1143. #define CORE_PIN38_CONFIG PORTC_PCR11
  1144. #define CORE_PIN39_CONFIG PORTA_PCR17
  1145. #define CORE_PIN40_CONFIG PORTA_PCR28
  1146. #define CORE_PIN41_CONFIG PORTA_PCR29
  1147. #define CORE_PIN42_CONFIG PORTA_PCR26
  1148. #define CORE_PIN43_CONFIG PORTB_PCR20
  1149. #define CORE_PIN44_CONFIG PORTB_PCR22
  1150. #define CORE_PIN45_CONFIG PORTB_PCR23
  1151. #define CORE_PIN46_CONFIG PORTB_PCR21
  1152. #define CORE_PIN47_CONFIG PORTD_PCR8
  1153. #define CORE_PIN48_CONFIG PORTD_PCR9
  1154. #define CORE_PIN49_CONFIG PORTB_PCR4
  1155. #define CORE_PIN50_CONFIG PORTB_PCR5
  1156. #define CORE_PIN51_CONFIG PORTD_PCR14
  1157. #define CORE_PIN52_CONFIG PORTD_PCR13
  1158. #define CORE_PIN53_CONFIG PORTD_PCR12
  1159. #define CORE_PIN54_CONFIG PORTD_PCR15
  1160. #define CORE_PIN55_CONFIG PORTD_PCR11
  1161. #define CORE_PIN56_CONFIG PORTE_PCR10
  1162. #define CORE_PIN57_CONFIG PORTE_PCR11
  1163. #define CORE_ADC0_PIN 14
  1164. #define CORE_ADC1_PIN 15
  1165. #define CORE_ADC2_PIN 16
  1166. #define CORE_ADC3_PIN 17
  1167. #define CORE_ADC4_PIN 18
  1168. #define CORE_ADC5_PIN 19
  1169. #define CORE_ADC6_PIN 20
  1170. #define CORE_ADC7_PIN 21
  1171. #define CORE_ADC8_PIN 22
  1172. #define CORE_ADC9_PIN 23
  1173. #define CORE_ADC10_PIN 40
  1174. #define CORE_ADC11_PIN 41
  1175. #define CORE_ADC12_PIN 31
  1176. #define CORE_ADC13_PIN 32
  1177. #define CORE_ADC14_PIN 33
  1178. #define CORE_ADC15_PIN 34
  1179. #define CORE_ADC16_PIN 35
  1180. #define CORE_ADC17_PIN 36
  1181. #define CORE_ADC18_PIN 37
  1182. #define CORE_ADC19_PIN 38
  1183. #define CORE_ADC20_PIN 39
  1184. #define CORE_RXD0_PIN 0
  1185. #define CORE_TXD0_PIN 1
  1186. #define CORE_RXD1_PIN 9
  1187. #define CORE_TXD1_PIN 10
  1188. #define CORE_RXD2_PIN 7
  1189. #define CORE_TXD2_PIN 8
  1190. #define CORE_RXD3_PIN 31
  1191. #define CORE_TXD3_PIN 32
  1192. #define CORE_RXD4_PIN 34
  1193. #define CORE_TXD4_PIN 33
  1194. #define CORE_INT0_PIN 0
  1195. #define CORE_INT1_PIN 1
  1196. #define CORE_INT2_PIN 2
  1197. #define CORE_INT3_PIN 3
  1198. #define CORE_INT4_PIN 4
  1199. #define CORE_INT5_PIN 5
  1200. #define CORE_INT6_PIN 6
  1201. #define CORE_INT7_PIN 7
  1202. #define CORE_INT8_PIN 8
  1203. #define CORE_INT9_PIN 9
  1204. #define CORE_INT10_PIN 10
  1205. #define CORE_INT11_PIN 11
  1206. #define CORE_INT12_PIN 12
  1207. #define CORE_INT13_PIN 13
  1208. #define CORE_INT14_PIN 14
  1209. #define CORE_INT15_PIN 15
  1210. #define CORE_INT16_PIN 16
  1211. #define CORE_INT17_PIN 17
  1212. #define CORE_INT18_PIN 18
  1213. #define CORE_INT19_PIN 19
  1214. #define CORE_INT20_PIN 20
  1215. #define CORE_INT21_PIN 21
  1216. #define CORE_INT22_PIN 22
  1217. #define CORE_INT23_PIN 23
  1218. #define CORE_INT24_PIN 24
  1219. #define CORE_INT25_PIN 25
  1220. #define CORE_INT26_PIN 26
  1221. #define CORE_INT27_PIN 27
  1222. #define CORE_INT28_PIN 28
  1223. #define CORE_INT29_PIN 29
  1224. #define CORE_INT30_PIN 30
  1225. #define CORE_INT31_PIN 31
  1226. #define CORE_INT32_PIN 32
  1227. #define CORE_INT33_PIN 33
  1228. #define CORE_INT34_PIN 34
  1229. #define CORE_INT35_PIN 35
  1230. #define CORE_INT36_PIN 36
  1231. #define CORE_INT37_PIN 37
  1232. #define CORE_INT38_PIN 38
  1233. #define CORE_INT39_PIN 39
  1234. #define CORE_INT40_PIN 40
  1235. #define CORE_INT41_PIN 41
  1236. #define CORE_INT42_PIN 42
  1237. #define CORE_INT43_PIN 43
  1238. #define CORE_INT44_PIN 44
  1239. #define CORE_INT45_PIN 45
  1240. #define CORE_INT46_PIN 46
  1241. #define CORE_INT47_PIN 47
  1242. #define CORE_INT48_PIN 48
  1243. #define CORE_INT49_PIN 49
  1244. #define CORE_INT50_PIN 50
  1245. #define CORE_INT51_PIN 51
  1246. #define CORE_INT52_PIN 52
  1247. #define CORE_INT53_PIN 53
  1248. #define CORE_INT54_PIN 54
  1249. #define CORE_INT55_PIN 55
  1250. #define CORE_INT56_PIN 56
  1251. #define CORE_INT57_PIN 57
  1252. #define CORE_INT_EVERY_PIN 1
  1253. #endif
  1254. #ifdef __cplusplus
  1255. extern "C" {
  1256. #endif
  1257. void digitalWrite(uint8_t pin, uint8_t val);
  1258. static inline void digitalWriteFast(uint8_t pin, uint8_t val) __attribute__((always_inline, unused));
  1259. static inline void digitalWriteFast(uint8_t pin, uint8_t val)
  1260. {
  1261. if (__builtin_constant_p(pin)) {
  1262. if (val) {
  1263. if (pin == 0) {
  1264. CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
  1265. } else if (pin == 1) {
  1266. CORE_PIN1_PORTSET = CORE_PIN1_BITMASK;
  1267. } else if (pin == 2) {
  1268. CORE_PIN2_PORTSET = CORE_PIN2_BITMASK;
  1269. } else if (pin == 3) {
  1270. CORE_PIN3_PORTSET = CORE_PIN3_BITMASK;
  1271. } else if (pin == 4) {
  1272. CORE_PIN4_PORTSET = CORE_PIN4_BITMASK;
  1273. } else if (pin == 5) {
  1274. CORE_PIN5_PORTSET = CORE_PIN5_BITMASK;
  1275. } else if (pin == 6) {
  1276. CORE_PIN6_PORTSET = CORE_PIN6_BITMASK;
  1277. } else if (pin == 7) {
  1278. CORE_PIN7_PORTSET = CORE_PIN7_BITMASK;
  1279. } else if (pin == 8) {
  1280. CORE_PIN8_PORTSET = CORE_PIN8_BITMASK;
  1281. } else if (pin == 9) {
  1282. CORE_PIN9_PORTSET = CORE_PIN9_BITMASK;
  1283. } else if (pin == 10) {
  1284. CORE_PIN10_PORTSET = CORE_PIN10_BITMASK;
  1285. } else if (pin == 11) {
  1286. CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
  1287. } else if (pin == 12) {
  1288. CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
  1289. } else if (pin == 13) {
  1290. CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
  1291. } else if (pin == 14) {
  1292. CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
  1293. } else if (pin == 15) {
  1294. CORE_PIN15_PORTSET = CORE_PIN15_BITMASK;
  1295. } else if (pin == 16) {
  1296. CORE_PIN16_PORTSET = CORE_PIN16_BITMASK;
  1297. } else if (pin == 17) {
  1298. CORE_PIN17_PORTSET = CORE_PIN17_BITMASK;
  1299. } else if (pin == 18) {
  1300. CORE_PIN18_PORTSET = CORE_PIN18_BITMASK;
  1301. } else if (pin == 19) {
  1302. CORE_PIN19_PORTSET = CORE_PIN19_BITMASK;
  1303. } else if (pin == 20) {
  1304. CORE_PIN20_PORTSET = CORE_PIN20_BITMASK;
  1305. } else if (pin == 21) {
  1306. CORE_PIN21_PORTSET = CORE_PIN21_BITMASK;
  1307. } else if (pin == 22) {
  1308. CORE_PIN22_PORTSET = CORE_PIN22_BITMASK;
  1309. } else if (pin == 23) {
  1310. CORE_PIN23_PORTSET = CORE_PIN23_BITMASK;
  1311. } else if (pin == 24) {
  1312. CORE_PIN24_PORTSET = CORE_PIN24_BITMASK;
  1313. } else if (pin == 25) {
  1314. CORE_PIN25_PORTSET = CORE_PIN25_BITMASK;
  1315. } else if (pin == 26) {
  1316. CORE_PIN26_PORTSET = CORE_PIN26_BITMASK;
  1317. }
  1318. #if defined(CORE_PIN27_PORTSET)
  1319. else if (pin == 27) {
  1320. CORE_PIN27_PORTSET = CORE_PIN27_BITMASK;
  1321. } else if (pin == 28) {
  1322. CORE_PIN28_PORTSET = CORE_PIN28_BITMASK;
  1323. } else if (pin == 29) {
  1324. CORE_PIN29_PORTSET = CORE_PIN29_BITMASK;
  1325. } else if (pin == 30) {
  1326. CORE_PIN30_PORTSET = CORE_PIN30_BITMASK;
  1327. } else if (pin == 31) {
  1328. CORE_PIN31_PORTSET = CORE_PIN31_BITMASK;
  1329. } else if (pin == 32) {
  1330. CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
  1331. } else if (pin == 33) {
  1332. CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
  1333. }
  1334. #endif
  1335. #if defined(CORE_PIN34_PORTSET)
  1336. else if (pin == 34) {
  1337. CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
  1338. } else if (pin == 35) {
  1339. CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
  1340. } else if (pin == 36) {
  1341. CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
  1342. } else if (pin == 37) {
  1343. CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
  1344. } else if (pin == 38) {
  1345. CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
  1346. } else if (pin == 39) {
  1347. CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
  1348. } else if (pin == 40) {
  1349. CORE_PIN40_PORTSET = CORE_PIN40_BITMASK;
  1350. } else if (pin == 41) {
  1351. CORE_PIN41_PORTSET = CORE_PIN41_BITMASK;
  1352. } else if (pin == 42) {
  1353. CORE_PIN42_PORTSET = CORE_PIN42_BITMASK;
  1354. } else if (pin == 43) {
  1355. CORE_PIN43_PORTSET = CORE_PIN43_BITMASK;
  1356. } else if (pin == 44) {
  1357. CORE_PIN44_PORTSET = CORE_PIN44_BITMASK;
  1358. } else if (pin == 45) {
  1359. CORE_PIN45_PORTSET = CORE_PIN45_BITMASK;
  1360. } else if (pin == 46) {
  1361. CORE_PIN46_PORTSET = CORE_PIN46_BITMASK;
  1362. } else if (pin == 47) {
  1363. CORE_PIN47_PORTSET = CORE_PIN47_BITMASK;
  1364. } else if (pin == 48) {
  1365. CORE_PIN48_PORTSET = CORE_PIN48_BITMASK;
  1366. } else if (pin == 49) {
  1367. CORE_PIN49_PORTSET = CORE_PIN49_BITMASK;
  1368. } else if (pin == 50) {
  1369. CORE_PIN50_PORTSET = CORE_PIN50_BITMASK;
  1370. } else if (pin == 51) {
  1371. CORE_PIN51_PORTSET = CORE_PIN51_BITMASK;
  1372. } else if (pin == 52) {
  1373. CORE_PIN52_PORTSET = CORE_PIN52_BITMASK;
  1374. } else if (pin == 53) {
  1375. CORE_PIN53_PORTSET = CORE_PIN53_BITMASK;
  1376. } else if (pin == 54) {
  1377. CORE_PIN54_PORTSET = CORE_PIN54_BITMASK;
  1378. } else if (pin == 55) {
  1379. CORE_PIN55_PORTSET = CORE_PIN55_BITMASK;
  1380. } else if (pin == 56) {
  1381. CORE_PIN56_PORTSET = CORE_PIN56_BITMASK;
  1382. } else if (pin == 57) {
  1383. CORE_PIN57_PORTSET = CORE_PIN57_BITMASK;
  1384. }
  1385. #endif
  1386. } else {
  1387. if (pin == 0) {
  1388. CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;
  1389. } else if (pin == 1) {
  1390. CORE_PIN1_PORTCLEAR = CORE_PIN1_BITMASK;
  1391. } else if (pin == 2) {
  1392. CORE_PIN2_PORTCLEAR = CORE_PIN2_BITMASK;
  1393. } else if (pin == 3) {
  1394. CORE_PIN3_PORTCLEAR = CORE_PIN3_BITMASK;
  1395. } else if (pin == 4) {
  1396. CORE_PIN4_PORTCLEAR = CORE_PIN4_BITMASK;
  1397. } else if (pin == 5) {
  1398. CORE_PIN5_PORTCLEAR = CORE_PIN5_BITMASK;
  1399. } else if (pin == 6) {
  1400. CORE_PIN6_PORTCLEAR = CORE_PIN6_BITMASK;
  1401. } else if (pin == 7) {
  1402. CORE_PIN7_PORTCLEAR = CORE_PIN7_BITMASK;
  1403. } else if (pin == 8) {
  1404. CORE_PIN8_PORTCLEAR = CORE_PIN8_BITMASK;
  1405. } else if (pin == 9) {
  1406. CORE_PIN9_PORTCLEAR = CORE_PIN9_BITMASK;
  1407. } else if (pin == 10) {
  1408. CORE_PIN10_PORTCLEAR = CORE_PIN10_BITMASK;
  1409. } else if (pin == 11) {
  1410. CORE_PIN11_PORTCLEAR = CORE_PIN11_BITMASK;
  1411. } else if (pin == 12) {
  1412. CORE_PIN12_PORTCLEAR = CORE_PIN12_BITMASK;
  1413. } else if (pin == 13) {
  1414. CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
  1415. } else if (pin == 14) {
  1416. CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
  1417. } else if (pin == 15) {
  1418. CORE_PIN15_PORTCLEAR = CORE_PIN15_BITMASK;
  1419. } else if (pin == 16) {
  1420. CORE_PIN16_PORTCLEAR = CORE_PIN16_BITMASK;
  1421. } else if (pin == 17) {
  1422. CORE_PIN17_PORTCLEAR = CORE_PIN17_BITMASK;
  1423. } else if (pin == 18) {
  1424. CORE_PIN18_PORTCLEAR = CORE_PIN18_BITMASK;
  1425. } else if (pin == 19) {
  1426. CORE_PIN19_PORTCLEAR = CORE_PIN19_BITMASK;
  1427. } else if (pin == 20) {
  1428. CORE_PIN20_PORTCLEAR = CORE_PIN20_BITMASK;
  1429. } else if (pin == 21) {
  1430. CORE_PIN21_PORTCLEAR = CORE_PIN21_BITMASK;
  1431. } else if (pin == 22) {
  1432. CORE_PIN22_PORTCLEAR = CORE_PIN22_BITMASK;
  1433. } else if (pin == 23) {
  1434. CORE_PIN23_PORTCLEAR = CORE_PIN23_BITMASK;
  1435. } else if (pin == 24) {
  1436. CORE_PIN24_PORTCLEAR = CORE_PIN24_BITMASK;
  1437. } else if (pin == 25) {
  1438. CORE_PIN25_PORTCLEAR = CORE_PIN25_BITMASK;
  1439. } else if (pin == 26) {
  1440. CORE_PIN26_PORTCLEAR = CORE_PIN26_BITMASK;
  1441. }
  1442. #if defined(CORE_PIN27_PORTCLEAR)
  1443. else if (pin == 27) {
  1444. CORE_PIN27_PORTCLEAR = CORE_PIN27_BITMASK;
  1445. } else if (pin == 28) {
  1446. CORE_PIN28_PORTCLEAR = CORE_PIN28_BITMASK;
  1447. } else if (pin == 29) {
  1448. CORE_PIN29_PORTCLEAR = CORE_PIN29_BITMASK;
  1449. } else if (pin == 30) {
  1450. CORE_PIN30_PORTCLEAR = CORE_PIN30_BITMASK;
  1451. } else if (pin == 31) {
  1452. CORE_PIN31_PORTCLEAR = CORE_PIN31_BITMASK;
  1453. } else if (pin == 32) {
  1454. CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
  1455. } else if (pin == 33) {
  1456. CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
  1457. }
  1458. #endif
  1459. #if defined(CORE_PIN34_PORTCLEAR)
  1460. else if (pin == 34) {
  1461. CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
  1462. } else if (pin == 35) {
  1463. CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
  1464. } else if (pin == 36) {
  1465. CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
  1466. } else if (pin == 37) {
  1467. CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
  1468. } else if (pin == 38) {
  1469. CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
  1470. } else if (pin == 39) {
  1471. CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
  1472. } else if (pin == 40) {
  1473. CORE_PIN40_PORTCLEAR = CORE_PIN40_BITMASK;
  1474. } else if (pin == 41) {
  1475. CORE_PIN41_PORTCLEAR = CORE_PIN41_BITMASK;
  1476. } else if (pin == 42) {
  1477. CORE_PIN42_PORTCLEAR = CORE_PIN42_BITMASK;
  1478. } else if (pin == 43) {
  1479. CORE_PIN43_PORTCLEAR = CORE_PIN43_BITMASK;
  1480. } else if (pin == 44) {
  1481. CORE_PIN44_PORTCLEAR = CORE_PIN44_BITMASK;
  1482. } else if (pin == 45) {
  1483. CORE_PIN45_PORTCLEAR = CORE_PIN45_BITMASK;
  1484. } else if (pin == 46) {
  1485. CORE_PIN46_PORTCLEAR = CORE_PIN46_BITMASK;
  1486. } else if (pin == 47) {
  1487. CORE_PIN47_PORTCLEAR = CORE_PIN47_BITMASK;
  1488. } else if (pin == 48) {
  1489. CORE_PIN48_PORTCLEAR = CORE_PIN48_BITMASK;
  1490. } else if (pin == 49) {
  1491. CORE_PIN49_PORTCLEAR = CORE_PIN49_BITMASK;
  1492. } else if (pin == 50) {
  1493. CORE_PIN50_PORTCLEAR = CORE_PIN50_BITMASK;
  1494. } else if (pin == 51) {
  1495. CORE_PIN51_PORTCLEAR = CORE_PIN51_BITMASK;
  1496. } else if (pin == 52) {
  1497. CORE_PIN52_PORTCLEAR = CORE_PIN52_BITMASK;
  1498. } else if (pin == 53) {
  1499. CORE_PIN53_PORTCLEAR = CORE_PIN53_BITMASK;
  1500. } else if (pin == 54) {
  1501. CORE_PIN54_PORTCLEAR = CORE_PIN54_BITMASK;
  1502. } else if (pin == 55) {
  1503. CORE_PIN55_PORTCLEAR = CORE_PIN55_BITMASK;
  1504. } else if (pin == 56) {
  1505. CORE_PIN56_PORTCLEAR = CORE_PIN56_BITMASK;
  1506. } else if (pin == 57) {
  1507. CORE_PIN57_PORTCLEAR = CORE_PIN57_BITMASK;
  1508. }
  1509. #endif
  1510. }
  1511. } else {
  1512. if (val) {
  1513. *portSetRegister(pin) = digitalPinToBitMask(pin);
  1514. } else {
  1515. *portClearRegister(pin) = digitalPinToBitMask(pin);
  1516. }
  1517. }
  1518. }
  1519. uint8_t digitalRead(uint8_t pin);
  1520. static inline uint8_t digitalReadFast(uint8_t pin) __attribute__((always_inline, unused));
  1521. static inline uint8_t digitalReadFast(uint8_t pin)
  1522. {
  1523. if (__builtin_constant_p(pin)) {
  1524. if (pin == 0) {
  1525. return (CORE_PIN0_PINREG & CORE_PIN0_BITMASK) ? 1 : 0;
  1526. } else if (pin == 1) {
  1527. return (CORE_PIN1_PINREG & CORE_PIN1_BITMASK) ? 1 : 0;
  1528. } else if (pin == 2) {
  1529. return (CORE_PIN2_PINREG & CORE_PIN2_BITMASK) ? 1 : 0;
  1530. } else if (pin == 3) {
  1531. return (CORE_PIN3_PINREG & CORE_PIN3_BITMASK) ? 1 : 0;
  1532. } else if (pin == 4) {
  1533. return (CORE_PIN4_PINREG & CORE_PIN4_BITMASK) ? 1 : 0;
  1534. } else if (pin == 5) {
  1535. return (CORE_PIN5_PINREG & CORE_PIN5_BITMASK) ? 1 : 0;
  1536. } else if (pin == 6) {
  1537. return (CORE_PIN6_PINREG & CORE_PIN6_BITMASK) ? 1 : 0;
  1538. } else if (pin == 7) {
  1539. return (CORE_PIN7_PINREG & CORE_PIN7_BITMASK) ? 1 : 0;
  1540. } else if (pin == 8) {
  1541. return (CORE_PIN8_PINREG & CORE_PIN8_BITMASK) ? 1 : 0;
  1542. } else if (pin == 9) {
  1543. return (CORE_PIN9_PINREG & CORE_PIN9_BITMASK) ? 1 : 0;
  1544. } else if (pin == 10) {
  1545. return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
  1546. } else if (pin == 11) {
  1547. return (CORE_PIN11_PINREG & CORE_PIN11_BITMASK) ? 1 : 0;
  1548. } else if (pin == 12) {
  1549. return (CORE_PIN12_PINREG & CORE_PIN12_BITMASK) ? 1 : 0;
  1550. } else if (pin == 13) {
  1551. return (CORE_PIN13_PINREG & CORE_PIN13_BITMASK) ? 1 : 0;
  1552. } else if (pin == 14) {
  1553. return (CORE_PIN14_PINREG & CORE_PIN14_BITMASK) ? 1 : 0;
  1554. } else if (pin == 15) {
  1555. return (CORE_PIN15_PINREG & CORE_PIN15_BITMASK) ? 1 : 0;
  1556. } else if (pin == 16) {
  1557. return (CORE_PIN16_PINREG & CORE_PIN16_BITMASK) ? 1 : 0;
  1558. } else if (pin == 17) {
  1559. return (CORE_PIN17_PINREG & CORE_PIN17_BITMASK) ? 1 : 0;
  1560. } else if (pin == 18) {
  1561. return (CORE_PIN18_PINREG & CORE_PIN18_BITMASK) ? 1 : 0;
  1562. } else if (pin == 19) {
  1563. return (CORE_PIN19_PINREG & CORE_PIN19_BITMASK) ? 1 : 0;
  1564. } else if (pin == 20) {
  1565. return (CORE_PIN20_PINREG & CORE_PIN20_BITMASK) ? 1 : 0;
  1566. } else if (pin == 21) {
  1567. return (CORE_PIN21_PINREG & CORE_PIN21_BITMASK) ? 1 : 0;
  1568. } else if (pin == 22) {
  1569. return (CORE_PIN22_PINREG & CORE_PIN22_BITMASK) ? 1 : 0;
  1570. } else if (pin == 23) {
  1571. return (CORE_PIN23_PINREG & CORE_PIN23_BITMASK) ? 1 : 0;
  1572. } else if (pin == 24) {
  1573. return (CORE_PIN24_PINREG & CORE_PIN24_BITMASK) ? 1 : 0;
  1574. } else if (pin == 25) {
  1575. return (CORE_PIN25_PINREG & CORE_PIN25_BITMASK) ? 1 : 0;
  1576. } else if (pin == 26) {
  1577. return (CORE_PIN26_PINREG & CORE_PIN26_BITMASK) ? 1 : 0;
  1578. }
  1579. #if defined(CORE_PIN27_PINREG)
  1580. else if (pin == 27) {
  1581. return (CORE_PIN27_PINREG & CORE_PIN27_BITMASK) ? 1 : 0;
  1582. } else if (pin == 28) {
  1583. return (CORE_PIN28_PINREG & CORE_PIN28_BITMASK) ? 1 : 0;
  1584. } else if (pin == 29) {
  1585. return (CORE_PIN29_PINREG & CORE_PIN29_BITMASK) ? 1 : 0;
  1586. } else if (pin == 30) {
  1587. return (CORE_PIN30_PINREG & CORE_PIN30_BITMASK) ? 1 : 0;
  1588. } else if (pin == 31) {
  1589. return (CORE_PIN31_PINREG & CORE_PIN31_BITMASK) ? 1 : 0;
  1590. } else if (pin == 32) {
  1591. return (CORE_PIN32_PINREG & CORE_PIN32_BITMASK) ? 1 : 0;
  1592. } else if (pin == 33) {
  1593. return (CORE_PIN33_PINREG & CORE_PIN33_BITMASK) ? 1 : 0;
  1594. }
  1595. #endif
  1596. #if defined(CORE_PIN34_PINREG)
  1597. else if (pin == 34) {
  1598. return (CORE_PIN34_PINREG & CORE_PIN34_BITMASK) ? 1 : 0;
  1599. } else if (pin == 35) {
  1600. return (CORE_PIN35_PINREG & CORE_PIN35_BITMASK) ? 1 : 0;
  1601. } else if (pin == 36) {
  1602. return (CORE_PIN36_PINREG & CORE_PIN36_BITMASK) ? 1 : 0;
  1603. } else if (pin == 37) {
  1604. return (CORE_PIN37_PINREG & CORE_PIN37_BITMASK) ? 1 : 0;
  1605. } else if (pin == 38) {
  1606. return (CORE_PIN38_PINREG & CORE_PIN38_BITMASK) ? 1 : 0;
  1607. } else if (pin == 39) {
  1608. return (CORE_PIN39_PINREG & CORE_PIN39_BITMASK) ? 1 : 0;
  1609. } else if (pin == 40) {
  1610. return (CORE_PIN40_PINREG & CORE_PIN40_BITMASK) ? 1 : 0;
  1611. } else if (pin == 41) {
  1612. return (CORE_PIN41_PINREG & CORE_PIN41_BITMASK) ? 1 : 0;
  1613. } else if (pin == 42) {
  1614. return (CORE_PIN42_PINREG & CORE_PIN42_BITMASK) ? 1 : 0;
  1615. } else if (pin == 43) {
  1616. return (CORE_PIN43_PINREG & CORE_PIN43_BITMASK) ? 1 : 0;
  1617. } else if (pin == 44) {
  1618. return (CORE_PIN44_PINREG & CORE_PIN44_BITMASK) ? 1 : 0;
  1619. } else if (pin == 45) {
  1620. return (CORE_PIN45_PINREG & CORE_PIN45_BITMASK) ? 1 : 0;
  1621. } else if (pin == 46) {
  1622. return (CORE_PIN46_PINREG & CORE_PIN46_BITMASK) ? 1 : 0;
  1623. } else if (pin == 47) {
  1624. return (CORE_PIN47_PINREG & CORE_PIN47_BITMASK) ? 1 : 0;
  1625. } else if (pin == 48) {
  1626. return (CORE_PIN48_PINREG & CORE_PIN48_BITMASK) ? 1 : 0;
  1627. } else if (pin == 49) {
  1628. return (CORE_PIN49_PINREG & CORE_PIN49_BITMASK) ? 1 : 0;
  1629. } else if (pin == 50) {
  1630. return (CORE_PIN50_PINREG & CORE_PIN50_BITMASK) ? 1 : 0;
  1631. } else if (pin == 51) {
  1632. return (CORE_PIN51_PINREG & CORE_PIN51_BITMASK) ? 1 : 0;
  1633. } else if (pin == 52) {
  1634. return (CORE_PIN52_PINREG & CORE_PIN52_BITMASK) ? 1 : 0;
  1635. } else if (pin == 53) {
  1636. return (CORE_PIN53_PINREG & CORE_PIN53_BITMASK) ? 1 : 0;
  1637. } else if (pin == 54) {
  1638. return (CORE_PIN54_PINREG & CORE_PIN54_BITMASK) ? 1 : 0;
  1639. } else if (pin == 55) {
  1640. return (CORE_PIN55_PINREG & CORE_PIN55_BITMASK) ? 1 : 0;
  1641. } else if (pin == 56) {
  1642. return (CORE_PIN56_PINREG & CORE_PIN56_BITMASK) ? 1 : 0;
  1643. } else if (pin == 57) {
  1644. return (CORE_PIN57_PINREG & CORE_PIN57_BITMASK) ? 1 : 0;
  1645. }
  1646. #endif
  1647. else {
  1648. return 0;
  1649. }
  1650. } else {
  1651. #if defined(KINETISK)
  1652. return *portInputRegister(pin);
  1653. #else
  1654. return (*portInputRegister(pin) & digitalPinToBitMask(pin)) ? 1 : 0;
  1655. #endif
  1656. }
  1657. }
  1658. void pinMode(uint8_t pin, uint8_t mode);
  1659. void init_pins(void);
  1660. void analogWrite(uint8_t pin, int val);
  1661. void analogWriteRes(uint32_t bits);
  1662. static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); }
  1663. void analogWriteFrequency(uint8_t pin, float frequency);
  1664. void analogWriteDAC0(int val);
  1665. void analogWriteDAC1(int val);
  1666. #ifdef __cplusplus
  1667. void attachInterruptVector(IRQ_NUMBER_t irq, void (*function)(void));
  1668. #else
  1669. void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void));
  1670. #endif
  1671. void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
  1672. void detachInterrupt(uint8_t pin);
  1673. void _init_Teensyduino_internal_(void);
  1674. int analogRead(uint8_t pin);
  1675. void analogReference(uint8_t type);
  1676. void analogReadRes(unsigned int bits);
  1677. static inline void analogReadResolution(unsigned int bits) { analogReadRes(bits); }
  1678. void analogReadAveraging(unsigned int num);
  1679. void analog_init(void);
  1680. #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
  1681. #define DEFAULT 0
  1682. #define INTERNAL 2
  1683. #define INTERNAL1V2 2
  1684. #define INTERNAL1V1 2
  1685. #define EXTERNAL 0
  1686. #elif defined(__MKL26Z64__)
  1687. #define DEFAULT 0
  1688. #define INTERNAL 0
  1689. #define EXTERNAL 1
  1690. #endif
  1691. int touchRead(uint8_t pin);
  1692. static inline void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1693. extern void _shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) __attribute__((noinline));
  1694. extern void shiftOut_lsbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1695. extern void shiftOut_msbFirst(uint8_t dataPin, uint8_t clockPin, uint8_t value) __attribute__((noinline));
  1696. static inline void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
  1697. {
  1698. if (__builtin_constant_p(bitOrder)) {
  1699. if (bitOrder == LSBFIRST) {
  1700. shiftOut_lsbFirst(dataPin, clockPin, value);
  1701. } else {
  1702. shiftOut_msbFirst(dataPin, clockPin, value);
  1703. }
  1704. } else {
  1705. _shiftOut(dataPin, clockPin, bitOrder, value);
  1706. }
  1707. }
  1708. static inline uint8_t shiftIn(uint8_t, uint8_t, uint8_t) __attribute__((always_inline, unused));
  1709. extern uint8_t _shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) __attribute__((noinline));
  1710. extern uint8_t shiftIn_lsbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1711. extern uint8_t shiftIn_msbFirst(uint8_t dataPin, uint8_t clockPin) __attribute__((noinline));
  1712. static inline uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
  1713. {
  1714. if (__builtin_constant_p(bitOrder)) {
  1715. if (bitOrder == LSBFIRST) {
  1716. return shiftIn_lsbFirst(dataPin, clockPin);
  1717. } else {
  1718. return shiftIn_msbFirst(dataPin, clockPin);
  1719. }
  1720. } else {
  1721. return _shiftIn(dataPin, clockPin, bitOrder);
  1722. }
  1723. }
  1724. void _reboot_Teensyduino_(void) __attribute__((noreturn));
  1725. void _restart_Teensyduino_(void) __attribute__((noreturn));
  1726. void yield(void);
  1727. void delay(uint32_t msec);
  1728. extern volatile uint32_t systick_millis_count;
  1729. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  1730. static inline uint32_t millis(void)
  1731. {
  1732. // Reading a volatile variable to another volatile
  1733. // seems redundant, but isn't for some cases.
  1734. // Eventually this should probably be replaced by a
  1735. // proper memory barrier or other technique. Please
  1736. // do not remove this "redundant" code without
  1737. // carefully verifying the case mentioned here:
  1738. //
  1739. // https://forum.pjrc.com/threads/17469-millis%28%29-on-teensy-3?p=104924&viewfull=1#post104924
  1740. //
  1741. volatile uint32_t ret = systick_millis_count; // single aligned 32 bit is atomic
  1742. return ret;
  1743. }
  1744. uint32_t micros(void);
  1745. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  1746. static inline void delayMicroseconds(uint32_t usec)
  1747. {
  1748. #if F_CPU == 240000000
  1749. uint32_t n = usec * 80;
  1750. #elif F_CPU == 216000000
  1751. uint32_t n = usec * 72;
  1752. #elif F_CPU == 192000000
  1753. uint32_t n = usec * 64;
  1754. #elif F_CPU == 180000000
  1755. uint32_t n = usec * 60;
  1756. #elif F_CPU == 168000000
  1757. uint32_t n = usec * 56;
  1758. #elif F_CPU == 144000000
  1759. uint32_t n = usec * 48;
  1760. #elif F_CPU == 120000000
  1761. uint32_t n = usec * 40;
  1762. #elif F_CPU == 96000000
  1763. uint32_t n = usec << 5;
  1764. #elif F_CPU == 72000000
  1765. uint32_t n = usec * 24;
  1766. #elif F_CPU == 48000000
  1767. uint32_t n = usec << 4;
  1768. #elif F_CPU == 24000000
  1769. uint32_t n = usec << 3;
  1770. #elif F_CPU == 16000000
  1771. uint32_t n = usec << 2;
  1772. #elif F_CPU == 8000000
  1773. uint32_t n = usec << 1;
  1774. #elif F_CPU == 4000000
  1775. uint32_t n = usec;
  1776. #elif F_CPU == 2000000
  1777. uint32_t n = usec >> 1;
  1778. #endif
  1779. // changed because a delay of 1 micro Sec @ 2MHz will be 0
  1780. if (n == 0) return;
  1781. __asm__ volatile(
  1782. "L_%=_delayMicroseconds:" "\n\t"
  1783. #if F_CPU < 24000000
  1784. "nop" "\n\t"
  1785. #endif
  1786. #ifdef KINETISL
  1787. "sub %0, #1" "\n\t"
  1788. #else
  1789. "subs %0, #1" "\n\t"
  1790. #endif
  1791. "bne L_%=_delayMicroseconds" "\n"
  1792. : "+r" (n) :
  1793. );
  1794. }
  1795. #ifdef __cplusplus
  1796. }
  1797. #endif
  1798. #ifdef __cplusplus
  1799. extern "C" {
  1800. #endif
  1801. unsigned long rtc_get(void);
  1802. void rtc_set(unsigned long t);
  1803. void rtc_compensate(int adjust);
  1804. #ifdef __cplusplus
  1805. }
  1806. class teensy3_clock_class
  1807. {
  1808. public:
  1809. static unsigned long get(void) __attribute__((always_inline)) { return rtc_get(); }
  1810. static void set(unsigned long t) __attribute__((always_inline)) { rtc_set(t); }
  1811. static void compensate(int adj) __attribute__((always_inline)) { rtc_compensate(adj); }
  1812. };
  1813. extern teensy3_clock_class Teensy3Clock;
  1814. #endif
  1815. #endif