diff --git a/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c index dcceafb28a..19e5c9d7bd 100644 --- a/arch/arm/src/dm320/dm320_serial.c +++ b/arch/arm/src/dm320/dm320_serial.c @@ -268,6 +268,7 @@ static inline void up_waittxready(struct up_dev_s *priv) static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { uint16_t lcr = up_serialin(priv, UART_LCR); + if (enable) { lcr |= UART_LCR_BOC; @@ -276,6 +277,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { lcr &= ~UART_LCR_BOC; } + up_serialout(priv, UART_LCR, lcr); } diff --git a/arch/arm/src/lpc214x/lpc214x_serial.c b/arch/arm/src/lpc214x/lpc214x_serial.c index 041f9b8c05..62b18ecfe3 100644 --- a/arch/arm/src/lpc214x/lpc214x_serial.c +++ b/arch/arm/src/lpc214x/lpc214x_serial.c @@ -272,6 +272,7 @@ static inline void up_waittxready(struct up_dev_s *priv) static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { uint8_t lcr = up_serialin(priv, LPC214X_UART_LCR_OFFSET); + if (enable) { lcr |= LPC214X_LCR_BREAK_ENABLE; @@ -280,6 +281,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { lcr &= ~LPC214X_LCR_BREAK_ENABLE; } + up_serialout(priv, LPC214X_UART_LCR_OFFSET, lcr); } diff --git a/arch/arm/src/lpc2378/lpc23xx_serial.c b/arch/arm/src/lpc2378/lpc23xx_serial.c index 389d713284..9650a0827a 100644 --- a/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/arch/arm/src/lpc2378/lpc23xx_serial.c @@ -290,6 +290,7 @@ static inline void up_waittxready(struct up_dev_s *priv) static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { uint8_t lcr = up_serialin(priv, UART_LCR_OFFSET); + if (enable) { lcr |= LCR_BREAK_ENABLE; @@ -298,6 +299,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { lcr &= ~LCR_BREAK_ENABLE; } + up_serialout(priv, UART_LCR_OFFSET, lcr); } diff --git a/arch/arm/src/lpc43xx/lpc43_serial.c b/arch/arm/src/lpc43xx/lpc43_serial.c index 0dda586af1..c12d65597b 100644 --- a/arch/arm/src/lpc43xx/lpc43_serial.c +++ b/arch/arm/src/lpc43xx/lpc43_serial.c @@ -551,6 +551,7 @@ static inline void up_restoreuartint(struct up_dev_s *priv, uint32_t ier) static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { uint32_t lcr = up_serialin(priv, LPC43_UART_LCR_OFFSET); + if (enable) { lcr |= UART_LCR_BRK; @@ -559,6 +560,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { lcr &= ~UART_LCR_BRK; } + up_serialout(priv, LPC43_UART_LCR_OFFSET, lcr); } diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 2e11d52609..73039dcf6d 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -2060,8 +2060,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) #ifdef CONFIG_USART_BREAKS case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { - irqstate_t flags = enter_critical_section(); - uint32_t cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); + uint32_t cr2; + irqstate_t flags; + + flags = enter_critical_section(); + cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); up_serialout(priv, STM32_USART_CR2_OFFSET, cr2 | USART_CR2_LINEN); leave_critical_section(flags); } @@ -2069,9 +2072,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ { + uint32_t cr2; irqstate_t flags; + flags = enter_critical_section(); - uint32_t cr1 = up_serialin(priv, STM32_USART_CR2_OFFSET); + cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); up_serialout(priv, STM32_USART_CR2_OFFSET, cr2 & ~USART_CR2_LINEN); leave_critical_section(flags); } diff --git a/arch/arm/src/stm32f7/stm32_serial.c b/arch/arm/src/stm32f7/stm32_serial.c index d62b78fd6e..78810f52f3 100644 --- a/arch/arm/src/stm32f7/stm32_serial.c +++ b/arch/arm/src/stm32f7/stm32_serial.c @@ -1967,8 +1967,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) #ifdef CONFIG_USART_BREAKS case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { - irqstate_t flags = enter_critical_section(); - uint32_t cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); + uint32_t cr2; + irqstate_t flags; + + flags = enter_critical_section(); + cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); up_serialout(priv, STM32_USART_CR2_OFFSET, cr2 | USART_CR2_LINEN); leave_critical_section(flags); } @@ -1976,9 +1979,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ { + uint32_t cr2; irqstate_t flags; + flags = enter_critical_section(); - uint32_t cr1 = up_serialin(priv, STM32_USART_CR2_OFFSET); + cr2 = up_serialin(priv, STM32_USART_CR2_OFFSET); up_serialout(priv, STM32_USART_CR2_OFFSET, cr2 & ~USART_CR2_LINEN); leave_critical_section(flags); } diff --git a/arch/arm/src/stm32l4/stm32l4_serial.c b/arch/arm/src/stm32l4/stm32l4_serial.c index 68e9e75245..8f68409dba 100644 --- a/arch/arm/src/stm32l4/stm32l4_serial.c +++ b/arch/arm/src/stm32l4/stm32l4_serial.c @@ -1723,8 +1723,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) #ifdef CONFIG_USART_BREAKS case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { - irqstate_t flags = enter_critical_section(); - uint32_t cr2 = up_serialin(priv, STM32L4_USART_CR2_OFFSET); + uint32_t cr2; + irqstate_t flags; + + flags = enter_critical_section(); + cr2 = up_serialin(priv, STM32L4_USART_CR2_OFFSET); up_serialout(priv, STM32L4_USART_CR2_OFFSET, cr2 | USART_CR2_LINEN); leave_critical_section(flags); } @@ -1732,9 +1735,11 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ { + uint32_t cr2; irqstate_t flags; + flags = enter_critical_section(); - uint32_t cr1 = up_serialin(priv, STM32L4_USART_CR2_OFFSET); + cr2 = up_serialin(priv, STM32L4_USART_CR2_OFFSET); up_serialout(priv, STM32L4_USART_CR2_OFFSET, cr2 & ~USART_CR2_LINEN); leave_critical_section(flags); } diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index 8b8eb82564..c7de1031a3 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -520,6 +520,7 @@ static inline void u16550_restoreuartint(FAR struct u16550_s *priv, uint32_t ier static inline void u16550_enablebreaks(FAR struct u16550_s *priv, bool enable) { uint32_t lcr = u16550_serialin(priv, UART_LCR_OFFSET); + if (enable) { lcr |= UART_LCR_BRK; @@ -528,6 +529,7 @@ static inline void u16550_enablebreaks(FAR struct u16550_s *priv, bool enable) { lcr &= ~UART_LCR_BRK; } + u16550_serialout(priv, UART_LCR_OFFSET, lcr); }