[bsp][nxp][mcxa153] add more UART channels (#9635)

* [bsp][nxp][mcxa153] add more UART channels
This commit is contained in:
下里巴人 2024-11-13 08:01:21 +08:00 committed by GitHub
parent f0934630c4
commit be0161ec62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 151 additions and 1 deletions

View File

@ -6,6 +6,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2024-02-06 yandld The first version for MCX * 2024-02-06 yandld The first version for MCX
* 2024-11-11 hywing add more UART channels
*/ */
#include <rtdevice.h> #include <rtdevice.h>
#include "drv_uart.h" #include "drv_uart.h"
@ -35,6 +36,22 @@ void LPUART0_IRQHandler(void)
uart_isr(&serial0); uart_isr(&serial0);
} }
#endif #endif
#if defined(BSP_USING_UART1)
struct rt_serial_device serial1;
void LPUART1_IRQHandler(void)
{
uart_isr(&serial1);
}
#endif
#if defined(BSP_USING_UART2)
struct rt_serial_device serial2;
void LPUART2_IRQHandler(void)
{
uart_isr(&serial2);
}
#endif
static const struct mcx_uart uarts[] = static const struct mcx_uart uarts[] =
{ {
@ -50,6 +67,30 @@ static const struct mcx_uart uarts[] =
"uart0", "uart0",
}, },
#endif #endif
#ifdef BSP_USING_UART1
{
&serial1,
LPUART1,
LPUART1_IRQn,
kCLOCK_Fro12M,
kFRO12M_to_LPUART1,
kCLOCK_GateLPUART1,
kCLOCK_DivLPUART1,
"uart1",
},
#endif
#ifdef BSP_USING_UART2
{
&serial2,
LPUART2,
LPUART2_IRQn,
kCLOCK_Fro12M,
kFRO12M_to_LPUART2,
kCLOCK_GateLPUART2,
kCLOCK_DivLPUART2,
"uart2",
},
#endif
}; };
static rt_err_t mcx_configure(struct rt_serial_device *serial, struct serial_configure *cfg) static rt_err_t mcx_configure(struct rt_serial_device *serial, struct serial_configure *cfg)

View File

@ -27,8 +27,14 @@ menu "On-chip Peripheral Drivers"
if BSP_USING_UART if BSP_USING_UART
config BSP_USING_UART0 config BSP_USING_UART0
bool "Enable LPUART as UART" bool "Enable LPUART as UART0"
default y default y
config BSP_USING_UART1
bool "Enable LPUART as UART1"
default n
config BSP_USING_UART2
bool "Enable LPUART as UART2"
default n
endif endif
menuconfig BSP_USING_I2C menuconfig BSP_USING_I2C

View File

@ -117,6 +117,109 @@ void BOARD_InitPins(void)
/* PORT0_3 (pin 52) is configured as LPUART0_TXD */ /* PORT0_3 (pin 52) is configured as LPUART0_TXD */
PORT_SetPinConfig(PORT0, 3U, &port0_3_pin52_config); PORT_SetPinConfig(PORT0, 3U, &port0_3_pin52_config);
#ifdef BSP_USING_UART1
const port_pin_config_t port1_8_pin2_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART1_RXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT1_8 (pin 2) is configured as LPUART1_RXD */
PORT_SetPinConfig(PORT1, 8U, &port1_8_pin2_config);
const port_pin_config_t port1_9_pin3_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART1_TXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT1_9 (pin 3) is configured as LPUART1_TXD */
PORT_SetPinConfig(PORT1, 9U, &port1_9_pin3_config);
#endif
#ifdef BSP_USING_UART2
const port_pin_config_t port3_14_pin36_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART2_RXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT3_14 (pin 36) is configured as LPUART2_RXD */
PORT_SetPinConfig(PORT3, 14U, &port3_14_pin36_config);
const port_pin_config_t port3_15_pin35_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART2_TXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT3_15 (pin 35) is configured as LPUART2_TXD */
PORT_SetPinConfig(PORT3, 15U, &port3_15_pin35_config);
#endif
#ifdef BSP_USING_PWM0 #ifdef BSP_USING_PWM0
ctimer_config_t config; ctimer_config_t config;
CTIMER_Init(CTIMER1, &config); CTIMER_Init(CTIMER1, &config);