Skip to content

Commit 655e41b

Browse files
committed
Simplify by passing slice only
1 parent 42dc2ee commit 655e41b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

nrf-hal-common/src/uarte.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ where
145145
///
146146
/// The buffer must have a length of at most 255 bytes.
147147
pub fn read(&mut self, rx_buffer: &mut [u8]) -> Result<(), Error> {
148-
start_read(&*self.0, rx_buffer, rx_buffer.len())?;
148+
start_read(&*self.0, rx_buffer)?;
149149

150150
// Wait for transmission to end.
151151
while self.0.events_endrx.read().bits() == 0 {}
@@ -183,7 +183,7 @@ where
183183
I: timer::Instance,
184184
{
185185
// Start the read.
186-
start_read(&self.0, rx_buffer, rx_buffer.len())?;
186+
start_read(&self.0, rx_buffer)?;
187187

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

327327
/// Start a UARTE read transaction by setting the control
328328
/// values and triggering a read task.
329-
fn start_read(
330-
uarte: &uarte0::RegisterBlock,
331-
rx_buffer: &mut [u8],
332-
nbytes: usize,
333-
) -> Result<(), Error> {
329+
fn start_read(uarte: &uarte0::RegisterBlock, rx_buffer: &mut [u8]) -> Result<(), Error> {
334330
if rx_buffer.len() > EASY_DMA_SIZE {
335331
return Err(Error::RxBufferTooLong);
336332
}
@@ -359,7 +355,7 @@ fn start_read(
359355
//
360356
// The MAXCNT field is at least 8 bits wide and accepts the full
361357
// range of values.
362-
unsafe { w.maxcnt().bits(nbytes.min(rx_buffer.len()) as _) });
358+
unsafe { w.maxcnt().bits(rx_buffer.len() as _) });
363359

364360
// Start UARTE Receive transaction.
365361
uarte.tasks_startrx.write(|w|
@@ -676,7 +672,7 @@ where
676672
}
677673
Ok(self.rx_buf[0])
678674
} else {
679-
start_read(&uarte, self.rx_buf, 1)?;
675+
start_read(&uarte, &mut self.rx_buf[..1])?;
680676
Err(nb::Error::WouldBlock)
681677
}
682678
}

0 commit comments

Comments
 (0)