Skip to content

Commit 8f4f450

Browse files
committed
Fix polling edge case in UART buffered read
Set available=0 instead of continue when xfercount=0x3FF and buffer not granted, preventing needless polling until rx data actually comes.
1 parent 2692cc1 commit 8f4f450

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/uart.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,15 +860,14 @@ impl<'a> UartRx<'a, Async> {
860860
// But if it is 0x3FF and buffer is not granted, this can mean we just finished transfer after
861861
// our grant check - so we skip this case to avoid overflowing written calculation below
862862
if xfercount == 0x3FF {
863-
continue;
864-
}
865-
866-
// Channel not active (transfer finished) and value is 0x3FF - nothing to transfer
867-
let remaining = xfercount as usize + 1;
863+
available = 0;
864+
} else {
865+
let remaining = xfercount as usize + 1;
868866

869-
let written = half_size - remaining;
870-
if written > buffer_config.read_off {
871-
available = written - buffer_config.read_off;
867+
let written = half_size - remaining;
868+
if written > buffer_config.read_off {
869+
available = written - buffer_config.read_off;
870+
}
872871
}
873872
}
874873
// If DMA is writing to the other buffer, no new data is available

0 commit comments

Comments
 (0)