Skip to content

Commit 0e9e661

Browse files
pi-anldpgeorge
authored andcommitted
mimxrt/machine_uart: Use a wrapper function to handle IRQ idle support.
MicroPython needs to handle the UART idle interrupt, which is not something that the standard SDK provides. This was previously fixed by including in the mimxrt port a modified copy of `fsl_lpuart.c`. This commit changes how that's done by building the unmodified `fsl_lpuart.c` directly from the SDK, and using linker wrapping to override the necessary functions to get at the idle IRQ. As part of this, the code is updated to work with the latest SDK. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent cf048e0 commit 0e9e661

3 files changed

Lines changed: 79 additions & 2015 deletions

File tree

ports/mimxrt/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ SRC_HAL_IMX_C += \
137137
$(MCUX_SDK_DIR)/drivers/lpi2c/fsl_lpi2c.c \
138138
$(MCUX_SDK_DIR)/drivers/lpspi/fsl_lpspi.c \
139139
$(MCUX_SDK_DIR)/drivers/lpspi/fsl_lpspi_edma.c \
140+
$(MCUX_SDK_DIR)/drivers/lpuart/fsl_lpuart.c \
140141
$(MCUX_SDK_DIR)/drivers/pit/fsl_pit.c \
141142
$(MCUX_SDK_DIR)/drivers/pwm/fsl_pwm.c \
142143
$(MCUX_SDK_DIR)/drivers/sai/fsl_sai.c \
@@ -152,6 +153,10 @@ else
152153
SRC_HAL_IMX_C += $(MCU_DIR)/xip/fsl_flexspi_nor_boot.c
153154
endif
154155

156+
# UART IRQ wrapper for UART.IRQ_RXIDLE support (see machine_uart.c for implementation details)
157+
# Double wrapping is required because SDK stores function pointers in s_lpuartIsr[] dispatch table
158+
LDFLAGS += --wrap=LPUART_TransferCreateHandle --wrap=LPUART_TransferHandleIRQ
159+
155160
INC_HAL_IMX += \
156161
-I$(TOP)/$(MCU_DIR) \
157162
-I$(TOP)/$(MCU_DIR)/drivers \
@@ -244,7 +249,6 @@ SRC_C += \
244249
eth.c \
245250
fatfs_port.c \
246251
flash.c \
247-
hal/fsl_lpuart.c \
248252
hal/pwm_backport.c \
249253
help.c \
250254
led.c \
@@ -505,7 +509,8 @@ LDFLAGS += \
505509
--cref \
506510
--gc-sections \
507511
--print-memory-usage \
508-
-Map=$@.map
512+
-Map=$@.map \
513+
--wrap=LPUART_TransferCreateHandle --wrap=LPUART_TransferHandleIRQ
509514

510515
# LDDEFINES are used for link time adaptation of linker scripts, utilizing
511516
# the C preprocessor. Therefore keep LDDEFINES separated from LDFLAGS!

0 commit comments

Comments
 (0)