diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC55S66/project_template/board.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/LPC55S66/project_template/board.h | 251 |
1 files changed, 251 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC55S66/project_template/board.h b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC55S66/project_template/board.h new file mode 100644 index 000000000..870d99aeb --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC55S66/project_template/board.h | |||
@@ -0,0 +1,251 @@ | |||
1 | /* | ||
2 | * Copyright 2017-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_reset.h" | ||
14 | #include "fsl_gpio.h" | ||
15 | #include "fsl_iocon.h" | ||
16 | |||
17 | /******************************************************************************* | ||
18 | * Definitions | ||
19 | ******************************************************************************/ | ||
20 | /*! @brief The board name */ | ||
21 | #define BOARD_NAME "LPCXpresso55S69" | ||
22 | |||
23 | /*! @brief The UART to use for debug messages. */ | ||
24 | /* TODO: rename UART to USART */ | ||
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 12000000U | ||
29 | #define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0 | ||
30 | #define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn | ||
31 | #define BOARD_DEBUG_UART_CLKSRC kCLOCK_Flexcomm0 | ||
32 | #define BOARD_UART_IRQ_HANDLER FLEXCOMM0_IRQHandler | ||
33 | #define BOARD_UART_IRQ FLEXCOMM0_IRQn | ||
34 | |||
35 | #define BOARD_ACCEL_I2C_BASEADDR I2C4 | ||
36 | #define BOARD_ACCEL_I2C_CLOCK_FREQ 12000000 | ||
37 | |||
38 | #define BOARD_DEBUG_UART_TYPE_CORE1 kSerialPort_Uart | ||
39 | #define BOARD_DEBUG_UART_BASEADDR_CORE1 (uint32_t) USART1 | ||
40 | #define BOARD_DEBUG_UART_INSTANCE_CORE1 1U | ||
41 | #define BOARD_DEBUG_UART_CLK_FREQ_CORE1 12000000U | ||
42 | #define BOARD_DEBUG_UART_CLK_ATTACH_CORE1 kFRO12M_to_FLEXCOMM1 | ||
43 | #define BOARD_DEBUG_UART_RST_CORE1 kFC1_RST_SHIFT_RSTn | ||
44 | #define BOARD_DEBUG_UART_CLKSRC_CORE1 kCLOCK_Flexcomm1 | ||
45 | #define BOARD_UART_IRQ_HANDLER_CORE1 FLEXCOMM1_IRQHandler | ||
46 | #define BOARD_UART_IRQ_CORE1 FLEXCOMM1_IRQn | ||
47 | |||
48 | #ifndef BOARD_DEBUG_UART_BAUDRATE | ||
49 | #define BOARD_DEBUG_UART_BAUDRATE 115200U | ||
50 | #endif /* BOARD_DEBUG_UART_BAUDRATE */ | ||
51 | |||
52 | #ifndef BOARD_DEBUG_UART_BAUDRATE_CORE1 | ||
53 | #define BOARD_DEBUG_UART_BAUDRATE_CORE1 115200U | ||
54 | #endif /* BOARD_DEBUG_UART_BAUDRATE_CORE1 */ | ||
55 | |||
56 | #define BOARD_CODEC_I2C_BASEADDR I2C4 | ||
57 | #define BOARD_CODEC_I2C_CLOCK_FREQ 12000000 | ||
58 | |||
59 | #ifndef BOARD_LED_RED_GPIO | ||
60 | #define BOARD_LED_RED_GPIO GPIO | ||
61 | #endif | ||
62 | #define BOARD_LED_RED_GPIO_PORT 1U | ||
63 | #ifndef BOARD_LED_RED_GPIO_PIN | ||
64 | #define BOARD_LED_RED_GPIO_PIN 6U | ||
65 | #endif | ||
66 | |||
67 | #ifndef BOARD_LED_BLUE_GPIO | ||
68 | #define BOARD_LED_BLUE_GPIO GPIO | ||
69 | #endif | ||
70 | #define BOARD_LED_BLUE_GPIO_PORT 1U | ||
71 | #ifndef BOARD_LED_BLUE_GPIO_PIN | ||
72 | #define BOARD_LED_BLUE_GPIO_PIN 4U | ||
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 1U | ||
79 | #ifndef BOARD_LED_GREEN_GPIO_PIN | ||
80 | #define BOARD_LED_GREEN_GPIO_PIN 7U | ||
81 | #endif | ||
82 | |||
83 | #ifndef BOARD_SW1_GPIO | ||
84 | #define BOARD_SW1_GPIO GPIO | ||
85 | #endif | ||
86 | #define BOARD_SW1_GPIO_PORT 0U | ||
87 | #ifndef BOARD_SW1_GPIO_PIN | ||
88 | #define BOARD_SW1_GPIO_PIN 5U | ||
89 | #endif | ||
90 | #define BOARD_SW1_NAME "SW1" | ||
91 | #define BOARD_SW1_IRQ PIN_INT0_IRQn | ||
92 | #define BOARD_SW1_IRQ_HANDLER PIN_INT0_IRQHandler | ||
93 | |||
94 | #ifndef BOARD_SW2_GPIO | ||
95 | #define BOARD_SW2_GPIO GPIO | ||
96 | #endif | ||
97 | #define BOARD_SW2_GPIO_PORT 1U | ||
98 | #ifndef BOARD_SW2_GPIO_PIN | ||
99 | #define BOARD_SW2_GPIO_PIN 18U | ||
100 | #endif | ||
101 | #define BOARD_SW2_NAME "SW2" | ||
102 | #define BOARD_SW2_IRQ PIN_INT1_IRQn | ||
103 | #define BOARD_SW2_IRQ_HANDLER PIN_INT1_IRQHandler | ||
104 | #define BOARD_SW2_GPIO_PININT_INDEX 1 | ||
105 | |||
106 | #ifndef BOARD_SW3_GPIO | ||
107 | #define BOARD_SW3_GPIO GPIO | ||
108 | #endif | ||
109 | #define BOARD_SW3_GPIO_PORT 1U | ||
110 | #ifndef BOARD_SW3_GPIO_PIN | ||
111 | #define BOARD_SW3_GPIO_PIN 9U | ||
112 | #endif | ||
113 | #define BOARD_SW3_NAME "SW3" | ||
114 | #define BOARD_SW3_IRQ PIN_INT1_IRQn | ||
115 | #define BOARD_SW3_IRQ_HANDLER PIN_INT1_IRQHandler | ||
116 | #define BOARD_SW3_GPIO_PININT_INDEX 1 | ||
117 | |||
118 | #define BOARD_SDIF_BASEADDR SDIF | ||
119 | #define BOARD_SDIF_CLKSRC kCLOCK_SDio | ||
120 | #define BOARD_SDIF_CLK_FREQ CLOCK_GetSdioClkFreq() | ||
121 | #define BOARD_SDIF_CLK_ATTACH kMAIN_CLK_to_SDIO_CLK | ||
122 | #define BOARD_SDIF_IRQ SDIO_IRQn | ||
123 | #define BOARD_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360 | ||
124 | #define BOARD_SD_CARD_DETECT_PIN 17 | ||
125 | #define BOARD_SD_CARD_DETECT_PORT 0 | ||
126 | #define BOARD_SD_CARD_DETECT_GPIO GPIO | ||
127 | #define BOARD_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostCD | ||
128 | |||
129 | #define BOARD_SDIF_CD_GPIO_INIT() \ | ||
130 | { \ | ||
131 | CLOCK_EnableClock(kCLOCK_Gpio2); \ | ||
132 | GPIO_PinInit(BOARD_SD_CARD_DETECT_GPIO, BOARD_SD_CARD_DETECT_PORT, BOARD_SD_CARD_DETECT_PIN, \ | ||
133 | &(gpio_pin_config_t){kGPIO_DigitalInput, 0U}); \ | ||
134 | } | ||
135 | #define BOARD_SDIF_CD_STATUS() \ | ||
136 | GPIO_PinRead(BOARD_SD_CARD_DETECT_GPIO, BOARD_SD_CARD_DETECT_PORT, BOARD_SD_CARD_DETECT_PIN) | ||
137 | |||
138 | /* Board led color mapping */ | ||
139 | #define LOGIC_LED_ON 0U | ||
140 | #define LOGIC_LED_OFF 1U | ||
141 | |||
142 | #define BOARD_SDIF_CLK_ATTACH kMAIN_CLK_to_SDIO_CLK | ||
143 | |||
144 | #define LED_RED_INIT(output) \ | ||
145 | { \ | ||
146 | IOCON_PinMuxSet(IOCON, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ | ||
147 | (IOCON_PIO_FUNC0 | IOCON_PIO_MODE_INACT | IOCON_PIO_SLEW_STANDARD | IOCON_PIO_INV_DI | \ | ||
148 | IOCON_PIO_DIGITAL_EN | IOCON_PIO_OPENDRAIN_DI)); \ | ||
149 | GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ | ||
150 | &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \ | ||
151 | } | ||
152 | #define LED_RED_ON() \ | ||
153 | GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ | ||
154 | 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED1 */ | ||
155 | #define LED_RED_OFF() \ | ||
156 | GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ | ||
157 | 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED1 \ \ \ \ \ \ \ \ \ \ \ | ||
158 | */ | ||
159 | #define LED_RED_TOGGLE() \ | ||
160 | GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ | ||
161 | 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED1 */ | ||
162 | |||
163 | #define LED_BLUE_INIT(output) \ | ||
164 | { \ | ||
165 | IOCON_PinMuxSet(IOCON, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ | ||
166 | (IOCON_PIO_FUNC0 | IOCON_PIO_MODE_INACT | IOCON_PIO_SLEW_STANDARD | IOCON_PIO_INV_DI | \ | ||
167 | IOCON_PIO_DIGITAL_EN | IOCON_PIO_OPENDRAIN_DI)); \ | ||
168 | GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ | ||
169 | &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \ | ||
170 | } | ||
171 | #define LED_BLUE_ON() \ | ||
172 | GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ | ||
173 | 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED1 */ | ||
174 | #define LED_BLUE_OFF() \ | ||
175 | GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ | ||
176 | 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED1 */ | ||
177 | #define LED_BLUE_TOGGLE() \ | ||
178 | GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ | ||
179 | 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED1 */ | ||
180 | |||
181 | #define LED_GREEN_INIT(output) \ | ||
182 | GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \ | ||
183 | &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED1 */ | ||
184 | #define LED_GREEN_ON() \ | ||
185 | GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ | ||
186 | 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED1 */ | ||
187 | #define LED_GREEN_OFF() \ | ||
188 | GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ | ||
189 | 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED1 */ | ||
190 | #define LED_GREEN_TOGGLE() \ | ||
191 | GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ | ||
192 | 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED1 */ | ||
193 | |||
194 | /*! @brief The WIFI-QCA shield pin. */ | ||
195 | #define BOARD_INITGT202SHIELD_PWRON_GPIO GPIO | ||
196 | #define BOARD_INITGT202SHIELD_PWRON_PORT 1U | ||
197 | #define BOARD_INITGT202SHIELD_PWRON_PIN 8U | ||
198 | |||
199 | #define BOARD_INITGT202SHIELD_IRQ_GPIO GPIO | ||
200 | #define BOARD_INITGT202SHIELD_IRQ_PORT 1U | ||
201 | #define BOARD_INITGT202SHIELD_IRQ_PIN 9U | ||
202 | |||
203 | /*! @brief The WIFI-QCA shield pin. */ | ||
204 | #define BOARD_INITSILEX2401SHIELD_PWRON_GPIO GPIO | ||
205 | #define BOARD_INITSILEX2401SHIELD_PWRON_PORT 1U | ||
206 | #define BOARD_INITSILEX2401SHIELD_PWRON_PIN 7U | ||
207 | |||
208 | #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO GPIO | ||
209 | #define BOARD_INITSILEX2401SHIELD_IRQ_PORT 0U | ||
210 | #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO_PIN 15U | ||
211 | |||
212 | #if defined(__cplusplus) | ||
213 | extern "C" { | ||
214 | #endif /* __cplusplus */ | ||
215 | |||
216 | /******************************************************************************* | ||
217 | * API | ||
218 | ******************************************************************************/ | ||
219 | |||
220 | void BOARD_InitDebugConsole(void); | ||
221 | void BOARD_InitDebugConsole_Core1(void); | ||
222 | #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED | ||
223 | void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz); | ||
224 | status_t BOARD_I2C_Send(I2C_Type *base, | ||
225 | uint8_t deviceAddress, | ||
226 | uint32_t subAddress, | ||
227 | uint8_t subaddressSize, | ||
228 | uint8_t *txBuff, | ||
229 | uint8_t txBuffSize); | ||
230 | status_t BOARD_I2C_Receive(I2C_Type *base, | ||
231 | uint8_t deviceAddress, | ||
232 | uint32_t subAddress, | ||
233 | uint8_t subaddressSize, | ||
234 | uint8_t *rxBuff, | ||
235 | uint8_t rxBuffSize); | ||
236 | void BOARD_Accel_I2C_Init(void); | ||
237 | status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); | ||
238 | status_t BOARD_Accel_I2C_Receive( | ||
239 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
240 | void BOARD_Codec_I2C_Init(void); | ||
241 | status_t BOARD_Codec_I2C_Send( | ||
242 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); | ||
243 | status_t BOARD_Codec_I2C_Receive( | ||
244 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
245 | #endif /* SDK_I2C_BASED_COMPONENT_USED */ | ||
246 | |||
247 | #if defined(__cplusplus) | ||
248 | } | ||
249 | #endif /* __cplusplus */ | ||
250 | |||
251 | #endif /* _BOARD_H_ */ | ||