-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Description
Hi.
Recently, the API of the SpiDevice
trait has been updated to use a list of Operation instances instead of passing a closure.
embedded-hal/embedded-hal/src/spi.rs
Line 342 in 9ac61a7
fn transaction(&mut self, operations: &mut [Operation<'_, Word>]) -> Result<(), Self::Error>; |
Before the API change, I had written code in the implementation of a driver for the ILI9341/ILI9342 SPI LCD, as shown below, to toggle the DC (Data/Command) pin while the CS is asserted.
// self.spi is a field whose type is `SpiDevice`
// Send command byte [0x04] while DC is low (which indicates command byte)
// Then change DC to high and read thee data bytes into `buffer`
let mut buffer = [0, 0, 0];
self.spi.transaction(|bus| {
self.pin_dc.set_low().unwrap();
bus.write(&[0x04])?;
self.pin_dc.set_high().unwrap();
bus.read(&mut buffer)?;
Ok(())
})
After the API was changed, it appears that toggling the DC pin within a transaction has become difficult.
So, my question is, how can I implement a similar function using the new API?
I couldn't find any examples to do it.
Metadata
Metadata
Assignees
Labels
No labels