Struct embedded_hal_bus::spi::ExclusiveDevice
source · pub struct ExclusiveDevice<BUS, CS, D> { /* private fields */ }
Expand description
Implementations§
source§impl<BUS, CS, D> ExclusiveDevice<BUS, CS, D>
impl<BUS, CS, D> ExclusiveDevice<BUS, CS, D>
source§impl<BUS, CS> ExclusiveDevice<BUS, CS, NoDelay>
impl<BUS, CS> ExclusiveDevice<BUS, CS, NoDelay>
sourcepub fn new_no_delay(bus: BUS, cs: CS) -> Result<Self, CS::Error>where
CS: OutputPin,
pub fn new_no_delay(bus: BUS, cs: CS) -> Result<Self, CS::Error>where
CS: OutputPin,
Create a new ExclusiveDevice
without support for in-transaction delays.
This sets the cs
pin high, and returns an error if that fails. It is recommended
to set the pin high the moment it’s configured as an output, to avoid glitches.
Warning: The returned instance technically doesn’t comply with the SpiDevice
contract, which mandates delay support. It is relatively rare for drivers to use
in-transaction delays, so you might still want to use this method because it’s more practical.
Note that a future version of the driver might start using delays, causing your
code to panic. This wouldn’t be considered a breaking change from the driver side, because
drivers are allowed to assume SpiDevice
implementations comply with the contract.
If you feel this risk outweighs the convenience of having cargo
automatically upgrade
the driver crate, you might want to pin the driver’s version.
§Panics
The returned device will panic if you try to execute a transaction
that contains any operations of type Operation::DelayNs
.