board.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /************************************************************************************
  2. * configs/imxrt1050/include/board.h
  3. *
  4. * Copyright (C) 2018 Gregory Nutt. All rights reserved.
  5. * Authors: Gregory Nutt <gnutt@nuttx.org>
  6. * David Sidrane <david_s5@nscdg.com>
  7. * Dave Marples <dave@marples.net>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. * 3. Neither the name NuttX nor the names of its contributors may be
  20. * used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ************************************************************************************/
  37. #ifndef __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H
  38. #define __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H
  39. /************************************************************************************
  40. * Included Files
  41. ************************************************************************************/
  42. #include <nuttx/config.h>
  43. /************************************************************************************
  44. * Pre-processor Definitions
  45. ************************************************************************************/
  46. /* Clocking *************************************************************************/
  47. /* Set VDD_SOC to 1.25V */
  48. #define IMXRT_VDD_SOC (0x12)
  49. /* Set Arm PLL (PLL1) to fOut = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR
  50. * 600Mhz = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR
  51. * ARM_PLL_DIV_SELECT = 100
  52. * ARM_PODF_DIVISOR = 2
  53. * 600Mhz = (24Mhz * 100/2) / 2
  54. *
  55. * AHB_CLOCK_ROOT = PLL1fOut / IMXRT_AHB_PODF_DIVIDER
  56. * 1Hz to 600 Mhz = 600Mhz / IMXRT_ARM_CLOCK_DIVIDER
  57. * IMXRT_ARM_CLOCK_DIVIDER = 1
  58. * 600Mhz = 600Mhz / 1
  59. *
  60. * PRE_PERIPH_CLK_SEL = PRE_PERIPH_CLK_SEL_PLL1
  61. * PERIPH_CLK_SEL = 1 (0 select PERIPH_CLK2_PODF, 1 select PRE_PERIPH_CLK_SEL_PLL1)
  62. * PERIPH_CLK = 600Mhz
  63. *
  64. * IPG_CLOCK_ROOT = AHB_CLOCK_ROOT / IMXRT_IPG_PODF_DIVIDER
  65. * IMXRT_IPG_PODF_DIVIDER = 4
  66. * 150Mhz = 600Mhz / 4
  67. *
  68. * PRECLK_CLOCK_ROOT = IPG_CLOCK_ROOT / IMXRT_PERCLK_PODF_DIVIDER
  69. * IMXRT_PERCLK_PODF_DIVIDER = 1
  70. * 150Mhz = 150Mhz / 1
  71. *
  72. * SEMC_CLK_ROOT = 600Mhz / IMXRT_SEMC_PODF_DIVIDER (labeled AIX_PODF in 18.2)
  73. * IMXRT_SEMC_PODF_DIVIDER = 8
  74. * 75Mhz = 600Mhz / 8
  75. *
  76. * Set Sys PLL (PLL2) to fOut = (24Mhz * (20+(2*(DIV_SELECT)))
  77. * 528Mhz = (24Mhz * (20+(2*(1)))
  78. *
  79. * Set USB1 PLL (PLL3) to fOut = (24Mhz * 20)
  80. * 480Mhz = (24Mhz * 20)
  81. */
  82. #define BOARD_XTAL_FREQUENCY 24000000
  83. #define IMXRT_PRE_PERIPH_CLK_SEL CCM_CBCMR_PRE_PERIPH_CLK_SEL_PLL1
  84. #define IMXRT_PERIPH_CLK_SEL CCM_CBCDR_PERIPH_CLK_SEL_PRE_PERIPH
  85. #define IMXRT_ARM_PLL_DIV_SELECT 100
  86. #define IMXRT_ARM_PODF_DIVIDER 2
  87. #define IMXRT_AHB_PODF_DIVIDER 1
  88. #define IMXRT_IPG_PODF_DIVIDER 4
  89. #define IMXRT_PERCLK_CLK_SEL CCM_CSCMR1_PERCLK_CLK_SEL_IPG_CLK_ROOT
  90. #define IMXRT_PERCLK_PODF_DIVIDER 9
  91. #define IMXRT_SEMC_PODF_DIVIDER 8
  92. #define IMXRT_LPSPI_CLK_SELECT CCM_CBCMR_LPSPI_CLK_SEL_PLL3_PFD0
  93. #define IMXRT_LSPI_PODF_DIVIDER 8
  94. #define IMXRT_USDHC1_CLK_SELECT CCM_CSCMR1_USDHC1_CLK_SEL_PLL2_PFD0
  95. #define IMXRT_USDHC1_PODF_DIVIDER 2
  96. #define IMXRT_SYS_PLL_SELECT CCM_ANALOG_PLL_SYS_DIV_SELECT_22
  97. #define BOARD_CPU_FREQUENCY \
  98. (BOARD_XTAL_FREQUENCY * (IMXRT_ARM_PLL_DIV_SELECT / 2)) / IMXRT_ARM_PODF_DIVIDER
  99. /* LED definitions ******************************************************************/
  100. /* There are four LED status indicators located on the EVK Board. The functions of
  101. * these LEDs include:
  102. *
  103. * - Main Power Supply(D3)
  104. * Green: DC 5V main supply is normal.
  105. * Red: J2 input voltage is over 5.6V.
  106. * Off: The board is not powered.
  107. * - Reset RED LED(D15)
  108. * - OpenSDA LED(D16)
  109. * - USER LED(D18)
  110. *
  111. * Only a single LED, D18, is under software control.
  112. */
  113. /* LED index values for use with board_userled() */
  114. #define BOARD_USERLED 0
  115. #define BOARD_NLEDS 1
  116. /* LED bits for use with board_userled_all() */
  117. #define BOARD_USERLED_BIT (1 << BOARD_USERLED)
  118. /* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
  119. * defined. In that case, the usage by the board port is defined in
  120. * include/board.h and src/imxrt_autoleds.c. The LED is used to encode
  121. * OS-related events as follows:
  122. *
  123. * -------------------- ----------------------------- ------
  124. * SYMBOL Meaning LED
  125. * -------------------- ----------------------------- ------ */
  126. #define LED_STARTED 0 /* NuttX has been started OFF */
  127. #define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
  128. #define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
  129. #define LED_STACKCREATED 1 /* Idle stack created ON */
  130. #define LED_INIRQ 2 /* In an interrupt N/C */
  131. #define LED_SIGNAL 2 /* In a signal handler N/C */
  132. #define LED_ASSERTION 2 /* An assertion failed N/C */
  133. #define LED_PANIC 3 /* The system has crashed FLASH */
  134. #undef LED_IDLE /* Not used */
  135. /* Thus if the LED is statically on, NuttX has successfully booted and is,
  136. * apparently, running normally. If the LED is flashing at approximately
  137. * 2Hz, then a fatal error has been detected and the system has halted.
  138. */
  139. /* Button definitions ***************************************************************/
  140. /* The IMXRT board has one external user button
  141. *
  142. * 1. SW8 (IRQ88) GPIO5-00
  143. */
  144. #define BUTTON_SW8 0
  145. #define BUTTON_SW8_BIT (1 << BUTTON_SW8)
  146. /* SDIO *****************************************************************************/
  147. /* Pin drive characteristics - drive strength in particular may need tuning for
  148. * specific boards, but has been checked by scope on the EVKB to make sure shapes
  149. * are square with minimal ringing.
  150. */
  151. #define USDHC1_DATAX_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | \
  152. IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER)
  153. #define USDHC1_CMD_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | \
  154. IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER)
  155. #define USDHC1_CLK_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_SPEED_MAX)
  156. #define USDHC1_CD_IOMUX (0)
  157. #define PIN_USDHC1_D0 (GPIO_USDHC1_DATA0 | USDHC1_DATAX_IOMUX)
  158. #define PIN_USDHC1_D1 (GPIO_USDHC1_DATA1 | USDHC1_DATAX_IOMUX)
  159. #define PIN_USDHC1_D2 (GPIO_USDHC1_DATA2 | USDHC1_DATAX_IOMUX)
  160. #define PIN_USDHC1_D3 (GPIO_USDHC1_DATA3 | USDHC1_DATAX_IOMUX)
  161. #define PIN_USDHC1_DCLK (GPIO_USDHC1_CLK | USDHC1_CLK_IOMUX)
  162. #define PIN_USDHC1_CMD (GPIO_USDHC1_CMD | USDHC1_CMD_IOMUX)
  163. #define PIN_USDHC1_CD (GPIO_USDHC1_CD_2 | USDHC1_CD_IOMUX)
  164. /* 386 KHz for initial inquiry stuff */
  165. #define BOARD_USDHC_IDMODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV256
  166. #define BOARD_USDHC_IDMODE_DIVISOR USDHC_SYSCTL_DVS_DIV(2)
  167. /* 24.8MHz for other modes */
  168. #define BOARD_USDHC_MMCMODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8
  169. #define BOARD_USDHC_MMCMODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1)
  170. #define BOARD_USDHC_SD1MODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8
  171. #define BOARD_USDHC_SD1MODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1)
  172. #define BOARD_USDHC_SD4MODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8
  173. #define BOARD_USDHC_SD4MODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1)
  174. /* PIO Disambiguation ***************************************************************/
  175. /* LPUARTs
  176. *
  177. * Virtual console port provided by OpenSDA:
  178. *
  179. * UART1_TXD GPIO_AD_B0_12 LPUART1_TX
  180. * UART1_RXD GPIO_AD_B0_13 LPUART1_RX
  181. *
  182. * NOTE: There are no alternative pin configurations for LPUART1.
  183. *
  184. * Arduino RS-232 Shield:
  185. *
  186. * J22 D0 UART_RX/D0 GPIO_AD_B1_07 LPUART3_RX
  187. * J22 D1 UART_TX/D1 GPIO_AD_B1_06 LPUART3_TX
  188. */
  189. #define GPIO_LPUART3_RX GPIO_LPUART3_RX_1 /* GPIO_AD_B1_07 */
  190. #define GPIO_LPUART3_TX GPIO_LPUART3_TX_1 /* GPIO_AD_B1_06 */
  191. /* LPI2Cs
  192. *
  193. * Arduino Connector
  194. *
  195. * J23 A4 A4/ADC4/SDA GPIO_AD_B1_01 LPI2C1_SDA
  196. * J23 A5 A5/ADC5/SCL GPIO_AD_B1_00 LPI2C1_SCL
  197. */
  198. #define GPIO_LPI2C1_SDA GPIO_LPI2C1_SDA_2 /* GPIO_AD_B1_01 */
  199. #define GPIO_LPI2C1_SCL GPIO_LPI2C1_SCL_2 /* GPIO_AD_B1_00 */
  200. #define GPIO_LPI2C3_SDA GPIO_LPI2C3_SDA_2 /* GPIO_AD_B1_01 */
  201. #define GPIO_LPI2C3_SCL GPIO_LPI2C3_SCL_2 /* GPIO_AD_B1_00 */
  202. /* LPSPI
  203. *
  204. * Arduino Connector
  205. *
  206. * J24 D09 GPIO_AD_B0_02 LPSPI3_SDI
  207. * J24 D14 GPIO_AD_B0_01 LPSPI3_SDO
  208. * J24 D15 GPIO_AD_B0_00 LPSPI3_SCK
  209. */
  210. #define GPIO_LPSPI3_SCK GPIO_LPSPI3_SCK_2 /* GPIO_AD_B0_00 */
  211. #define GPIO_LPSPI3_MISO GPIO_LPSPI3_SDI_2 /* GPIO_AD_B0_02 */
  212. #define GPIO_LPSPI3_MOSI GPIO_LPSPI3_SDO_2 /* GPIO_AD_B0_01 */
  213. /************************************************************************************
  214. * Public Types
  215. ************************************************************************************/
  216. /************************************************************************************
  217. * Public Data
  218. ************************************************************************************/
  219. #ifndef __ASSEMBLY__
  220. #undef EXTERN
  221. #if defined(__cplusplus)
  222. #define EXTERN extern "C"
  223. extern "C"
  224. {
  225. #else
  226. #define EXTERN extern
  227. #endif
  228. /************************************************************************************
  229. * Public Functions
  230. ************************************************************************************/
  231. #undef EXTERN
  232. #if defined(__cplusplus)
  233. }
  234. #endif
  235. #endif /* __ASSEMBLY__ */
  236. #endif /* __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H */