From 73431a847b876f9604999a0e5ca9c8c6d1182e4e Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sat, 30 Oct 2021 01:16:43 +0200 Subject: [PATCH] fix UART rx (#187) --- rp2040-hal/src/uart.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rp2040-hal/src/uart.rs b/rp2040-hal/src/uart.rs index 20c55bc..8f57f63 100644 --- a/rp2040-hal/src/uart.rs +++ b/rp2040-hal/src/uart.rs @@ -328,19 +328,21 @@ impl UartPeripheral { if bytes_read < buffer.len() { let mut error: Option = None; - if self.device.uartdr.read().oe().bit_is_set() { + let read = self.device.uartdr.read(); + + if read.oe().bit_is_set() { error = Some(ReadErrorType::Overrun); } - if self.device.uartdr.read().be().bit_is_set() { + if read.be().bit_is_set() { error = Some(ReadErrorType::Break); } - if self.device.uartdr.read().pe().bit_is_set() { + if read.pe().bit_is_set() { error = Some(ReadErrorType::Parity); } - if self.device.uartdr.read().fe().bit_is_set() { + if read.fe().bit_is_set() { error = Some(ReadErrorType::Framing); } @@ -351,7 +353,7 @@ impl UartPeripheral { })); } - buffer[bytes_read] = self.device.uartdr.read().data().bits(); + buffer[bytes_read] = read.data().bits(); bytes_read += 1; } else { break &mut buffer[bytes_read..];