From 7f6749a054a8c7873c9443af2905a9d110418c1b Mon Sep 17 00:00:00 2001 From: vandoul Date: Sat, 7 Feb 2026 17:38:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dn947=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=9D=BFarduino=E6=8E=A5=E5=8F=A3=E4=B8=B2=E5=8F=A3=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BD=BF=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mcx/mcxn/frdm-mcxn947/board/SConscript | 2 +- bsp/nxp/mcx/mcxn/frdm-mcxn947/board/board.c | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/SConscript b/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/SConscript index 277739d361f..70958fbab06 100644 --- a/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/SConscript +++ b/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/SConscript @@ -24,7 +24,7 @@ if GetDepend(['PKG_USING_CJSON']) and GetDepend(['PKG_USING_WEBCLIENT']): CPPPATH = [cwd, cwd + '/MCUX_Config/board'] -CPPDEFINES = ['DEBUG', 'CPU_MCXN947VDF_cm33_core0'] +CPPDEFINES = ['DEBUG', 'CPU_MCXN947VDF_cm33_core0', 'LPFLEXCOMM_INIT_NOT_USED_IN_DRIVER=1'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) diff --git a/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/board.c b/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/board.c index c7fd47bac4e..871ed972e6e 100644 --- a/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/board.c +++ b/bsp/nxp/mcx/mcxn/frdm-mcxn947/board/board.c @@ -34,6 +34,57 @@ void SysTick_Handler(void) rt_interrupt_leave(); } +/** + * This function will initial the FlexComm mode. + * +--------+----------------+--------+--------+--------------+ + * | Signal | LPSPI | LPUART | LPI2C | LPUART+LPI2C | + * +--------+----------------+--------+--------+--------------+ + * | FC_P0 | SDO/DATA[0] | RXD | SDA | SDA | + * | FC_P1 | SCK | TXD | SCL | SCL | + * | FC_P2 | SDI/DATA[1] | RTS_b | SCLS | TXD | + * | FC_P3 | PCS[0] | CTS_b | SDAS | RXD | + * | FC_P4 | PCS[3]/DATA[3] | DSR_b | HREQ_b | CTS_b | + * | FC_P5 | PCS[2]/DATA[2] | DTR_b | — | RTS_b | + * | FC_P6 | PCS[1]/HREQ | DCD_b | — | HREQ_b | + * +--------+----------------+--------+--------+--------------+ + */ +void rt_hw_flexcomm_mode_init(void) +{ +#ifdef BSP_USING_UART2 + LP_FLEXCOMM_Init(2, LP_FLEXCOMM_PERIPH_LPI2CAndLPUART); /* FLEXCOMM2 used for LPI2C and LPUART */ +#endif +#ifdef BSP_USING_UART4 + LP_FLEXCOMM_Init(4, LP_FLEXCOMM_PERIPH_LPUART); /* FLEXCOMM4 used for LPUART */ +#endif +#ifdef BSP_USING_UART5 + LP_FLEXCOMM_Init(5, LP_FLEXCOMM_PERIPH_LPUART); /* FLEXCOMM5 used for LPUART */ +#endif +#ifdef BSP_USING_UART6 + LP_FLEXCOMM_Init(6, LP_FLEXCOMM_PERIPH_LPUART); /* FLEXCOMM6 used for LPUART */ + #endif +#ifdef BSP_USING_SPI1 + LP_FLEXCOMM_Init(2, LP_FLEXCOMM_PERIPH_LPSPI); /* FLEXCOMM2 used for LPI2C and LPUART */ +#endif +#ifdef BSP_USING_SPI3 + LP_FLEXCOMM_Init(3, LP_FLEXCOMM_PERIPH_LPSPI); /* FLEXCOMM3 used for LPSPI */ +#endif +#ifdef BSP_USING_SPI6 + LP_FLEXCOMM_Init(6, LP_FLEXCOMM_PERIPH_LPSPI); /* FLEXCOMM6 used for LPSPI */ +#endif +#ifdef BSP_USING_SPI7 + LP_FLEXCOMM_Init(7, LP_FLEXCOMM_PERIPH_LPSPI); /* FLEXCOMM7 used for LPSPI */ +#endif +#ifdef BSP_USING_I2C0 + LP_FLEXCOMM_Init(0, LP_FLEXCOMM_PERIPH_LPI2C); /* FLEXCOMM0 used for LPI2C */ +#endif +#ifdef BSP_USING_I2C1 + LP_FLEXCOMM_Init(1, LP_FLEXCOMM_PERIPH_LPI2C); /* FLEXCOMM1 used for LPI2C */ +#endif +#ifdef BSP_USING_I2C2 + LP_FLEXCOMM_Init(2, LP_FLEXCOMM_PERIPH_LPI2C); /* FLEXCOMM2 used for LPI2C */ +#endif +} + /** * This function will initial board. */ From 49872b7e0e98745cf07a94462826b0a19f88bb27 Mon Sep 17 00:00:00 2001 From: vandoul Date: Sat, 7 Feb 2026 21:39:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E5=86=8D=E9=85=8D=E7=BD=AE=E5=90=8E=E6=97=A0=E6=B3=95=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/nxp/mcx/mcxn/Libraries/drivers/drv_uart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bsp/nxp/mcx/mcxn/Libraries/drivers/drv_uart.c b/bsp/nxp/mcx/mcxn/Libraries/drivers/drv_uart.c index 31b457d9fe3..e1790359d5b 100644 --- a/bsp/nxp/mcx/mcxn/Libraries/drivers/drv_uart.c +++ b/bsp/nxp/mcx/mcxn/Libraries/drivers/drv_uart.c @@ -133,6 +133,7 @@ static rt_err_t mcx_configure(struct rt_serial_device *serial, struct serial_con { struct mcx_uart *uart; /* Serial port hardware structure, calling the structure initialized above */ lpuart_config_t config;/* It contains basic configuration parameters of the serial port, such as baud rate, data bit, stop bit, and parity check */ + rt_uint32_t irq_regval; RT_ASSERT(serial != RT_NULL); /* assert */ RT_ASSERT(cfg != RT_NULL); @@ -159,8 +160,14 @@ static rt_err_t mcx_configure(struct rt_serial_device *serial, struct serial_con config.enableTx = true; config.enableRx = true; - + + irq_regval = LPUART_GetEnabledInterrupts(uart->uart_base); LPUART_Init(uart->uart_base, &config, CLOCK_GetFreq(uart->clock_src)); + if(irq_regval & kLPUART_RxDataRegFullInterruptEnable) + { + LPUART_EnableInterrupts(uart->uart_base, kLPUART_RxDataRegFullInterruptEnable); + EnableIRQ(uart->irqn); + } return RT_EOK; }