board.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. #include "pin_mux.h"
  14. #include "fsl_iomuxc.h"
  15. #include "fsl_gpio.h"
  16. #ifdef BSP_USING_DMA
  17. #include "fsl_dmamux.h"
  18. #include "fsl_edma.h"
  19. #endif
  20. #define NVIC_PRIORITYGROUP_0 0x00000007U /*!< 0 bits for pre-emption priority
  21. 4 bits for subpriority */
  22. #define NVIC_PRIORITYGROUP_1 0x00000006U /*!< 1 bits for pre-emption priority
  23. 3 bits for subpriority */
  24. #define NVIC_PRIORITYGROUP_2 0x00000005U /*!< 2 bits for pre-emption priority
  25. 2 bits for subpriority */
  26. #define NVIC_PRIORITYGROUP_3 0x00000004U /*!< 3 bits for pre-emption priority
  27. 1 bits for subpriority */
  28. #define NVIC_PRIORITYGROUP_4 0x00000003U /*!< 4 bits for pre-emption priority
  29. 0 bits for subpriority */
  30. /* MPU configuration. */
  31. static void BOARD_ConfigMPU(void)
  32. {
  33. /* Disable I cache and D cache */
  34. SCB_DisableICache();
  35. SCB_DisableDCache();
  36. /* Disable MPU */
  37. ARM_MPU_Disable();
  38. /* Region 0 setting */
  39. MPU->RBAR = ARM_MPU_RBAR(0, 0xC0000000U);
  40. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB);
  41. /* Region 1 setting */
  42. MPU->RBAR = ARM_MPU_RBAR(1, 0x80000000U);
  43. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);
  44. /* Region 2 setting */
  45. // spi flash: normal type, cacheable, no bufferable, no shareable
  46. MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U);
  47. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_512MB);
  48. /* Region 3 setting */
  49. MPU->RBAR = ARM_MPU_RBAR(3, 0x00000000U);
  50. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);
  51. /* Region 4 setting */
  52. MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U);
  53. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
  54. /* Region 5 setting */
  55. MPU->RBAR = ARM_MPU_RBAR(5, 0x20000000U);
  56. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
  57. /* Region 6 setting */
  58. MPU->RBAR = ARM_MPU_RBAR(6, 0x20200000U);
  59. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);
  60. #if defined(BSP_USING_SDRAM)
  61. /* Region 7 setting */
  62. MPU->RBAR = ARM_MPU_RBAR(7, 0x80000000U);
  63. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB);
  64. /* Region 8 setting */
  65. MPU->RBAR = ARM_MPU_RBAR(8, 0x81E00000U);
  66. MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 1, 0, 0, 0, ARM_MPU_REGION_SIZE_2MB);
  67. #endif
  68. /* Enable MPU */
  69. ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk);
  70. /* Enable I cache and D cache */
  71. SCB_EnableDCache();
  72. SCB_EnableICache();
  73. }
  74. /* This is the timer interrupt service routine. */
  75. void SysTick_Handler(void)
  76. {
  77. /* enter interrupt */
  78. rt_interrupt_enter();
  79. rt_tick_increase();
  80. /* leave interrupt */
  81. rt_interrupt_leave();
  82. }
  83. #ifdef BSP_USING_DMA
  84. void imxrt_dma_init(void)
  85. {
  86. edma_config_t config;
  87. DMAMUX_Init(DMAMUX);
  88. EDMA_GetDefaultConfig(&config);
  89. EDMA_Init(DMA0, &config);
  90. }
  91. #endif
  92. #ifdef BSP_USING_LPUART
  93. void imxrt_uart_pins_init(void)
  94. {
  95. #ifdef BSP_USING_LPUART1
  96. IOMUXC_SetPinMux(
  97. IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 is configured as LPUART1_TX */
  98. 0U); /* Software Input On Field: Input Path is determined by functionality */
  99. IOMUXC_SetPinMux(
  100. IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 is configured as LPUART1_RX */
  101. 0U); /* Software Input On Field: Input Path is determined by functionality */
  102. IOMUXC_SetPinConfig(
  103. IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 PAD functional properties : */
  104. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  105. Drive Strength Field: R0/6
  106. Speed Field: medium(100MHz)
  107. Open Drain Enable Field: Open Drain Disabled
  108. Pull / Keep Enable Field: Pull/Keeper Enabled
  109. Pull / Keep Select Field: Keeper
  110. Pull Up / Down Config. Field: 100K Ohm Pull Down
  111. Hyst. Enable Field: Hysteresis Disabled */
  112. IOMUXC_SetPinConfig(
  113. IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 PAD functional properties : */
  114. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  115. Drive Strength Field: R0/6
  116. Speed Field: medium(100MHz)
  117. Open Drain Enable Field: Open Drain Disabled
  118. Pull / Keep Enable Field: Pull/Keeper Enabled
  119. Pull / Keep Select Field: Keeper
  120. Pull Up / Down Config. Field: 100K Ohm Pull Down
  121. Hyst. Enable Field: Hysteresis Disabled */
  122. #endif
  123. #ifdef BSP_USING_LPUART2
  124. IOMUXC_SetPinMux(
  125. IOMUXC_GPIO_AD_B1_02_LPUART2_TX,
  126. 0U);
  127. IOMUXC_SetPinMux(
  128. IOMUXC_GPIO_AD_B1_03_LPUART2_RX,
  129. 0U);
  130. IOMUXC_SetPinConfig(
  131. IOMUXC_GPIO_AD_B1_02_LPUART2_TX,
  132. 0x10B0u);
  133. IOMUXC_SetPinConfig(
  134. IOMUXC_GPIO_AD_B1_03_LPUART2_RX,
  135. 0x10B0u);
  136. #endif
  137. #ifdef BSP_USING_LPUART3
  138. IOMUXC_SetPinMux(
  139. IOMUXC_GPIO_AD_B1_06_LPUART3_TX,
  140. 0U);
  141. IOMUXC_SetPinMux(
  142. IOMUXC_GPIO_AD_B1_07_LPUART3_RX,
  143. 0U);
  144. IOMUXC_SetPinConfig(
  145. IOMUXC_GPIO_AD_B1_06_LPUART3_TX,
  146. 0x10B0u);
  147. IOMUXC_SetPinConfig(
  148. IOMUXC_GPIO_AD_B1_07_LPUART3_RX,
  149. 0x10B0u);
  150. #endif
  151. #ifdef BSP_USING_LPUART4
  152. IOMUXC_SetPinMux(
  153. IOMUXC_GPIO_B1_00_LPUART4_TX,
  154. 0U);
  155. IOMUXC_SetPinMux(
  156. IOMUXC_GPIO_B1_01_LPUART4_RX,
  157. 0U);
  158. IOMUXC_SetPinConfig(
  159. IOMUXC_GPIO_B1_00_LPUART4_TX,
  160. 0x10B0u);
  161. IOMUXC_SetPinConfig(
  162. IOMUXC_GPIO_B1_01_LPUART4_RX,
  163. 0x10B0u);
  164. #endif
  165. #ifdef BSP_USING_LPUART5
  166. IOMUXC_SetPinMux(
  167. IOMUXC_GPIO_B1_12_LPUART5_TX,
  168. 0U);
  169. IOMUXC_SetPinMux(
  170. IOMUXC_GPIO_B1_13_LPUART5_RX,
  171. 0U);
  172. IOMUXC_SetPinConfig(
  173. IOMUXC_GPIO_B1_12_LPUART5_TX,
  174. 0x10B0u);
  175. IOMUXC_SetPinConfig(
  176. IOMUXC_GPIO_B1_13_LPUART5_RX,
  177. 0x10B0u);
  178. #endif
  179. #ifdef BSP_USING_LPUART6
  180. IOMUXC_SetPinMux(
  181. IOMUXC_GPIO_AD_B0_02_LPUART6_TX,
  182. 0U);
  183. IOMUXC_SetPinMux(
  184. IOMUXC_GPIO_AD_B0_03_LPUART6_RX,
  185. 0U);
  186. IOMUXC_SetPinConfig(
  187. IOMUXC_GPIO_AD_B0_02_LPUART6_TX,
  188. 0x10B0u);
  189. IOMUXC_SetPinConfig(
  190. IOMUXC_GPIO_AD_B0_03_LPUART6_RX,
  191. 0x10B0u);
  192. #endif
  193. #ifdef BSP_USING_LPUART7
  194. IOMUXC_SetPinMux(
  195. IOMUXC_GPIO_EMC_31_LPUART7_TX,
  196. 0U);
  197. IOMUXC_SetPinMux(
  198. IOMUXC_GPIO_EMC_32_LPUART7_RX,
  199. 0U);
  200. IOMUXC_SetPinConfig(
  201. IOMUXC_GPIO_EMC_31_LPUART7_TX,
  202. 0x10B0u);
  203. IOMUXC_SetPinConfig(
  204. IOMUXC_GPIO_EMC_32_LPUART7_RX,
  205. 0x10B0u);
  206. #endif
  207. #ifdef BSP_USING_LPUART8
  208. IOMUXC_SetPinMux(
  209. IOMUXC_GPIO_AD_B1_10_LPUART8_TX,
  210. 0U);
  211. IOMUXC_SetPinMux(
  212. IOMUXC_GPIO_AD_B1_11_LPUART8_RX,
  213. 0U);
  214. IOMUXC_SetPinConfig(
  215. IOMUXC_GPIO_AD_B1_10_LPUART8_TX,
  216. 0x10B0u);
  217. IOMUXC_SetPinConfig(
  218. IOMUXC_GPIO_AD_B1_11_LPUART8_RX,
  219. 0x10B0u);
  220. #endif
  221. }
  222. #endif /* BSP_USING_LPUART */
  223. #ifdef BSP_USING_ETH
  224. void imxrt_enet_pins_init(void)
  225. {
  226. CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */
  227. IOMUXC_SetPinMux(
  228. IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */
  229. 0U); /* Software Input On Field: Input Path is determined by functionality */
  230. IOMUXC_SetPinMux(
  231. IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 is configured as GPIO1_IO10 */
  232. 0U);
  233. IOMUXC_SetPinMux(
  234. IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 is configured as ENET_RX_DATA00 */
  235. 0U); /* Software Input On Field: Input Path is determined by functionality */
  236. IOMUXC_SetPinMux(
  237. IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 is configured as ENET_RX_DATA01 */
  238. 0U); /* Software Input On Field: Input Path is determined by functionality */
  239. IOMUXC_SetPinMux(
  240. IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 is configured as ENET_RX_EN */
  241. 0U); /* Software Input On Field: Input Path is determined by functionality */
  242. IOMUXC_SetPinMux(
  243. IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 is configured as ENET_TX_DATA00 */
  244. 0U); /* Software Input On Field: Input Path is determined by functionality */
  245. IOMUXC_SetPinMux(
  246. IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 is configured as ENET_TX_DATA01 */
  247. 0U); /* Software Input On Field: Input Path is determined by functionality */
  248. IOMUXC_SetPinMux(
  249. IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 is configured as ENET_TX_EN */
  250. 0U); /* Software Input On Field: Input Path is determined by functionality */
  251. IOMUXC_SetPinMux(
  252. IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 is configured as ENET_REF_CLK */
  253. 1U); /* Software Input On Field: Force input path of pad GPIO_B1_10 */
  254. IOMUXC_SetPinMux(
  255. IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 is configured as ENET_RX_ER */
  256. 0U); /* Software Input On Field: Input Path is determined by functionality */
  257. IOMUXC_SetPinMux(
  258. IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 is configured as ENET_MDC */
  259. 0U); /* Software Input On Field: Input Path is determined by functionality */
  260. IOMUXC_SetPinMux(
  261. IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 is configured as ENET_MDIO */
  262. 0U); /* Software Input On Field: Input Path is determined by functionality */
  263. IOMUXC_SetPinConfig(
  264. IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 PAD functional properties : */
  265. 0xB0A9u); /* Slew Rate Field: Fast Slew Rate
  266. Drive Strength Field: R0/5
  267. Speed Field: medium(100MHz)
  268. Open Drain Enable Field: Open Drain Disabled
  269. Pull / Keep Enable Field: Pull/Keeper Enabled
  270. Pull / Keep Select Field: Pull
  271. Pull Up / Down Config. Field: 100K Ohm Pull Up
  272. Hyst. Enable Field: Hysteresis Disabled */
  273. IOMUXC_SetPinConfig(
  274. IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 PAD functional properties : */
  275. 0xB0A9u); /* Slew Rate Field: Fast Slew Rate
  276. Drive Strength Field: R0/5
  277. Speed Field: medium(100MHz)
  278. Open Drain Enable Field: Open Drain Disabled
  279. Pull / Keep Enable Field: Pull/Keeper Enabled
  280. Pull / Keep Select Field: Pull
  281. Pull Up / Down Config. Field: 100K Ohm Pull Up
  282. Hyst. Enable Field: Hysteresis Disabled */
  283. IOMUXC_SetPinConfig(
  284. IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 PAD functional properties : */
  285. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  286. Drive Strength Field: R0/5
  287. Speed Field: max(200MHz)
  288. Open Drain Enable Field: Open Drain Disabled
  289. Pull / Keep Enable Field: Pull/Keeper Enabled
  290. Pull / Keep Select Field: Pull
  291. Pull Up / Down Config. Field: 100K Ohm Pull Up
  292. Hyst. Enable Field: Hysteresis Disabled */
  293. IOMUXC_SetPinConfig(
  294. IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 PAD functional properties : */
  295. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  296. Drive Strength Field: R0/5
  297. Speed Field: max(200MHz)
  298. Open Drain Enable Field: Open Drain Disabled
  299. Pull / Keep Enable Field: Pull/Keeper Enabled
  300. Pull / Keep Select Field: Pull
  301. Pull Up / Down Config. Field: 100K Ohm Pull Up
  302. Hyst. Enable Field: Hysteresis Disabled */
  303. IOMUXC_SetPinConfig(
  304. IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 PAD functional properties : */
  305. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  306. Drive Strength Field: R0/5
  307. Speed Field: max(200MHz)
  308. Open Drain Enable Field: Open Drain Disabled
  309. Pull / Keep Enable Field: Pull/Keeper Enabled
  310. Pull / Keep Select Field: Pull
  311. Pull Up / Down Config. Field: 100K Ohm Pull Up
  312. Hyst. Enable Field: Hysteresis Disabled */
  313. IOMUXC_SetPinConfig(
  314. IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 PAD functional properties : */
  315. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  316. Drive Strength Field: R0/5
  317. Speed Field: max(200MHz)
  318. Open Drain Enable Field: Open Drain Disabled
  319. Pull / Keep Enable Field: Pull/Keeper Enabled
  320. Pull / Keep Select Field: Pull
  321. Pull Up / Down Config. Field: 100K Ohm Pull Up
  322. Hyst. Enable Field: Hysteresis Disabled */
  323. IOMUXC_SetPinConfig(
  324. IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 PAD functional properties : */
  325. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  326. Drive Strength Field: R0/5
  327. Speed Field: max(200MHz)
  328. Open Drain Enable Field: Open Drain Disabled
  329. Pull / Keep Enable Field: Pull/Keeper Enabled
  330. Pull / Keep Select Field: Pull
  331. Pull Up / Down Config. Field: 100K Ohm Pull Up
  332. Hyst. Enable Field: Hysteresis Disabled */
  333. IOMUXC_SetPinConfig(
  334. IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 PAD functional properties : */
  335. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  336. Drive Strength Field: R0/5
  337. Speed Field: max(200MHz)
  338. Open Drain Enable Field: Open Drain Disabled
  339. Pull / Keep Enable Field: Pull/Keeper Enabled
  340. Pull / Keep Select Field: Pull
  341. Pull Up / Down Config. Field: 100K Ohm Pull Up
  342. Hyst. Enable Field: Hysteresis Disabled */
  343. IOMUXC_SetPinConfig(
  344. IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 PAD functional properties : */
  345. 0x31u); /* Slew Rate Field: Fast Slew Rate
  346. Drive Strength Field: R0/6
  347. Speed Field: low(50MHz)
  348. Open Drain Enable Field: Open Drain Disabled
  349. Pull / Keep Enable Field: Pull/Keeper Disabled
  350. Pull / Keep Select Field: Keeper
  351. Pull Up / Down Config. Field: 100K Ohm Pull Down
  352. Hyst. Enable Field: Hysteresis Disabled */
  353. IOMUXC_SetPinConfig(
  354. IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 PAD functional properties : */
  355. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  356. Drive Strength Field: R0/5
  357. Speed Field: max(200MHz)
  358. Open Drain Enable Field: Open Drain Disabled
  359. Pull / Keep Enable Field: Pull/Keeper Enabled
  360. Pull / Keep Select Field: Pull
  361. Pull Up / Down Config. Field: 100K Ohm Pull Up
  362. Hyst. Enable Field: Hysteresis Disabled */
  363. IOMUXC_SetPinConfig(
  364. IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 PAD functional properties : */
  365. 0xB0E9u); /* Slew Rate Field: Fast Slew Rate
  366. Drive Strength Field: R0/5
  367. Speed Field: max(200MHz)
  368. Open Drain Enable Field: Open Drain Disabled
  369. Pull / Keep Enable Field: Pull/Keeper Enabled
  370. Pull / Keep Select Field: Pull
  371. Pull Up / Down Config. Field: 100K Ohm Pull Up
  372. Hyst. Enable Field: Hysteresis Disabled */
  373. IOMUXC_SetPinConfig(
  374. IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 PAD functional properties : */
  375. 0xB829u); /* Slew Rate Field: Fast Slew Rate
  376. Drive Strength Field: R0/5
  377. Speed Field: low(50MHz)
  378. Open Drain Enable Field: Open Drain Enabled
  379. Pull / Keep Enable Field: Pull/Keeper Enabled
  380. Pull / Keep Select Field: Pull
  381. Pull Up / Down Config. Field: 100K Ohm Pull Up
  382. Hyst. Enable Field: Hysteresis Disabled */
  383. }
  384. void imxrt_enet_phy_reset_by_gpio(void)
  385. {
  386. gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
  387. GPIO_PinInit(GPIO1, 9, &gpio_config);
  388. GPIO_PinInit(GPIO1, 10, &gpio_config);
  389. /* pull up the ENET_INT before RESET. */
  390. GPIO_WritePinOutput(GPIO1, 10, 1);
  391. GPIO_WritePinOutput(GPIO1, 9, 0);
  392. rt_thread_delay(100);
  393. GPIO_WritePinOutput(GPIO1, 9, 1);
  394. }
  395. #endif /* BSP_USING_ETH */
  396. #ifdef BSP_USING_AUDIO
  397. void imxrt_sai_pins_init(void)
  398. { /* Software Input On Field: Input Path is determined by functionality */
  399. IOMUXC_SetPinMux(
  400. IOMUXC_GPIO_AD_B1_00_LPI2C1_SCL, /* GPIO_AD_B1_00 is configured as LPI2C1_SCL */
  401. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_00 */
  402. IOMUXC_SetPinMux(
  403. IOMUXC_GPIO_AD_B1_01_LPI2C1_SDA, /* GPIO_AD_B1_01 is configured as LPI2C1_SDA */
  404. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_01 */
  405. IOMUXC_SetPinMux(
  406. IOMUXC_GPIO_AD_B1_09_SAI1_MCLK, /* GPIO_AD_B1_09 is configured as SAI1_MCLK */
  407. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_09 */
  408. IOMUXC_SetPinMux(
  409. IOMUXC_GPIO_AD_B1_12_SAI1_RX_DATA00, /* GPIO_AD_B1_12 is configured as SAI1_RX_DATA00 */
  410. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_12 */
  411. IOMUXC_SetPinMux(
  412. IOMUXC_GPIO_AD_B1_13_SAI1_TX_DATA00, /* GPIO_AD_B1_13 is configured as SAI1_TX_DATA00 */
  413. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_13 */
  414. IOMUXC_SetPinMux(
  415. IOMUXC_GPIO_AD_B1_14_SAI1_TX_BCLK, /* GPIO_AD_B1_14 is configured as SAI1_TX_BCLK */
  416. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_14 */
  417. IOMUXC_SetPinMux(
  418. IOMUXC_GPIO_AD_B1_15_SAI1_TX_SYNC, /* GPIO_AD_B1_15 is configured as SAI1_TX_SYNC */
  419. 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_15 */
  420. IOMUXC_SetPinConfig(
  421. IOMUXC_GPIO_AD_B1_00_LPI2C1_SCL, /* GPIO_AD_B1_00 PAD functional properties : */
  422. 0xD8B0u); /* Slew Rate Field: Slow Slew Rate
  423. Drive Strength Field: R0/6
  424. Speed Field: medium(100MHz)
  425. Open Drain Enable Field: Open Drain Enabled
  426. Pull / Keep Enable Field: Pull/Keeper Enabled
  427. Pull / Keep Select Field: Keeper
  428. Pull Up / Down Config. Field: 22K Ohm Pull Up
  429. Hyst. Enable Field: Hysteresis Disabled */
  430. IOMUXC_SetPinConfig(
  431. IOMUXC_GPIO_AD_B1_01_LPI2C1_SDA, /* GPIO_AD_B1_01 PAD functional properties : */
  432. 0xD8B0u); /* Slew Rate Field: Slow Slew Rate
  433. Drive Strength Field: R0/6
  434. Speed Field: medium(100MHz)
  435. Open Drain Enable Field: Open Drain Enabled
  436. Pull / Keep Enable Field: Pull/Keeper Enabled
  437. Pull / Keep Select Field: Keeper
  438. Pull Up / Down Config. Field: 22K Ohm Pull Up
  439. Hyst. Enable Field: Hysteresis Disabled */
  440. IOMUXC_SetPinConfig(
  441. IOMUXC_GPIO_AD_B1_09_SAI1_MCLK, /* GPIO_AD_B1_09 PAD functional properties : */
  442. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  443. Drive Strength Field: R0/6
  444. Speed Field: medium(100MHz)
  445. Open Drain Enable Field: Open Drain Disabled
  446. Pull / Keep Enable Field: Pull/Keeper Enabled
  447. Pull / Keep Select Field: Keeper
  448. Pull Up / Down Config. Field: 100K Ohm Pull Down
  449. Hyst. Enable Field: Hysteresis Disabled */
  450. IOMUXC_SetPinConfig(
  451. IOMUXC_GPIO_AD_B1_12_SAI1_RX_DATA00, /* GPIO_AD_B1_12 PAD functional properties : */
  452. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  453. Drive Strength Field: R0/6
  454. Speed Field: medium(100MHz)
  455. Open Drain Enable Field: Open Drain Disabled
  456. Pull / Keep Enable Field: Pull/Keeper Enabled
  457. Pull / Keep Select Field: Keeper
  458. Pull Up / Down Config. Field: 100K Ohm Pull Down
  459. Hyst. Enable Field: Hysteresis Disabled */
  460. IOMUXC_SetPinConfig(
  461. IOMUXC_GPIO_AD_B1_13_SAI1_TX_DATA00, /* GPIO_AD_B1_13 PAD functional properties : */
  462. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  463. Drive Strength Field: R0/6
  464. Speed Field: medium(100MHz)
  465. Open Drain Enable Field: Open Drain Disabled
  466. Pull / Keep Enable Field: Pull/Keeper Enabled
  467. Pull / Keep Select Field: Keeper
  468. Pull Up / Down Config. Field: 100K Ohm Pull Down
  469. Hyst. Enable Field: Hysteresis Disabled */
  470. IOMUXC_SetPinConfig(
  471. IOMUXC_GPIO_AD_B1_14_SAI1_TX_BCLK, /* GPIO_AD_B1_14 PAD functional properties : */
  472. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  473. Drive Strength Field: R0/6
  474. Speed Field: medium(100MHz)
  475. Open Drain Enable Field: Open Drain Disabled
  476. Pull / Keep Enable Field: Pull/Keeper Enabled
  477. Pull / Keep Select Field: Keeper
  478. Pull Up / Down Config. Field: 100K Ohm Pull Down
  479. Hyst. Enable Field: Hysteresis Disabled */
  480. IOMUXC_SetPinConfig(
  481. IOMUXC_GPIO_AD_B1_15_SAI1_TX_SYNC, /* GPIO_AD_B1_15 PAD functional properties : */
  482. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  483. Drive Strength Field: R0/6
  484. Speed Field: medium(100MHz)
  485. Open Drain Enable Field: Open Drain Disabled
  486. Pull / Keep Enable Field: Pull/Keeper Enabled
  487. Pull / Keep Select Field: Keeper
  488. Pull Up / Down Config. Field: 100K Ohm Pull Down
  489. Hyst. Enable Field: Hysteresis Disabled */
  490. }
  491. #endif
  492. /**
  493. * This function will initial rt1050 board.
  494. */
  495. #ifdef BSP_USING_SDIO
  496. void imxrt_SDcard_pins_init(void)
  497. {
  498. IOMUXC_SetPinMux(
  499. IOMUXC_GPIO_AD_B0_05_GPIO1_IO05, /* GPIO_AD_B0_05 is configured as GPIO1_IO05 */
  500. 0U); /* Software Input On Field: Input Path is determined by functionality */
  501. IOMUXC_SetPinMux(
  502. IOMUXC_GPIO_B1_12_GPIO2_IO28, /* GPIO_B1_12 is configured as GPIO2_IO28 */
  503. 0U); /* Software Input On Field: Input Path is determined by functionality */
  504. IOMUXC_SetPinMux(
  505. IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 is configured as USDHC1_VSELECT */
  506. 0U); /* Software Input On Field: Input Path is determined by functionality */
  507. IOMUXC_SetPinMux(
  508. IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 is configured as USDHC1_CMD */
  509. 0U); /* Software Input On Field: Input Path is determined by functionality */
  510. IOMUXC_SetPinMux(
  511. IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 is configured as USDHC1_CLK */
  512. 0U); /* Software Input On Field: Input Path is determined by functionality */
  513. IOMUXC_SetPinMux(
  514. IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 is configured as USDHC1_DATA0 */
  515. 0U); /* Software Input On Field: Input Path is determined by functionality */
  516. IOMUXC_SetPinMux(
  517. IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 is configured as USDHC1_DATA1 */
  518. 0U); /* Software Input On Field: Input Path is determined by functionality */
  519. IOMUXC_SetPinMux(
  520. IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 is configured as USDHC1_DATA2 */
  521. 0U); /* Software Input On Field: Input Path is determined by functionality */
  522. IOMUXC_SetPinMux(
  523. IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 is configured as USDHC1_DATA3 */
  524. 0U); /* Software Input On Field: Input Path is determined by functionality */
  525. IOMUXC_SetPinConfig(
  526. IOMUXC_GPIO_AD_B0_05_GPIO1_IO05, /* GPIO_AD_B0_05 PAD functional properties : */
  527. 0x10B0u); /* Slew Rate Field: Slow Slew Rate
  528. Drive Strength Field: R0/6
  529. Speed Field: medium(100MHz)
  530. Open Drain Enable Field: Open Drain Disabled
  531. Pull / Keep Enable Field: Pull/Keeper Enabled
  532. Pull / Keep Select Field: Keeper
  533. Pull Up / Down Config. Field: 100K Ohm Pull Down
  534. Hyst. Enable Field: Hysteresis Disabled */
  535. IOMUXC_SetPinConfig(
  536. IOMUXC_GPIO_B1_12_GPIO2_IO28, /* GPIO_B1_12 PAD functional properties : */
  537. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  538. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  539. Speed Field: medium(100MHz)
  540. Open Drain Enable Field: Open Drain Disabled
  541. Pull / Keep Enable Field: Pull/Keeper Enabled
  542. Pull / Keep Select Field: Pull
  543. Pull Up / Down Config. Field: 47K Ohm Pull Up
  544. Hyst. Enable Field: Hysteresis Enabled */
  545. IOMUXC_SetPinConfig(
  546. IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 PAD functional properties : */
  547. 0x0170A1u); /* Slew Rate Field: Fast Slew Rate
  548. Drive Strength Field: R0/4
  549. Speed Field: medium(100MHz)
  550. Open Drain Enable Field: Open Drain Disabled
  551. Pull / Keep Enable Field: Pull/Keeper Enabled
  552. Pull / Keep Select Field: Pull
  553. Pull Up / Down Config. Field: 47K Ohm Pull Up
  554. Hyst. Enable Field: Hysteresis Enabled */
  555. IOMUXC_SetPinConfig(
  556. IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 PAD functional properties : */
  557. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  558. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  559. Speed Field: medium(100MHz)
  560. Open Drain Enable Field: Open Drain Disabled
  561. Pull / Keep Enable Field: Pull/Keeper Enabled
  562. Pull / Keep Select Field: Pull
  563. Pull Up / Down Config. Field: 47K Ohm Pull Up
  564. Hyst. Enable Field: Hysteresis Enabled */
  565. IOMUXC_SetPinConfig(
  566. IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 PAD functional properties : */
  567. 0x014089u); /* Slew Rate Field: Fast Slew Rate
  568. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  569. Speed Field: medium(100MHz)
  570. Open Drain Enable Field: Open Drain Disabled
  571. Pull / Keep Enable Field: Pull/Keeper Disabled
  572. Pull / Keep Select Field: Keeper
  573. Pull Up / Down Config. Field: 47K Ohm Pull Up
  574. Hyst. Enable Field: Hysteresis Enabled */
  575. IOMUXC_SetPinConfig(
  576. IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 PAD functional properties : */
  577. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  578. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  579. Speed Field: medium(100MHz)
  580. Open Drain Enable Field: Open Drain Disabled
  581. Pull / Keep Enable Field: Pull/Keeper Enabled
  582. Pull / Keep Select Field: Pull
  583. Pull Up / Down Config. Field: 47K Ohm Pull Up
  584. Hyst. Enable Field: Hysteresis Enabled */
  585. IOMUXC_SetPinConfig(
  586. IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 PAD functional properties : */
  587. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  588. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  589. Speed Field: medium(100MHz)
  590. Open Drain Enable Field: Open Drain Disabled
  591. Pull / Keep Enable Field: Pull/Keeper Enabled
  592. Pull / Keep Select Field: Pull
  593. Pull Up / Down Config. Field: 47K Ohm Pull Up
  594. Hyst. Enable Field: Hysteresis Enabled */
  595. IOMUXC_SetPinConfig(
  596. IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 PAD functional properties : */
  597. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  598. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  599. Speed Field: medium(100MHz)
  600. Open Drain Enable Field: Open Drain Disabled
  601. Pull / Keep Enable Field: Pull/Keeper Enabled
  602. Pull / Keep Select Field: Pull
  603. Pull Up / Down Config. Field: 47K Ohm Pull Up
  604. Hyst. Enable Field: Hysteresis Enabled */
  605. IOMUXC_SetPinConfig(
  606. IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 PAD functional properties : */
  607. 0x017089u); /* Slew Rate Field: Fast Slew Rate
  608. Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
  609. Speed Field: medium(100MHz)
  610. Open Drain Enable Field: Open Drain Disabled
  611. Pull / Keep Enable Field: Pull/Keeper Enabled
  612. Pull / Keep Select Field: Pull
  613. Pull Up / Down Config. Field: 47K Ohm Pull Up
  614. Hyst. Enable Field: Hysteresis Enabled */
  615. }
  616. #endif
  617. void rt_hw_board_init()
  618. {
  619. BOARD_ConfigMPU();
  620. BOARD_InitPins();
  621. BOARD_BootClockRUN();
  622. NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  623. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  624. #ifdef BSP_USING_LPUART
  625. imxrt_uart_pins_init();
  626. #endif
  627. #ifdef BSP_USING_ETH
  628. imxrt_enet_pins_init();
  629. #endif
  630. #ifdef BSP_USING_DMA
  631. imxrt_dma_init();
  632. #endif
  633. #ifdef BSP_USING_AUDIO
  634. imxrt_sai_pins_init();
  635. #endif
  636. #ifdef BSP_USING_SDIO
  637. imxrt_SDcard_pins_init();
  638. #endif
  639. #ifdef RT_USING_HEAP
  640. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  641. #endif
  642. #ifdef RT_USING_COMPONENTS_INIT
  643. rt_components_board_init();
  644. #endif
  645. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  646. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  647. #endif
  648. }