From 4dbec3402e1158975b462aa290b780f8a54b2eb8 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 30 Apr 2024 16:44:27 +0200 Subject: [PATCH] Remove old embedded-hal trait implementations --- .../src/shared_bus/blocking/spi.rs | 98 +------------------ 1 file changed, 4 insertions(+), 94 deletions(-) diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index 7d383980d..8f1cce4ad 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs @@ -28,33 +28,30 @@ use crate::shared_bus::SpiDeviceError; use crate::SetConfig; /// SPI device on a shared bus. -pub struct SpiDevice<'a, M: RawMutex, BUS, CS, Word: Copy + 'static = u8> { +pub struct SpiDevice<'a, M: RawMutex, BUS, CS> { bus: &'a Mutex>, cs: CS, - _word: core::marker::PhantomData, } -impl<'a, M: RawMutex, BUS, CS, Word: Copy + 'static> SpiDevice<'a, M, BUS, CS, Word> { +impl<'a, M: RawMutex, BUS, CS> SpiDevice<'a, M, BUS, CS, > { /// Create a new `SpiDevice`. pub fn new(bus: &'a Mutex>, cs: CS) -> Self { Self { bus, cs, - _word: core::marker::PhantomData, } } } -impl<'a, M: RawMutex, BUS, CS, Word> spi::ErrorType for SpiDevice<'a, M, BUS, CS, Word> +impl<'a, M: RawMutex, BUS, CS> spi::ErrorType for SpiDevice<'a, M, BUS, CS, > where BUS: spi::ErrorType, CS: OutputPin, - Word: Copy + 'static, { type Error = SpiDeviceError; } -impl embedded_hal_1::spi::SpiDevice for SpiDevice<'_, M, BUS, CS, Word> +impl embedded_hal_1::spi::SpiDevice for SpiDevice<'_, M, BUS, CS, > where M: RawMutex, BUS: SpiBus, @@ -97,93 +94,6 @@ where } } -impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer - for SpiDevice<'_, M, BUS, CS, Word> -where - M: RawMutex, - BUS: embedded_hal_02::blocking::spi::Transfer, - CS: OutputPin, - Word: Copy + 'static, -{ - type Error = SpiDeviceError; - fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - let op_res = bus.transfer(words); - let cs_res = self.cs.set_high(); - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} - -impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Write for SpiDevice<'_, M, BUS, CS, Word> -where - M: RawMutex, - BUS: embedded_hal_02::blocking::spi::Write, - CS: OutputPin, - Word: Copy + 'static, -{ - type Error = SpiDeviceError; - - fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - let op_res = bus.write(words); - let cs_res = self.cs.set_high(); - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} - -impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer - for SpiDevice<'_, M, BUS, CS, Word> -where - M: RawMutex, - BUS: embedded_hal_02::blocking::spi::Transfer, - CS: OutputPin, - Word: Copy + 'static, -{ - type Error = SpiDeviceError; - fn transfer<'w>(&mut self, words: &'w mut [u16]) -> Result<&'w [u16], Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - let op_res = bus.transfer(words); - let cs_res = self.cs.set_high(); - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} - -impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Write for SpiDevice<'_, M, BUS, CS, Word> -where - M: RawMutex, - BUS: embedded_hal_02::blocking::spi::Write, - CS: OutputPin, - Word: Copy + 'static, -{ - type Error = SpiDeviceError; - - fn write(&mut self, words: &[u16]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - let op_res = bus.write(words); - let cs_res = self.cs.set_high(); - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} /// SPI device on a shared bus, with its own configuration. ///