SPI: remove read/write_byte functions

This commit is contained in:
Juraj Sadel 2025-01-09 12:27:01 +01:00
parent 040c0fd353
commit 0f94d59b06

View File

@ -504,20 +504,6 @@ where
}
}
/// Read a byte from SPI.
///
/// Sends out a stuffing byte for every byte to read. This function doesn't
/// perform flushing. If you want to read the response to something you
/// have written before, consider using [`Self::transfer`] instead.
pub fn read_byte(&mut self) -> nb::Result<u8, Error> {
self.driver().read_byte()
}
/// Write a byte to SPI.
pub fn write_byte(&mut self, word: u8) -> nb::Result<(), Error> {
self.driver().write_byte(word)
}
/// Write bytes to SPI.
pub fn write_bytes(&mut self, words: &[u8]) -> Result<(), Error> {
self.driver().write_bytes(words)?;
@ -2139,11 +2125,14 @@ mod ehal1 {
Dm: DriverMode,
{
fn read(&mut self) -> nb::Result<u8, Self::Error> {
self.driver().read_byte()
let mut buffer = [0u8; 1];
self.driver().read_bytes(&mut buffer)?;
Ok(buffer[0])
}
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
self.driver().write_byte(word)
self.driver().write_bytes(&[word])?;
Ok(())
}
}
@ -2912,30 +2901,6 @@ impl Driver {
});
}
fn read_byte(&self) -> nb::Result<u8, Error> {
if self.busy() {
return Err(nb::Error::WouldBlock);
}
let reg_block = self.register_block();
Ok(u32::try_into(reg_block.w(0).read().bits()).unwrap_or_default())
}
fn write_byte(&self, word: u8) -> nb::Result<(), Error> {
if self.busy() {
return Err(nb::Error::WouldBlock);
}
self.configure_datalen(0, 1);
let reg_block = self.register_block();
reg_block.w(0).write(|w| w.buf().set(word.into()));
self.start_operation();
Ok(())
}
#[cfg_attr(place_spi_driver_in_ram, ram)]
fn fill_fifo(&self, chunk: &[u8]) {
// TODO: replace with `array_chunks` and `from_le_bytes`