diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-05-20 10:56:15 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-05-20 10:56:43 +0200 |
| commit | 78cdebbc9523a0db3654f56e1a5acf8015d69248 (patch) | |
| tree | babd754d9f81d5ec779d5fbe4d8e38ab16928352 /embassy-embedded-hal/src/shared_bus/asynch | |
| parent | 31887b47bc7c7f72b707c3195c119dec58a38dce (diff) | |
embassy-embedded-hal: add support for all word sizes to async shared spi.
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus/asynch')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/spi.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index 9890f218d..30d4ecc36 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs | |||
| @@ -55,13 +55,14 @@ where | |||
| 55 | type Error = SpiDeviceError<BUS::Error, CS::Error>; | 55 | type Error = SpiDeviceError<BUS::Error, CS::Error>; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | impl<M, BUS, CS> spi::SpiDevice for SpiDevice<'_, M, BUS, CS> | 58 | impl<M, BUS, CS, Word> spi::SpiDevice<Word> for SpiDevice<'_, M, BUS, CS> |
| 59 | where | 59 | where |
| 60 | M: RawMutex, | 60 | M: RawMutex, |
| 61 | BUS: spi::SpiBus, | 61 | BUS: spi::SpiBus<Word>, |
| 62 | CS: OutputPin, | 62 | CS: OutputPin, |
| 63 | Word: Copy + 'static, | ||
| 63 | { | 64 | { |
| 64 | async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { | 65 | async fn transaction(&mut self, operations: &mut [spi::Operation<'_, Word>]) -> Result<(), Self::Error> { |
| 65 | if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { | 66 | if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { |
| 66 | return Err(SpiDeviceError::DelayNotSupported); | 67 | return Err(SpiDeviceError::DelayNotSupported); |
| 67 | } | 68 | } |
| @@ -138,13 +139,14 @@ where | |||
| 138 | type Error = SpiDeviceError<BUS::Error, CS::Error>; | 139 | type Error = SpiDeviceError<BUS::Error, CS::Error>; |
| 139 | } | 140 | } |
| 140 | 141 | ||
| 141 | impl<M, BUS, CS> spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> | 142 | impl<M, BUS, CS, Word> spi::SpiDevice<Word> for SpiDeviceWithConfig<'_, M, BUS, CS> |
| 142 | where | 143 | where |
| 143 | M: RawMutex, | 144 | M: RawMutex, |
| 144 | BUS: spi::SpiBus + SetConfig, | 145 | BUS: spi::SpiBus<Word> + SetConfig, |
| 145 | CS: OutputPin, | 146 | CS: OutputPin, |
| 147 | Word: Copy + 'static, | ||
| 146 | { | 148 | { |
| 147 | async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { | 149 | async fn transaction(&mut self, operations: &mut [spi::Operation<'_, Word>]) -> Result<(), Self::Error> { |
| 148 | if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { | 150 | if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { |
| 149 | return Err(SpiDeviceError::DelayNotSupported); | 151 | return Err(SpiDeviceError::DelayNotSupported); |
| 150 | } | 152 | } |
