Skip to content

Commit 05fb916

Browse files
committed
[UART] Fix serial_[rx|tx]_active functions
HAL_UART_GetState() return a combined value. So mask needs to be applied before compare the value. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 04ac4e3 commit 05fb916

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/arduino/stm32/uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ size_t uart_debug_write(uint8_t *data, uint32_t size)
633633
*/
634634
uint8_t serial_rx_active(serial_t *obj)
635635
{
636-
return ((obj == NULL) ? 1 : (HAL_UART_GetState(uart_handlers[obj->index]) == HAL_UART_STATE_BUSY_RX));
636+
return ((HAL_UART_GetState(uart_handlers[obj->index]) & HAL_UART_STATE_BUSY_RX) == HAL_UART_STATE_BUSY_RX);
637637
}
638638

639639
/**
@@ -644,7 +644,7 @@ uint8_t serial_rx_active(serial_t *obj)
644644
*/
645645
uint8_t serial_tx_active(serial_t *obj)
646646
{
647-
return ((obj == NULL) ? 1 : (HAL_UART_GetState(uart_handlers[obj->index]) == HAL_UART_STATE_BUSY_TX));
647+
return ((HAL_UART_GetState(uart_handlers[obj->index]) & HAL_UART_STATE_BUSY_TX) == HAL_UART_STATE_BUSY_TX);
648648
}
649649

650650
/**

0 commit comments

Comments
 (0)