Skip to content

Commit da6fedb

Browse files
committed
[bsp][nxp][mcxa153] add more UART channels
1 parent f8ea6c6 commit da6fedb

File tree

3 files changed

+155
-4
lines changed

3 files changed

+155
-4
lines changed

bsp/nxp/mcx/mcxa/Libraries/drivers/drv_uart.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2024-02-06 yandld The first version for MCX
9+
* 2024-11-11 hywing add more UART channels
910
*/
1011
#include <rtdevice.h>
1112
#include "drv_uart.h"
@@ -35,6 +36,22 @@ void LPUART0_IRQHandler(void)
3536
uart_isr(&serial0);
3637
}
3738
#endif
39+
#if defined(BSP_USING_UART1)
40+
struct rt_serial_device serial1;
41+
42+
void LPUART1_IRQHandler(void)
43+
{
44+
uart_isr(&serial1);
45+
}
46+
#endif
47+
#if defined(BSP_USING_UART2)
48+
struct rt_serial_device serial2;
49+
50+
void LPUART2_IRQHandler(void)
51+
{
52+
uart_isr(&serial2);
53+
}
54+
#endif
3855

3956
static const struct mcx_uart uarts[] =
4057
{
@@ -50,6 +67,30 @@ static const struct mcx_uart uarts[] =
5067
"uart0",
5168
},
5269
#endif
70+
#ifdef BSP_USING_UART1
71+
{
72+
&serial1,
73+
LPUART1,
74+
LPUART1_IRQn,
75+
kCLOCK_Fro12M,
76+
kFRO12M_to_LPUART1,
77+
kCLOCK_GateLPUART1,
78+
kCLOCK_DivLPUART1,
79+
"uart1",
80+
},
81+
#endif
82+
#ifdef BSP_USING_UART2
83+
{
84+
&serial2,
85+
LPUART2,
86+
LPUART2_IRQn,
87+
kCLOCK_Fro12M,
88+
kFRO12M_to_LPUART2,
89+
kCLOCK_GateLPUART2,
90+
kCLOCK_DivLPUART2,
91+
"uart2",
92+
},
93+
#endif
5394
};
5495

5596
static rt_err_t mcx_configure(struct rt_serial_device *serial, struct serial_configure *cfg)

bsp/nxp/mcx/mcxa/frdm-mcxa153/board/Kconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ menu "On-chip Peripheral Drivers"
2727

2828
if BSP_USING_UART
2929
config BSP_USING_UART0
30-
bool "Enable LPUART as UART"
30+
bool "Enable LPUART as UART0"
3131
default y
32+
config BSP_USING_UART1
33+
bool "Enable LPUART as UART1"
34+
default n
35+
config BSP_USING_UART2
36+
bool "Enable LPUART as UART2"
37+
default n
3238
endif
3339

3440
menuconfig BSP_USING_I2C
@@ -55,7 +61,7 @@ menu "On-chip Peripheral Drivers"
5561
bool "Enable SPI0"
5662
default n
5763

58-
config BSP_USING_SPI1
64+
config BSP_USING_SPI1
5965
bool "Enable SPI1"
6066
default n
6167
endif

bsp/nxp/mcx/mcxa/frdm-mcxa153/board/MCUX_Config/board/pin_mux.c

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void BOARD_InitPins(void)
5353

5454
RESET_ReleasePeripheralReset(kCTIMER1_RST_SHIFT_RSTn);
5555
RESET_ReleasePeripheralReset(kLPSPI0_RST_SHIFT_RSTn);
56-
RESET_ReleasePeripheralReset(kLPSPI1_RST_SHIFT_RSTn);
56+
RESET_ReleasePeripheralReset(kLPSPI1_RST_SHIFT_RSTn);
5757

5858
RESET_ReleasePeripheralReset(kLPI2C0_RST_SHIFT_RSTn);
5959

@@ -117,6 +117,110 @@ void BOARD_InitPins(void)
117117
/* PORT0_3 (pin 52) is configured as LPUART0_TXD */
118118
PORT_SetPinConfig(PORT0, 3U, &port0_3_pin52_config);
119119

