summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2022-11-19 22:23:02 +0100
committerDamien George <damien@micropython.org>2022-12-14 12:43:34 +1100
commit5b1fd8802a14bb59ca1ecc30df317e5994b2a327 (patch)
treebb23c87a4132f6f76cc545be847303e805ff2783
parent4199f986ad7873f51aee5e9e51bffead775b06a1 (diff)
samd/machine_uart: Simplify machine_uart_any() and machine_uart_read().
Remove the call to uart_drain_rx_fifo(). It is not required, and may cause a race condition.
-rw-r--r--ports/samd/machine_uart.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/ports/samd/machine_uart.c b/ports/samd/machine_uart.c
index eb1415789..c8f25d985 100644
--- a/ports/samd/machine_uart.c
+++ b/ports/samd/machine_uart.c
@@ -362,8 +362,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_uart_deinit_obj, machine_uart_deinit);
STATIC mp_obj_t machine_uart_any(mp_obj_t self_in) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
- // get all bytes from the fifo first. May be obsolete.
- uart_drain_rx_fifo(self, sercom_instance[self->id]);
return MP_OBJ_NEW_SMALL_INT(ringbuf_avail(&self->read_buffer));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_uart_any_obj, machine_uart_any);
@@ -431,16 +429,10 @@ STATIC mp_uint_t machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t siz
uint64_t t = mp_hal_ticks_ms_64() + self->timeout;
uint64_t timeout_char = self->timeout_char;
uint8_t *dest = buf_in;
- Sercom *uart = sercom_instance[self->id];
for (size_t i = 0; i < size; i++) {
// Wait for the first/next character
while (ringbuf_avail(&self->read_buffer) == 0) {
- if (uart->USART.INTFLAG.bit.RXC != 0) {
- // Force a few incoming bytes to the buffer
- uart_drain_rx_fifo(self, uart);
- break;
- }
if (mp_hal_ticks_ms_64() > t) { // timed out
if (i <= 0) {
*errcode = MP_EAGAIN;