aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h287
1 files changed, 287 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h
new file mode 100644
index 000000000..b902f7913
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/project_template/board.h
@@ -0,0 +1,287 @@
1/*
2 * Copyright 2018-2019 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _BOARD_H_
10#define _BOARD_H_
11
12#include "clock_config.h"
13#include "fsl_common.h"
14#include "fsl_reset.h"
15#include "fsl_gpio.h"
16
17/*******************************************************************************
18 * Definitions
19 ******************************************************************************/
20/*! @brief The board name */
21#define BOARD_NAME "MIMXRT685-EVK"
22#define BOARD_I3C_CODEC (1)
23
24/*! @brief The UART to use for debug messages. */
25#define BOARD_DEBUG_UART_TYPE kSerialPort_Uart
26#define BOARD_DEBUG_UART_BASEADDR (uint32_t) USART0
27#define BOARD_DEBUG_UART_INSTANCE 0U
28#define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetFlexCommClkFreq(0U)
29#define BOARD_DEBUG_UART_FRG_CLK \
30 (&(const clock_frg_clk_config_t){0, kCLOCK_FrgPllDiv, 255, 0}) /*!< Select FRG0 mux as frg_pll */
31#define BOARD_DEBUG_UART_CLK_ATTACH kFRG_to_FLEXCOMM0
32#define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn
33#define BOARD_DEBUG_UART_CLKSRC kCLOCK_Flexcomm0
34#define BOARD_UART_IRQ_HANDLER FLEXCOMM0_IRQHandler
35#define BOARD_UART_IRQ FLEXCOMM0_IRQn
36
37#ifndef BOARD_DEBUG_UART_BAUDRATE
38#define BOARD_DEBUG_UART_BAUDRATE 115200
39#endif /* BOARD_DEBUG_UART_BAUDRATE */
40
41#define BOARD_FLEXSPI_PSRAM FLEXSPI
42#ifndef BOARD_ENABLE_PSRAM_CACHE
43#define BOARD_ENABLE_PSRAM_CACHE 1
44#endif
45
46#if BOARD_I3C_CODEC
47#define BOARD_CODEC_I2C_BASEADDR I3C
48#define BOARD_CODEC_I2C_CLOCK_FREQ CLOCK_GetI3cClkFreq()
49#define BOARD_CODEC_I2C_INSTANCE 0
50#else
51#define BOARD_CODEC_I2C_BASEADDR I2C4
52#define BOARD_CODEC_I2C_CLOCK_FREQ CLOCK_GetFlexCommClkFreq(4U)
53#define BOARD_CODEC_I2C_INSTANCE 4
54#endif
55
56#define BOARD_PMIC_I2C_BASEADDR I2C15
57#define BOARD_PMIC_I2C_CLOCK_FREQ CLOCK_GetFlexCommClkFreq(15U)
58
59#define BOARD_ACCEL_I2C_BASEADDR I2C2
60#define BOARD_ACCEL_I2C_ADDR 0x1E
61#define BOARD_ACCEL_I2C_CLOCK_FREQ CLOCK_GetFlexCommClkFreq(2U)
62
63/* Board led color mapping */
64#define LOGIC_LED_ON 1U
65#define LOGIC_LED_OFF 0U
66
67#ifndef BOARD_LED_RED_GPIO
68#define BOARD_LED_RED_GPIO GPIO
69#endif
70#define BOARD_LED_RED_GPIO_PORT 0U
71#ifndef BOARD_LED_RED_GPIO_PIN
72#define BOARD_LED_RED_GPIO_PIN 31U
73#endif
74
75#ifndef BOARD_LED_GREEN_GPIO
76#define BOARD_LED_GREEN_GPIO GPIO
77#endif
78#define BOARD_LED_GREEN_GPIO_PORT 0U
79#ifndef BOARD_LED_GREEN_GPIO_PIN
80#define BOARD_LED_GREEN_GPIO_PIN 14U
81#endif
82#ifndef BOARD_LED_BLUE_GPIO
83#define BOARD_LED_BLUE_GPIO GPIO
84#endif
85#define BOARD_LED_BLUE_GPIO_PORT 0U
86#ifndef BOARD_LED_BLUE_GPIO_PIN
87#define BOARD_LED_BLUE_GPIO_PIN 26U
88#endif
89
90#define LED_RED_INIT(output) \
91 GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \
92 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */
93#define LED_RED_ON() \
94 GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
95 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
96#define LED_RED_OFF() \
97 GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
98 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */
99#define LED_RED_TOGGLE() \
100 GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
101 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
102
103#define LED_GREEN_INIT(output) \
104 GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \
105 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_GREEN */
106#define LED_GREEN_ON() \
107 GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
108 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
109#define LED_GREEN_OFF() \
110 GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
111 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
112#define LED_GREEN_TOGGLE() \
113 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
114 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */
115
116#define LED_BLUE_INIT(output) \
117 GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \
118 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_BLUE */
119#define LED_BLUE_ON() \
120 GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
121 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */
122#define LED_BLUE_OFF() \
123 GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
124 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */
125#define LED_BLUE_TOGGLE() \
126 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
127 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */
128
129/* Board SW PIN */
130#ifndef BOARD_SW1_GPIO
131#define BOARD_SW1_GPIO GPIO
132#endif
133#define BOARD_SW1_GPIO_PORT 1U
134#ifndef BOARD_SW1_GPIO_PIN
135#define BOARD_SW1_GPIO_PIN 1U
136#endif
137
138#ifndef BOARD_SW2_GPIO
139#define BOARD_SW2_GPIO GPIO
140#endif
141#define BOARD_SW2_GPIO_PORT 0U
142#ifndef BOARD_SW2_GPIO_PIN
143#define BOARD_SW2_GPIO_PIN 10U
144#endif
145
146/* USDHC configuration */
147#define BOARD_SD_SUPPORT_180V (1)
148#define BOARD_USDHC_CD_GPIO_BASE GPIO
149#define BOARD_USDHC_CD_GPIO_PORT (2)
150#define BOARD_USDHC_CD_GPIO_PIN (9)
151#define BOARD_SD_POWER_RESET_GPIO (GPIO)
152#define BOARD_SD_POWER_RESET_GPIO_PORT (2)
153#define BOARD_SD_POWER_RESET_GPIO_PIN (10)
154
155/* Card detect handled by uSDHC, no GPIO interrupt */
156#define BOARD_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostCD
157#define BOARD_USDHC_CD_PORT_IRQ USDHC0_IRQn
158#define BOARD_USDHC_CD_STATUS() 0
159#define BOARD_USDHC_CD_INTERRUPT_STATUS() 0
160#define BOARD_USDHC_CD_CLEAR_INTERRUPT(flag)
161#define BOARD_USDHC_CD_GPIO_INIT()
162
163#define BOARD_HAS_SDCARD (1U)
164#define BOARD_USDHC_CARD_INSERT_CD_LEVEL (0U)
165
166#define BOARD_USDHC_MMCCARD_POWER_CONTROL_INIT()
167#define BOARD_USDHC_MMCCARD_POWER_CONTROL(state)
168#define BOARD_USDHC_SDCARD_POWER_CONTROL_INIT() \
169 { \
170 GPIO_PortInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PORT); \
171 GPIO_PinInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PORT, BOARD_SD_POWER_RESET_GPIO_PIN, \
172 &(gpio_pin_config_t){kGPIO_DigitalOutput, 0}); \
173 }
174
175#define BOARD_MMC_SUPPORT_8BIT_BUS 0
176
177#define BOARD_USDHC_SDCARD_POWER_CONTROL(state) \
178 (state ? \
179 GPIO_PortSet(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PORT, 1 << BOARD_SD_POWER_RESET_GPIO_PIN) : \
180 GPIO_PortClear(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PORT, \
181 1 << BOARD_SD_POWER_RESET_GPIO_PIN))
182
183#define BOARD_USDHC0_BASEADDR USDHC0
184
185#define BOARD_USDHC0_CLK_FREQ CLOCK_GetSdioClkFreq(0)
186
187#define BOARD_USDHC_SWITCH_VOLTAGE_FUNCTION 1U
188
189/* GT202 */
190#define BOARD_INITGT202SHIELD_PWRON_GPIO GPIO
191#define BOARD_INITGT202SHIELD_IRQ_GPIO GPIO
192#define BOARD_INITGT202SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput
193#define BOARD_INITGT202SHIELD_IRQ_DIRECTION kGPIO_DigitalInput
194#define BOARD_INITGT202SHIELD_PWRON_PORT 1
195#define BOARD_INITGT202SHIELD_IRQ_PORT 1
196#define BOARD_INITGT202SHIELD_PWRON_GPIO_PIN 9
197#define BOARD_INITGT202SHIELD_IRQ_GPIO_PIN 8
198
199/* Silex2401 */
200#define BOARD_INITSILEX2401SHIELD_PWRON_GPIO GPIO
201#define BOARD_INITSILEX2401SHIELD_IRQ_GPIO GPIO
202#define BOARD_INITSILEX2401SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput
203#define BOARD_INITSILEX2401SHIELD_IRQ_DIRECTION kGPIO_DigitalInput
204#define BOARD_INITSILEX2401SHIELD_PWRON_PORT 1
205#define BOARD_INITSILEX2401SHIELD_IRQ_PORT 0
206#define BOARD_INITSILEX2401SHIELD_PWRON_GPIO_PIN 0
207#define BOARD_INITSILEX2401SHIELD_IRQ_GPIO_PIN 28
208
209#define BOARD_SD_HOST_BASEADDR BOARD_USDHC0_BASEADDR
210#define BOARD_SD_HOST_CLK_FREQ BOARD_USDHC0_CLK_FREQ
211#define BOARD_SD_HOST_IRQ USDHC0_IRQn
212
213#define BOARD_SD_Pin_Config(speed, strength)
214
215/* USB PHY condfiguration */
216#define BOARD_USB_PHY_D_CAL (0x0CU)
217#define BOARD_USB_PHY_TXCAL45DP (0x06U)
218#define BOARD_USB_PHY_TXCAL45DM (0x06U)
219
220#define BOARD_FLASH_SIZE (0x4000000U)
221#if defined(__cplusplus)
222extern "C" {
223#endif /* __cplusplus */
224
225/*******************************************************************************
226 * API
227 ******************************************************************************/
228
229void BOARD_InitDebugConsole(void);
230status_t BOARD_InitPsRam(void);
231void BOARD_FlexspiClockSafeConfig(void);
232AT_QUICKACCESS_SECTION_CODE(void BOARD_SetFlexspiClock(uint32_t src, uint32_t divider));
233AT_QUICKACCESS_SECTION_CODE(void BOARD_DeinitXip(FLEXSPI_Type *base));
234AT_QUICKACCESS_SECTION_CODE(void BOARD_InitXip(FLEXSPI_Type *base));
235#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
236void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz);
237status_t BOARD_I2C_Send(I2C_Type *base,
238 uint8_t deviceAddress,
239 uint32_t subAddress,
240 uint8_t subaddressSize,
241 uint8_t *txBuff,
242 uint8_t txBuffSize);
243status_t BOARD_I2C_Receive(I2C_Type *base,
244 uint8_t deviceAddress,
245 uint32_t subAddress,
246 uint8_t subaddressSize,
247 uint8_t *rxBuff,
248 uint8_t rxBuffSize);
249#endif
250#if defined BOARD_USE_CODEC
251void BOARD_I3C_Init(I3C_Type *base, uint32_t clkSrc_Hz);
252status_t BOARD_I3C_Send(I3C_Type *base,
253 uint8_t deviceAddress,
254 uint32_t subAddress,
255 uint8_t subaddressSize,
256 uint8_t *txBuff,
257 uint8_t txBuffSize);
258status_t BOARD_I3C_Receive(I3C_Type *base,
259 uint8_t deviceAddress,
260 uint32_t subAddress,
261 uint8_t subaddressSize,
262 uint8_t *rxBuff,
263 uint8_t rxBuffSize);
264void BOARD_Codec_I2C_Init(void);
265status_t BOARD_Codec_I2C_Send(
266 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
267status_t BOARD_Codec_I2C_Receive(
268 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
269#endif
270#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
271void BOARD_PMIC_I2C_Init(void);
272status_t BOARD_PMIC_I2C_Send(
273 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
274status_t BOARD_PMIC_I2C_Receive(
275 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
276
277void BOARD_Accel_I2C_Init(void);
278status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff);
279status_t BOARD_Accel_I2C_Receive(
280 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
281
282#endif /* SDK_I2C_BASED_COMPONENT_USED */
283#if defined(__cplusplus)
284}
285#endif /* __cplusplus */
286
287#endif /* _BOARD_H_ */