diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/project_template/board.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/project_template/board.h | 290 |
1 files changed, 290 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/project_template/board.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/project_template/board.h new file mode 100644 index 000000000..22bb8d12e --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/project_template/board.h | |||
@@ -0,0 +1,290 @@ | |||
1 | /* | ||
2 | * Copyright 2018 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #ifndef _BOARD_H_ | ||
9 | #define _BOARD_H_ | ||
10 | |||
11 | #include "clock_config.h" | ||
12 | #include "fsl_common.h" | ||
13 | #include "fsl_gpio.h" | ||
14 | #include "fsl_clock.h" | ||
15 | |||
16 | /******************************************************************************* | ||
17 | * Definitions | ||
18 | ******************************************************************************/ | ||
19 | /*! @brief The board name */ | ||
20 | #define BOARD_NAME "MIMXRT1064-EVK" | ||
21 | |||
22 | /* The UART to use for debug messages. */ | ||
23 | #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart | ||
24 | #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1 | ||
25 | #define BOARD_DEBUG_UART_INSTANCE 1U | ||
26 | |||
27 | #define BOARD_DEBUG_UART_CLK_FREQ BOARD_DebugConsoleSrcFreq() | ||
28 | |||
29 | #define BOARD_UART_IRQ LPUART1_IRQn | ||
30 | #define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler | ||
31 | |||
32 | #ifndef BOARD_DEBUG_UART_BAUDRATE | ||
33 | #define BOARD_DEBUG_UART_BAUDRATE (115200U) | ||
34 | #endif /* BOARD_DEBUG_UART_BAUDRATE */ | ||
35 | |||
36 | /*! @brief The USER_LED used for board */ | ||
37 | #define LOGIC_LED_ON (0U) | ||
38 | #define LOGIC_LED_OFF (1U) | ||
39 | #ifndef BOARD_USER_LED_GPIO | ||
40 | #define BOARD_USER_LED_GPIO GPIO1 | ||
41 | #endif | ||
42 | #ifndef BOARD_USER_LED_GPIO_PIN | ||
43 | #define BOARD_USER_LED_GPIO_PIN (9U) | ||
44 | #endif | ||
45 | |||
46 | #define USER_LED_INIT(output) \ | ||
47 | GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, output); \ | ||
48 | BOARD_USER_LED_GPIO->GDIR |= (1U << BOARD_USER_LED_GPIO_PIN) /*!< Enable target USER_LED */ | ||
49 | #define USER_LED_ON() \ | ||
50 | GPIO_PortClear(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!< Turn off target USER_LED */ | ||
51 | #define USER_LED_OFF() GPIO_PortSet(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!<Turn on target USER_LED*/ | ||
52 | #define USER_LED_TOGGLE() \ | ||
53 | GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, \ | ||
54 | 0x1 ^ GPIO_PinRead(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN)) /*!< Toggle target USER_LED */ | ||
55 | |||
56 | /*! @brief Define the port interrupt number for the board switches */ | ||
57 | #ifndef BOARD_USER_BUTTON_GPIO | ||
58 | #define BOARD_USER_BUTTON_GPIO GPIO5 | ||
59 | #endif | ||
60 | #ifndef BOARD_USER_BUTTON_GPIO_PIN | ||
61 | #define BOARD_USER_BUTTON_GPIO_PIN (0U) | ||
62 | #endif | ||
63 | #define BOARD_USER_BUTTON_IRQ GPIO5_Combined_0_15_IRQn | ||
64 | #define BOARD_USER_BUTTON_IRQ_HANDLER GPIO5_Combined_0_15_IRQHandler | ||
65 | #define BOARD_USER_BUTTON_NAME "SW8" | ||
66 | |||
67 | /*! @brief The board flash size */ | ||
68 | #define BOARD_FLASH_SIZE (0x400000U) | ||
69 | |||
70 | /*! @brief The ENET PHY address. */ | ||
71 | #define BOARD_ENET0_PHY_ADDRESS (0x02U) /* Phy address of enet port 0. */ | ||
72 | |||
73 | /* USB PHY condfiguration */ | ||
74 | #define BOARD_USB_PHY_D_CAL (0x0CU) | ||
75 | #define BOARD_USB_PHY_TXCAL45DP (0x06U) | ||
76 | #define BOARD_USB_PHY_TXCAL45DM (0x06U) | ||
77 | |||
78 | #define BOARD_ARDUINO_INT_IRQ (GPIO1_INT3_IRQn) | ||
79 | #define BOARD_ARDUINO_I2C_IRQ (LPI2C1_IRQn) | ||
80 | #define BOARD_ARDUINO_I2C_INDEX (1) | ||
81 | #define BOARD_USDHC1_BASEADDR USDHC1 | ||
82 | #define BOARD_USDHC2_BASEADDR USDHC2 | ||
83 | #define BOARD_USDHC_CD_GPIO_BASE GPIO2 | ||
84 | #define BOARD_USDHC_CD_GPIO_PIN 28 | ||
85 | #define BOARD_USDHC_CD_PORT_IRQ GPIO2_Combined_16_31_IRQn | ||
86 | #define BOARD_USDHC_CD_PORT_IRQ_HANDLER GPIO2_Combined_16_31_IRQHandler | ||
87 | |||
88 | #define BOARD_USDHC_CD_STATUS() (GPIO_PinRead(BOARD_USDHC_CD_GPIO_BASE, BOARD_USDHC_CD_GPIO_PIN)) | ||
89 | |||
90 | #define BOARD_USDHC_CD_INTERRUPT_STATUS() (GPIO_PortGetInterruptFlags(BOARD_USDHC_CD_GPIO_BASE)) | ||
91 | #define BOARD_USDHC_CD_CLEAR_INTERRUPT(flag) (GPIO_PortClearInterruptFlags(BOARD_USDHC_CD_GPIO_BASE, flag)) | ||
92 | |||
93 | #define BOARD_USDHC_CD_GPIO_INIT() \ | ||
94 | { \ | ||
95 | gpio_pin_config_t sw_config = { \ | ||
96 | kGPIO_DigitalInput, \ | ||
97 | 0, \ | ||
98 | kGPIO_IntRisingOrFallingEdge, \ | ||
99 | }; \ | ||
100 | GPIO_PinInit(BOARD_USDHC_CD_GPIO_BASE, BOARD_USDHC_CD_GPIO_PIN, &sw_config); \ | ||
101 | GPIO_PortEnableInterrupts(BOARD_USDHC_CD_GPIO_BASE, 1U << BOARD_USDHC_CD_GPIO_PIN); \ | ||
102 | GPIO_PortClearInterruptFlags(BOARD_USDHC_CD_GPIO_BASE, ~0); \ | ||
103 | } | ||
104 | #define BOARD_HAS_SDCARD (1U) | ||
105 | #define BOARD_SD_POWER_RESET_GPIO (GPIO1) | ||
106 | #define BOARD_SD_POWER_RESET_GPIO_PIN (19U) | ||
107 | |||
108 | #define BOARD_USDHC_CARD_INSERT_CD_LEVEL (0U) | ||
109 | |||
110 | #define BOARD_USDHC_MMCCARD_POWER_CONTROL(state) | ||
111 | |||
112 | #define BOARD_USDHC_MMCCARD_POWER_CONTROL_INIT() \ | ||
113 | { \ | ||
114 | gpio_pin_config_t sw_config = { \ | ||
115 | kGPIO_DigitalOutput, \ | ||
116 | 0, \ | ||
117 | kGPIO_NoIntmode, \ | ||
118 | }; \ | ||
119 | GPIO_PinInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, &sw_config); \ | ||
120 | GPIO_PinWrite(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, true); \ | ||
121 | } | ||
122 | |||
123 | #define BOARD_USDHC_SDCARD_POWER_CONTROL_INIT() \ | ||
124 | { \ | ||
125 | gpio_pin_config_t sw_config = { \ | ||
126 | kGPIO_DigitalOutput, \ | ||
127 | 0, \ | ||
128 | kGPIO_NoIntmode, \ | ||
129 | }; \ | ||
130 | GPIO_PinInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, &sw_config); \ | ||
131 | } | ||
132 | |||
133 | #define BOARD_USDHC_SDCARD_POWER_CONTROL(state) \ | ||
134 | (GPIO_PinWrite(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, state)) | ||
135 | |||
136 | #define BOARD_USDHC1_CLK_FREQ (CLOCK_GetSysPfdFreq(kCLOCK_Pfd0) / (CLOCK_GetDiv(kCLOCK_Usdhc1Div) + 1U)) | ||
137 | #define BOARD_USDHC2_CLK_FREQ (CLOCK_GetSysPfdFreq(kCLOCK_Pfd0) / (CLOCK_GetDiv(kCLOCK_Usdhc2Div) + 1U)) | ||
138 | |||
139 | #define BOARD_SD_HOST_BASEADDR BOARD_USDHC1_BASEADDR | ||
140 | #define BOARD_SD_HOST_CLK_FREQ BOARD_USDHC1_CLK_FREQ | ||
141 | #define BOARD_SD_HOST_IRQ USDHC1_IRQn | ||
142 | |||
143 | #define BOARD_MMC_HOST_BASEADDR BOARD_USDHC2_BASEADDR | ||
144 | #define BOARD_MMC_HOST_CLK_FREQ BOARD_USDHC2_CLK_FREQ | ||
145 | #define BOARD_MMC_HOST_IRQ USDHC2_IRQn | ||
146 | #define BOARD_MMC_VCCQ_SUPPLY kMMC_VoltageWindow170to195 | ||
147 | #define BOARD_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360 | ||
148 | /* we are using the BB SD socket to DEMO the MMC example,but the | ||
149 | * SD socket provide 4bit bus only, so we define this macro to avoid | ||
150 | * 8bit data bus test | ||
151 | */ | ||
152 | #define BOARD_MMC_SUPPORT_8BIT_BUS (1U) | ||
153 | |||
154 | #define BOARD_SD_HOST_SUPPORT_SDR104_FREQ (200000000U) | ||
155 | #define BOARD_SD_HOST_SUPPORT_HS200_FREQ (180000000U) | ||
156 | |||
157 | /*! @brief The WIFI-QCA shield pin. */ | ||
158 | #define BOARD_INITGT202SHIELD_PWRON_GPIO GPIO1 /*!< GPIO device name: GPIO */ | ||
159 | #define BOARD_INITGT202SHIELD_PWRON_PORT 1U /*!< PORT device index: 1 */ | ||
160 | #define BOARD_INITGT202SHIELD_PWRON_GPIO_PIN 3U /*!< PIO4 pin index: 3 */ | ||
161 | #define BOARD_INITGT202SHIELD_PWRON_PIN_NAME GPIO1_3 /*!< Pin name */ | ||
162 | #define BOARD_INITGT202SHIELD_PWRON_LABEL "PWRON" /*!< Label */ | ||
163 | #define BOARD_INITGT202SHIELD_PWRON_NAME "PWRON" /*!< Identifier name */ | ||
164 | #define BOARD_INITGT202SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput /*!< Direction */ | ||
165 | |||
166 | #define BOARD_INITGT202SHIELD_IRQ_GPIO GPIO1 /*!< GPIO device name: GPIO */ | ||
167 | #define BOARD_INITGT202SHIELD_IRQ_PORT 1U /*!< PORT device index: 1 */ | ||
168 | #define BOARD_INITGT202SHIELD_IRQ_GPIO_PIN 19U /*!< PIO1 pin index: 19 */ | ||
169 | #define BOARD_INITGT202SHIELD_IRQ_PIN_NAME GPIO1_19 /*!< Pin name */ | ||
170 | #define BOARD_INITGT202SHIELD_IRQ_LABEL "IRQ" /*!< Label */ | ||
171 | #define BOARD_INITGT202SHIELD_IRQ_NAME "IRQ" /*!< Identifier name */ | ||
172 | #define BOARD_INITGT202SHIELD_IRQ_DIRECTION kGPIO_DigitalInput /*!< Direction */ | ||
173 | |||
174 | #define BOARD_INITSILEX2401SHIELD_PWRON_GPIO GPIO1 /*!< GPIO device name: GPIO */ | ||
175 | #define BOARD_INITSILEX2401SHIELD_PWRON_PORT 1U /*!< PORT device index: 1 */ | ||
176 | #define BOARD_INITSILEX2401SHIELD_PWRON_GPIO_PIN 9U /*!< PIO4 pin index: 9 */ | ||
177 | #define BOARD_INITSILEX2401SHIELD_PWRON_PIN_NAME GPIO1_9 /*!< Pin name */ | ||
178 | #define BOARD_INITSILEX2401SHIELD_PWRON_LABEL "PWRON" /*!< Label */ | ||
179 | #define BOARD_INITSILEX2401SHIELD_PWRON_NAME "PWRON" /*!< Identifier name */ | ||
180 | #define BOARD_INITSILEX2401SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput /*!< Direction */ | ||
181 | |||
182 | #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO GPIO1 /*!< GPIO device name: GPIO */ | ||
183 | #define BOARD_INITSILEX2401SHIELD_IRQ_PORT 1U /*!< PORT device index: 1 */ | ||
184 | #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO_PIN 11U /*!< PIO1 pin index: 11 */ | ||
185 | #define BOARD_INITSILEX2401SHIELD_IRQ_PIN_NAME GPIO1_11 /*!< Pin name */ | ||
186 | #define BOARD_INITSILEX2401SHIELD_IRQ_LABEL "IRQ" /*!< Label */ | ||
187 | #define BOARD_INITSILEX2401SHIELD_IRQ_NAME "IRQ" /*!< Identifier name */ | ||
188 | #define BOARD_INITSILEX2401SHIELD_IRQ_DIRECTION kGPIO_DigitalInput /*!< Direction */ | ||
189 | |||
190 | /* @Brief Board accelerator sensor configuration */ | ||
191 | #define BOARD_ACCEL_I2C_BASEADDR LPI2C1 | ||
192 | /* Select USB1 PLL (480 MHz) as LPI2C's clock source */ | ||
193 | #define BOARD_ACCEL_I2C_CLOCK_SOURCE_SELECT (0U) | ||
194 | /* Clock divider for LPI2C clock source */ | ||
195 | #define BOARD_ACCEL_I2C_CLOCK_SOURCE_DIVIDER (5U) | ||
196 | #define BOARD_ACCEL_I2C_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8 / (BOARD_ACCEL_I2C_CLOCK_SOURCE_DIVIDER + 1U)) | ||
197 | |||
198 | #define BOARD_CODEC_I2C_BASEADDR LPI2C1 | ||
199 | #define BOARD_CODEC_I2C_INSTANCE 1U | ||
200 | #define BOARD_CODEC_I2C_CLOCK_SOURCE_SELECT (0U) | ||
201 | #define BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER (5U) | ||
202 | #define BOARD_CODEC_I2C_CLOCK_FREQ (10000000U) | ||
203 | |||
204 | /* @Brief Board CAMERA configuration */ | ||
205 | #define BOARD_CAMERA_I2C_BASEADDR LPI2C1 | ||
206 | #define BOARD_CAMERA_I2C_CLOCK_SOURCE_DIVIDER (5U) | ||
207 | #define BOARD_CAMERA_I2C_CLOCK_SOURCE_SELECT (0U) /* Select USB1 PLL (480 MHz) as LPI2C's clock source */ | ||
208 | #define BOARD_CAMERA_I2C_CLOCK_FREQ \ | ||
209 | (CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8 / (BOARD_CAMERA_I2C_CLOCK_SOURCE_DIVIDER + 1U)) | ||
210 | |||
211 | #define BOARD_CAMERA_I2C_SCL_GPIO GPIO1 | ||
212 | #define BOARD_CAMERA_I2C_SCL_PIN 16 | ||
213 | #define BOARD_CAMERA_I2C_SDA_GPIO GPIO1 | ||
214 | #define BOARD_CAMERA_I2C_SDA_PIN 17 | ||
215 | #define BOARD_CAMERA_PWDN_GPIO GPIO1 | ||
216 | #define BOARD_CAMERA_PWDN_PIN 4 | ||
217 | |||
218 | /* @Brief Board Bluetooth HCI UART configuration */ | ||
219 | #define BOARD_BT_UART_BASEADDR LPUART3 | ||
220 | #define BOARD_BT_UART_CLK_FREQ BOARD_DebugConsoleSrcFreq() | ||
221 | #define BOARD_BT_UART_IRQ LPUART3_IRQn | ||
222 | #define BOARD_BT_UART_IRQ_HANDLER LPUART3_IRQHandler | ||
223 | |||
224 | #if defined(__cplusplus) | ||
225 | extern "C" { | ||
226 | #endif /* __cplusplus */ | ||
227 | |||
228 | /******************************************************************************* | ||
229 | * API | ||
230 | ******************************************************************************/ | ||
231 | uint32_t BOARD_DebugConsoleSrcFreq(void); | ||
232 | |||
233 | void BOARD_InitDebugConsole(void); | ||
234 | |||
235 | void BOARD_ConfigMPU(void); | ||
236 | #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED | ||
237 | void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz); | ||
238 | status_t BOARD_LPI2C_Send(LPI2C_Type *base, | ||
239 | uint8_t deviceAddress, | ||
240 | uint32_t subAddress, | ||
241 | uint8_t subaddressSize, | ||
242 | uint8_t *txBuff, | ||
243 | uint8_t txBuffSize); | ||
244 | status_t BOARD_LPI2C_Receive(LPI2C_Type *base, | ||
245 | uint8_t deviceAddress, | ||
246 | uint32_t subAddress, | ||
247 | uint8_t subaddressSize, | ||
248 | uint8_t *rxBuff, | ||
249 | uint8_t rxBuffSize); | ||
250 | status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base, | ||
251 | uint8_t deviceAddress, | ||
252 | uint32_t subAddress, | ||
253 | uint8_t subaddressSize, | ||
254 | uint8_t *txBuff, | ||
255 | uint8_t txBuffSize); | ||
256 | status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base, | ||
257 | uint8_t deviceAddress, | ||
258 | uint32_t subAddress, | ||
259 | uint8_t subaddressSize, | ||
260 | uint8_t *rxBuff, | ||
261 | uint8_t rxBuffSize); | ||
262 | void BOARD_Accel_I2C_Init(void); | ||
263 | status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); | ||
264 | status_t BOARD_Accel_I2C_Receive( | ||
265 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
266 | void BOARD_Codec_I2C_Init(void); | ||
267 | status_t BOARD_Codec_I2C_Send( | ||
268 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); | ||
269 | status_t BOARD_Codec_I2C_Receive( | ||
270 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
271 | void BOARD_Camera_I2C_Init(void); | ||
272 | status_t BOARD_Camera_I2C_Send( | ||
273 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); | ||
274 | status_t BOARD_Camera_I2C_Receive( | ||
275 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
276 | |||
277 | status_t BOARD_Camera_I2C_SendSCCB( | ||
278 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); | ||
279 | status_t BOARD_Camera_I2C_ReceiveSCCB( | ||
280 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
281 | #endif /* SDK_I2C_BASED_COMPONENT_USED */ | ||
282 | |||
283 | void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength); | ||
284 | void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength); | ||
285 | |||
286 | #if defined(__cplusplus) | ||
287 | } | ||
288 | #endif /* __cplusplus */ | ||
289 | |||
290 | #endif /* _BOARD_H_ */ | ||