You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "fix" for #8 assumes that drivers will only activate their CS right before communicating and deactivate it right afterwards and that there is no way for any other code in the same thread to do anything else in that time. However, this is not part of any API contract and drivers don't always work this way in practice.
The following hypothetical driver is perfectly valid, but using it with SpiProxy would lead to some unfortunate bugs.
pubstructDoomsdayDevice<SPI,CS>{spi:SPI,cs:CS,}impl<SPI,CS>DoomsdayDevice<SPI,CS>whereSPI: embedded_hal::blocking::spi::Write<u8>,CS: embedded_hal::digital::v2::OutputPin,CS::Error: core::fmt::Debug,{pubfnnew(spi:SPI,mutcs:CS) -> Self{// We own the SPI struct, so it is fine to just keep the CS pin active (low)
cs.set_low().unwrap();Self{ spi, cs }}pubfndetonate(&mutself) -> Result<(),SPI::Error>{// Send the super-secure password to the device, ending all life on earthself.spi.write(&[0x00])}pubfnsplit(self) -> (SPI,CS){letSelf{ spi,mut cs } = self;// Set the CS pin to idle (high)
cs.set_high().unwrap();(spi, cs)}}
Ack, I am aware of this. I'm in the process of writing up a response to the issue you linked, but didn't get to finishing it yet. Sorry for the radio silence in the last week.
The "fix" for #8 assumes that drivers will only activate their CS right before communicating and deactivate it right afterwards and that there is no way for any other code in the same thread to do anything else in that time. However, this is not part of any API contract and drivers don't always work this way in practice.
The following hypothetical driver is perfectly valid, but using it with SpiProxy would lead to some unfortunate bugs.
For my suggestion about how to fix this problem, see rust-embedded/embedded-hal#299
The text was updated successfully, but these errors were encountered: