Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions nrf-hal-common/src/uarte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ where
///
/// The buffer must have a length of at most 255 bytes.
pub fn read(&mut self, rx_buffer: &mut [u8]) -> Result<(), Error> {
start_read(&*self.0, rx_buffer, rx_buffer.len())?;
start_read(&*self.0, rx_buffer)?;

// Wait for transmission to end.
while self.0.events_endrx.read().bits() == 0 {}
Expand Down Expand Up @@ -183,7 +183,7 @@ where
I: timer::Instance,
{
// Start the read.
start_read(&self.0, rx_buffer, rx_buffer.len())?;
start_read(&self.0, rx_buffer)?;

// Start the timeout timer.
timer.start(cycles);
Expand Down Expand Up @@ -326,11 +326,7 @@ fn stop_write(uarte: &uarte0::RegisterBlock) {

/// Start a UARTE read transaction by setting the control
/// values and triggering a read task.
fn start_read(
uarte: &uarte0::RegisterBlock,
rx_buffer: &mut [u8],
nbytes: usize,
) -> Result<(), Error> {
fn start_read(uarte: &uarte0::RegisterBlock, rx_buffer: &mut [u8]) -> Result<(), Error> {
if rx_buffer.len() > EASY_DMA_SIZE {
return Err(Error::RxBufferTooLong);
}
Expand Down Expand Up @@ -359,7 +355,7 @@ fn start_read(
//
// The MAXCNT field is at least 8 bits wide and accepts the full
// range of values.
unsafe { w.maxcnt().bits(nbytes.min(rx_buffer.len()) as _) });
unsafe { w.maxcnt().bits(rx_buffer.len() as _) });

// Start UARTE Receive transaction.
uarte.tasks_startrx.write(|w|
Expand Down Expand Up @@ -676,7 +672,7 @@ where
}
Ok(self.rx_buf[0])
} else {
start_read(&uarte, self.rx_buf, 1)?;
start_read(&uarte, &mut self.rx_buf[..1])?;
Comment thread
lulf marked this conversation as resolved.
Outdated
Err(nb::Error::WouldBlock)
}
}
Expand Down