120+
#ifdef BSP_USING_UART1
121+
const port_pin_config_t port1_8_pin2_config = {/* Internal pull-up resistor is enabled */
122+
kPORT_PullUp,
123+
/* Low internal pull resistor value is selected. */
124+
kPORT_LowPullResistor,
125+
/* Fast slew rate is configured */
126+
kPORT_FastSlewRate,
127+
/* Passive input filter is disabled */
128+
kPORT_PassiveFilterDisable,
129+
/* Open drain output is disabled */
130+
kPORT_OpenDrainDisable,
131+
/* Low drive strength is configured */
132+
kPORT_LowDriveStrength,
133+
/* Normal drive strength is configured */
134+
kPORT_NormalDriveStrength,
135+
/* Pin is configured as LPUART1_RXD */
136+
kPORT_MuxAlt2,
137+
/* Digital input enabled */
138+
kPORT_InputBufferEnable,
139+
/* Digital input is not inverted */
140+
kPORT_InputNormal,
141+
/* Pin Control Register fields [15:0] are not locked */
142+
kPORT_UnlockRegister};
143+
/* PORT1_8 (pin 2) is configured as LPUART1_RXD */
144+
PORT_SetPinConfig(PORT1, 8U, &port1_8_pin2_config);
145+
146+
const port_pin_config_t port1_9_pin3_config = {/* Internal pull-up resistor is enabled */
147+
kPORT_PullUp,
148+
/* Low internal pull resistor value is selected. */
149+
kPORT_LowPullResistor,
150+
/* Fast slew rate is configured */
151+
kPORT_FastSlewRate,
152+
/* Passive input filter is disabled */
153+
kPORT_PassiveFilterDisable,
154+
/* Open drain output is disabled */
155+
kPORT_OpenDrainDisable,
156+
/* Low drive strength is configured */
157+
kPORT_LowDriveStrength,
158+
/* Normal drive strength is configured */
159+
kPORT_NormalDriveStrength,
160+
/* Pin is configured as LPUART1_TXD */
161+
kPORT_MuxAlt2,
162+
/* Digital input enabled */
163+
kPORT_InputBufferEnable,
164+
/* Digital input is not inverted */
165+
kPORT_InputNormal,
166+
/* Pin Control Register fields [15:0] are not locked */
167+
kPORT_UnlockRegister};
168+
/* PORT1_9 (pin 3) is configured as LPUART1_TXD */
169+
PORT_SetPinConfig(PORT1, 9U, &port1_9_pin3_config);
170+
#endif
171+
172+
#ifdef BSP_USING_UART2
173+
const port_pin_config_t port3_14_pin36_config = {/* Internal pull-up resistor is enabled */
174+
kPORT_PullUp,
175+
/* Low internal pull resistor value is selected. */
176+
kPORT_LowPullResistor,
177+
/* Fast slew rate is configured */
178+
kPORT_FastSlewRate,
179+
/* Passive input filter is disabled */
180+
kPORT_PassiveFilterDisable,
181+
/* Open drain output is disabled */
182+
kPORT_OpenDrainDisable,
183+
/* Low drive strength is configured */
184+
kPORT_LowDriveStrength,
185+
/* Normal drive strength is configured */
186+
kPORT_NormalDriveStrength,
187+
/* Pin is configured as LPUART2_RXD */
188+
kPORT_MuxAlt2,
189+
/* Digital input enabled */
190+
kPORT_InputBufferEnable,
191+
/* Digital input is not inverted */
192+
kPORT_InputNormal,
193+
/* Pin Control Register fields [15:0] are not locked */
194+
kPORT_UnlockRegister};
195+
/* PORT3_14 (pin 36) is configured as LPUART2_RXD */
196+
PORT_SetPinConfig(PORT3, 14U, &port3_14_pin36_config);
197+
198+
const port_pin_config_t port3_15_pin35_config = {/* Internal pull-up resistor is enabled */
199+
kPORT_PullUp,
200+
/* Low internal pull resistor value is selected. */
201+
kPORT_LowPullResistor,
202+
/* Fast slew rate is configured */
203+
kPORT_FastSlewRate,
204+
/* Passive input filter is disabled */
205+
kPORT_PassiveFilterDisable,
206+
/* Open drain output is disabled */
207+
kPORT_OpenDrainDisable,
208+
/* Low drive strength is configured */
209+
kPORT_LowDriveStrength,
210+
/* Normal drive strength is configured */
211+
kPORT_NormalDriveStrength,
212+
/* Pin is configured as LPUART2_TXD */
213+
kPORT_MuxAlt2,
214+
/* Digital input enabled */
215+
kPORT_InputBufferEnable,
216+
/* Digital input is not inverted */
217+
kPORT_InputNormal,
218+
/* Pin Control Register fields [15:0] are not locked */
219+
kPORT_UnlockRegister};
220+
/* PORT3_15 (pin 35) is configured as LPUART2_TXD */
221+
PORT_SetPinConfig(PORT3, 15U, &port3_15_pin35_config);
222+
#endif
223+
120224
#ifdef BSP_USING_PWM0
121225
ctimer_config_t config;
122226
CTIMER_Init(CTIMER1, &config);
@@ -249,7 +353,7 @@ void BOARD_InitPins(void)
249353
#endif
250354

251355
#ifdef BSP_USING_SPI1
252-
const port_pin_config_t port2_12_pin22_config = {/* Internal pull-up/down resistor is disabled */
356+
const port_pin_config_t port2_12_pin22_config = {/* Internal pull-up/down resistor is disabled */
253357
kPORT_PullDisable,
254358
/* Low internal pull resistor value is selected. */
255359
kPORT_LowPullResistor,

0 commit comments

Comments
 (0)