Skip to content

Commit 0b9fce4

Browse files
bas-archembeddedkartben
authored andcommitted
drivers: serial: uart_mcux_lpuart: Restore lpuart CTRL register.
When RTS/CTS is toggled it disables the receiver and transmitter bits to be able to change the flow control bits in the MODIR register. After it has done so, it should restore the original value of the CTRL register to re-enable the transmitter and/or receiver if they were enabled before calling the mcux_lpuart_line_ctrl_set_rts() function. Signed-off-by: Bas van Loon <bas@arch-embedded.com>
1 parent 1938403 commit 0b9fce4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/serial/uart_mcux_lpuart.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ static int mcux_lpuart_configure(const struct device *dev,
12491249
static void mcux_lpuart_line_ctrl_set_rts(const struct device *dev, uint32_t val)
12501250
{
12511251
const struct mcux_lpuart_config *config = dev->config;
1252+
uint32_t old_ctrl = config->base->CTRL;
12521253

12531254
/* Disable Transmitter and Receiver */
12541255
config->base->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
@@ -1262,6 +1263,9 @@ static void mcux_lpuart_line_ctrl_set_rts(const struct device *dev, uint32_t val
12621263
config->base->MODIR &= ~(LPUART_MODIR_RXRTSE_MASK);
12631264
config->base->MODIR |= (LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK);
12641265
}
1266+
1267+
/* Restore Transmitter and Receiver */
1268+
config->base->CTRL = old_ctrl;
12651269
}
12661270
#else
12671271
#define mcux_lpuart_line_ctrl_set_rts(dev, val) ret = -ENOTSUP

0 commit comments

Comments
 (0)