diff options
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus/blocking/spi.rs')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/blocking/spi.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index 0d01a590b..2583c699c 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs | |||
| @@ -4,7 +4,7 @@ use core::fmt::Debug; | |||
| 4 | 4 | ||
| 5 | use embedded_hal_1::digital::blocking::OutputPin; | 5 | use embedded_hal_1::digital::blocking::OutputPin; |
| 6 | use embedded_hal_1::spi; | 6 | use embedded_hal_1::spi; |
| 7 | use embedded_hal_1::spi::blocking::SpiDevice; | 7 | use embedded_hal_1::spi::blocking::{SpiBusFlush, SpiDevice}; |
| 8 | 8 | ||
| 9 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 9 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 10 | pub enum SpiBusDeviceError<BUS, CS> { | 10 | pub enum SpiBusDeviceError<BUS, CS> { |
| @@ -44,15 +44,15 @@ where | |||
| 44 | type Error = SpiBusDeviceError<BUS::Error, CS::Error>; | 44 | type Error = SpiBusDeviceError<BUS::Error, CS::Error>; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | impl<BUS, CS> spi::SpiDevice for SpiBusDevice<'_, BUS, CS> | 47 | impl<BUS, CS> SpiDevice for SpiBusDevice<'_, BUS, CS> |
| 48 | where | 48 | where |
| 49 | BUS: spi::SpiBusFlush, | 49 | BUS: SpiBusFlush, |
| 50 | CS: OutputPin, | 50 | CS: OutputPin, |
| 51 | { | 51 | { |
| 52 | type Bus = BUS; | 52 | type Bus = BUS; |
| 53 | fn transaction<R>(&mut self, f: impl FnOnce(&mut Self::Bus) -> Result<R, BUS::Error>) -> Result<R, Self::Error> { | 53 | fn transaction<R>(&mut self, f: impl FnOnce(&mut Self::Bus) -> Result<R, BUS::Error>) -> Result<R, Self::Error> { |
| 54 | let mut bus = self.bus.borrow_mut(); | 54 | let mut bus = self.bus.borrow_mut(); |
| 55 | self.cs.set_low().map_err(SpiDeviceWithCsError::Cs)?; | 55 | self.cs.set_low().map_err(SpiBusDeviceError::Cs)?; |
| 56 | 56 | ||
| 57 | let f_res = f(&mut bus); | 57 | let f_res = f(&mut bus); |
| 58 | 58 | ||
| @@ -60,9 +60,9 @@ where | |||
| 60 | let flush_res = bus.flush(); | 60 | let flush_res = bus.flush(); |
| 61 | let cs_res = self.cs.set_high(); | 61 | let cs_res = self.cs.set_high(); |
| 62 | 62 | ||
| 63 | let f_res = f_res.map_err(SpiDeviceWithCsError::Spi)?; | 63 | let f_res = f_res.map_err(SpiBusDeviceError::Spi)?; |
| 64 | flush_res.map_err(SpiDeviceWithCsError::Spi)?; | 64 | flush_res.map_err(SpiBusDeviceError::Spi)?; |
| 65 | cs_res.map_err(SpiDeviceWithCsError::Cs)?; | 65 | cs_res.map_err(SpiBusDeviceError::Cs)?; |
| 66 | 66 | ||
| 67 | Ok(f_res) | 67 | Ok(f_res) |
| 68 | } | 68 | } |
