aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h221
1 files changed, 221 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h
new file mode 100644
index 000000000..3c0097879
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1021/project_template/board.h
@@ -0,0 +1,221 @@
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
15/*******************************************************************************
16 * Definitions
17 ******************************************************************************/
18/*! @brief The board name */
19#define BOARD_NAME "MIMXRT1020-EVK"
20
21/* The UART to use for debug messages. */
22#define BOARD_DEBUG_UART_TYPE kSerialPort_Uart
23#define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1
24#define BOARD_DEBUG_UART_INSTANCE 1U
25
26#define BOARD_DEBUG_UART_CLK_FREQ BOARD_DebugConsoleSrcFreq()
27
28#define BOARD_UART_IRQ LPUART1_IRQn
29#define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler
30
31#ifndef BOARD_DEBUG_UART_BAUDRATE
32#define BOARD_DEBUG_UART_BAUDRATE (115200U)
33#endif /* BOARD_DEBUG_UART_BAUDRATE */
34
35/* @Brief Board accelerator sensor configuration */
36#define BOARD_ACCEL_I2C_BASEADDR LPI2C4
37#define BOARD_ACCEL_I2C_CLOCK_SOURCE_SELECT (0U)
38#define BOARD_ACCEL_I2C_CLOCK_SOURCE_DIVIDER (5U)
39#define BOARD_ACCEL_I2C_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8 / (BOARD_ACCEL_I2C_CLOCK_SOURCE_DIVIDER + 1U))
40
41#define BOARD_CODEC_I2C_BASEADDR LPI2C1
42#define BOARD_CODEC_I2C_CLOCK_SOURCE_SELECT (0U)
43#define BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER (5U)
44#define BOARD_CODEC_I2C_CLOCK_FREQ \
45 ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER + 1U))
46
47/*! @brief The USER_LED used for board */
48#define LOGIC_LED_ON (0U)
49#define LOGIC_LED_OFF (1U)
50#ifndef BOARD_USER_LED_GPIO
51#define BOARD_USER_LED_GPIO GPIO1
52#endif
53#ifndef BOARD_USER_LED_GPIO_PIN
54#define BOARD_USER_LED_GPIO_PIN (5U)
55#endif
56
57#define USER_LED_INIT(output) \
58 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, output); \
59 BOARD_USER_LED_GPIO->GDIR |= (1U << BOARD_USER_LED_GPIO_PIN) /*!< Enable target USER_LED */
60#define USER_LED_ON() \
61 GPIO_PortClear(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!< Turn off target USER_LED */
62#define USER_LED_OFF() GPIO_PortSet(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!<Turn on target USER_LED*/
63#define USER_LED_TOGGLE() \
64 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, \
65 0x1 ^ GPIO_PinRead(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN)) /*!< Toggle target USER_LED */
66
67/*! @brief Define the port interrupt number for the board switches */
68#ifndef BOARD_USER_BUTTON_GPIO
69#define BOARD_USER_BUTTON_GPIO GPIO5
70#endif
71#ifndef BOARD_USER_BUTTON_GPIO_PIN
72#define BOARD_USER_BUTTON_GPIO_PIN (0U)
73#endif
74#define BOARD_USER_BUTTON_IRQ GPIO5_Combined_0_15_IRQn
75#define BOARD_USER_BUTTON_IRQ_HANDLER GPIO5_Combined_0_15_IRQHandler
76#define BOARD_USER_BUTTON_NAME "SW4"
77
78/*! @brief The hyper flash size */
79#define BOARD_FLASH_SIZE (0x800000U)
80
81/*! @brief The ENET PHY address. */
82#define BOARD_ENET0_PHY_ADDRESS (0x02U) /* Phy address of enet port 0. */
83
84/* USB PHY condfiguration */
85#define BOARD_USB_PHY_D_CAL (0x0CU)
86#define BOARD_USB_PHY_TXCAL45DP (0x06U)
87#define BOARD_USB_PHY_TXCAL45DM (0x06U)
88
89#define BOARD_ARDUINO_INT_IRQ (GPIO1_Combined_16_31_IRQn)
90#define BOARD_ARDUINO_I2C_IRQ (LPI2C4_IRQn)
91#define BOARD_ARDUINO_I2C_INDEX (4)
92#define BOARD_USDHC1_BASEADDR USDHC1
93#define BOARD_USDHC2_BASEADDR USDHC2
94#define BOARD_USDHC_CD_GPIO_BASE GPIO3
95#define BOARD_USDHC_CD_GPIO_PIN 19
96#define BOARD_USDHC_CD_PORT_IRQ GPIO3_Combined_16_31_IRQn
97#define BOARD_USDHC_CD_PORT_IRQ_HANDLER GPIO3_Combined_16_31_IRQHandler
98
99#define BOARD_USDHC_CD_STATUS() (GPIO_PinRead(BOARD_USDHC_CD_GPIO_BASE, BOARD_USDHC_CD_GPIO_PIN))
100
101#define BOARD_USDHC_CD_INTERRUPT_STATUS() (GPIO_PortGetInterruptFlags(BOARD_USDHC_CD_GPIO_BASE))
102#define BOARD_USDHC_CD_CLEAR_INTERRUPT(flag) (GPIO_PortClearInterruptFlags(BOARD_USDHC_CD_GPIO_BASE, flag))
103
104#define BOARD_USDHC_CD_GPIO_INIT() \
105 { \
106 gpio_pin_config_t sw_config = { \
107 kGPIO_DigitalInput, 0, kGPIO_IntFallingEdge, \
108 }; \
109 GPIO_PinInit(BOARD_USDHC_CD_GPIO_BASE, BOARD_USDHC_CD_GPIO_PIN, &sw_config); \
110 GPIO_PortEnableInterrupts(BOARD_USDHC_CD_GPIO_BASE, 1U << BOARD_USDHC_CD_GPIO_PIN); \
111 GPIO_PortClearInterruptFlags(BOARD_USDHC_CD_GPIO_BASE, ~0); \
112 }
113
114#define BOARD_HAS_SDCARD (1U)
115#define BOARD_SD_POWER_RESET_GPIO (GPIO3)
116#define BOARD_SD_POWER_RESET_GPIO_PIN (24U)
117
118#define BOARD_USDHC_CARD_INSERT_CD_LEVEL (0U)
119
120#define BOARD_USDHC_MMCCARD_POWER_CONTROL(state)
121
122#define BOARD_USDHC_MMCCARD_POWER_CONTROL_INIT() \
123 { \
124 gpio_pin_config_t sw_config = { \
125 kGPIO_DigitalOutput, 0, kGPIO_NoIntmode, \
126 }; \
127 GPIO_PinInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, &sw_config); \
128 GPIO_PinWrite(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, true); \
129 }
130
131#define BOARD_USDHC_SDCARD_POWER_CONTROL_INIT() \
132 { \
133 gpio_pin_config_t sw_config = { \
134 kGPIO_DigitalOutput, 0, kGPIO_NoIntmode, \
135 }; \
136 GPIO_PinInit(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, &sw_config); \
137 }
138
139#define BOARD_USDHC_SDCARD_POWER_CONTROL(state) \
140 (GPIO_PinWrite(BOARD_SD_POWER_RESET_GPIO, BOARD_SD_POWER_RESET_GPIO_PIN, state))
141
142#define BOARD_USDHC1_CLK_FREQ (CLOCK_GetSysPfdFreq(kCLOCK_Pfd2) / (CLOCK_GetDiv(kCLOCK_Usdhc1Div) + 1U))
143#define BOARD_USDHC2_CLK_FREQ (CLOCK_GetSysPfdFreq(kCLOCK_Pfd2) / (CLOCK_GetDiv(kCLOCK_Usdhc2Div) + 1U))
144
145#define BOARD_SD_HOST_BASEADDR BOARD_USDHC1_BASEADDR
146#define BOARD_SD_HOST_CLK_FREQ BOARD_USDHC1_CLK_FREQ
147#define BOARD_SD_HOST_IRQ USDHC1_IRQn
148
149#define BOARD_MMC_HOST_BASEADDR BOARD_USDHC2_BASEADDR
150#define BOARD_MMC_HOST_CLK_FREQ BOARD_USDHC2_CLK_FREQ
151#define BOARD_MMC_HOST_IRQ USDHC2_IRQn
152#define BOARD_MMC_VCCQ_SUPPLY kMMC_VoltageWindow170to195
153#define BOARD_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360
154/* we are using the BB SD socket to DEMO the MMC example,but the
155* SD socket provide 4bit bus only, so we define this macro to avoid
156* 8bit data bus test
157*/
158#define BOARD_MMC_SUPPORT_8BIT_BUS (1U)
159
160#define BOARD_SD_HOST_SUPPORT_SDR104_FREQ (100000000U)
161#define BOARD_SD_HOST_SUPPORT_HS200_FREQ (180000000U)
162/*! @brief The WIFI-QCA shield pin. */
163#define BOARD_INITGT202SHIELD_PWRON_GPIO GPIO1 /*!< GPIO device name: GPIO */
164#define BOARD_INITGT202SHIELD_PWRON_PORT 1U /*!< PORT device index: 1 */
165#define BOARD_INITGT202SHIELD_PWRON_GPIO_PIN 23U /*!< PIO4 pin index: 23 */
166#define BOARD_INITGT202SHIELD_PWRON_PIN_NAME GPIO1_23 /*!< Pin name */
167#define BOARD_INITGT202SHIELD_PWRON_LABEL "PWRON" /*!< Label */
168#define BOARD_INITGT202SHIELD_PWRON_NAME "PWRON" /*!< Identifier name */
169#define BOARD_INITGT202SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput /*!< Direction */
170
171#define BOARD_INITGT202SHIELD_IRQ_GPIO GPIO1 /*!< GPIO device name: GPIO */
172#define BOARD_INITGT202SHIELD_IRQ_PORT 1U /*!< PORT device index: 1 */
173#define BOARD_INITGT202SHIELD_IRQ_GPIO_PIN 22U /*!< PIO1 pin index: 22 */
174#define BOARD_INITGT202SHIELD_IRQ_PIN_NAME GPIO1_22 /*!< Pin name */
175#define BOARD_INITGT202SHIELD_IRQ_LABEL "IRQ" /*!< Label */
176#define BOARD_INITGT202SHIELD_IRQ_NAME "IRQ" /*!< Identifier name */
177#define BOARD_INITGT202SHIELD_IRQ_DIRECTION kGPIO_DigitalInput /*!< Direction */
178
179#if defined(__cplusplus)
180extern "C" {
181#endif /* __cplusplus */
182
183/*******************************************************************************
184 * API
185 ******************************************************************************/
186uint32_t BOARD_DebugConsoleSrcFreq(void);
187
188void BOARD_InitDebugConsole(void);
189void BOARD_ConfigMPU(void);
190#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
191void BOARD_InitDebugConsole(void);
192void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz);
193status_t BOARD_LPI2C_Send(LPI2C_Type *base,
194 uint8_t deviceAddress,
195 uint32_t subAddress,
196 uint8_t subaddressSize,
197 uint8_t *txBuff,
198 uint8_t txBuffSize);
199status_t BOARD_LPI2C_Receive(LPI2C_Type *base,
200 uint8_t deviceAddress,
201 uint32_t subAddress,
202 uint8_t subaddressSize,
203 uint8_t *rxBuff,
204 uint8_t rxBuffSize);
205void BOARD_Accel_I2C_Init(void);
206status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff);
207status_t BOARD_Accel_I2C_Receive(
208 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
209void BOARD_Codec_I2C_Init(void);
210status_t BOARD_Codec_I2C_Send(
211 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
212status_t BOARD_Codec_I2C_Receive(
213 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
214#endif /* SDK_I2C_BASED_COMPONENT_USED */
215void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength);
216void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength);
217#if defined(__cplusplus)
218}
219#endif /* __cplusplus */
220
221#endif /* _BOARD_H_ */