embassy-embedded-hal: add support for all word sizes to async shared spi.

This commit is contained in:
Dario Nieuwenhuis 2024-05-20 10:56:15 +02:00
parent 31887b47bc
commit 78cdebbc95

View File

@ -55,13 +55,14 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<M, BUS, CS> spi::SpiDevice for SpiDevice<'_, M, BUS, CS> impl<M, BUS, CS, Word> spi::SpiDevice<Word> for SpiDevice<'_, M, BUS, CS>
where where
M: RawMutex, M: RawMutex,
BUS: spi::SpiBus, BUS: spi::SpiBus<Word>,
CS: OutputPin, CS: OutputPin,
Word: Copy + 'static,
{ {
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { async fn transaction(&mut self, operations: &mut [spi::Operation<'_, Word>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported); return Err(SpiDeviceError::DelayNotSupported);
} }
@ -138,13 +139,14 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<M, BUS, CS> spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> impl<M, BUS, CS, Word> spi::SpiDevice<Word> for SpiDeviceWithConfig<'_, M, BUS, CS>
where where
M: RawMutex, M: RawMutex,
BUS: spi::SpiBus + SetConfig, BUS: spi::SpiBus<Word> + SetConfig,
CS: OutputPin, CS: OutputPin,
Word: Copy + 'static,
{ {
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { async fn transaction(&mut self, operations: &mut [spi::Operation<'_, Word>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported); return Err(SpiDeviceError::DelayNotSupported);
} }