This commit is contained in:
Ragarnoy 2024-04-30 02:11:38 +02:00 committed by Dario Nieuwenhuis
parent c5a183fa82
commit 6df737a48c

View File

@ -37,8 +37,11 @@ pub struct SpiDevice<'a, M: RawMutex, BUS, CS, Word> {
impl<'a, M: RawMutex, BUS, CS, Word> SpiDevice<'a, M, BUS, CS, Word> { impl<'a, M: RawMutex, BUS, CS, Word> SpiDevice<'a, M, BUS, CS, Word> {
/// Create a new `SpiDevice`. /// Create a new `SpiDevice`.
pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, cs: CS) -> Self { pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, cs: CS) -> Self {
Self { bus, cs Self {
, _word: core::marker::PhantomData} bus,
cs,
_word: core::marker::PhantomData,
}
} }
} }
@ -93,7 +96,8 @@ where
} }
} }
impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer<u8> for SpiDevice<'_, M, BUS, CS, Word> impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer<u8>
for SpiDevice<'_, M, BUS, CS, Word>
where where
M: RawMutex, M: RawMutex,
BUS: embedded_hal_02::blocking::spi::Transfer<u8, Error = BusErr>, BUS: embedded_hal_02::blocking::spi::Transfer<u8, Error = BusErr>,
@ -134,11 +138,12 @@ where
} }
} }
impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer<u16> for SpiDevice<'_, M, BUS, CS, Word> impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transfer<u16>
where for SpiDevice<'_, M, BUS, CS, Word>
M: RawMutex, where
BUS: embedded_hal_02::blocking::spi::Transfer<u16, Error = BusErr>, M: RawMutex,
CS: OutputPin<Error = CsErr>, BUS: embedded_hal_02::blocking::spi::Transfer<u16, Error = BusErr>,
CS: OutputPin<Error = CsErr>,
{ {
type Error = SpiDeviceError<BusErr, CsErr>; type Error = SpiDeviceError<BusErr, CsErr>;
fn transfer<'w>(&mut self, words: &'w mut [u16]) -> Result<&'w [u16], Self::Error> { fn transfer<'w>(&mut self, words: &'w mut [u16]) -> Result<&'w [u16], Self::Error> {
@ -155,10 +160,10 @@ impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Transf
} }
impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Write<u16> for SpiDevice<'_, M, BUS, CS, Word> impl<'d, M, BUS, CS, BusErr, CsErr, Word> embedded_hal_02::blocking::spi::Write<u16> for SpiDevice<'_, M, BUS, CS, Word>
where where
M: RawMutex, M: RawMutex,
BUS: embedded_hal_02::blocking::spi::Write<u16, Error = BusErr>, BUS: embedded_hal_02::blocking::spi::Write<u16, Error = BusErr>,
CS: OutputPin<Error = CsErr>, CS: OutputPin<Error = CsErr>,
{ {
type Error = SpiDeviceError<BusErr, CsErr>; type Error = SpiDeviceError<BusErr, CsErr>;
@ -190,7 +195,12 @@ pub struct SpiDeviceWithConfig<'a, M: RawMutex, BUS: SetConfig, CS, Word> {
impl<'a, M: RawMutex, BUS: SetConfig, CS, Word> SpiDeviceWithConfig<'a, M, BUS, CS, Word> { impl<'a, M: RawMutex, BUS: SetConfig, CS, Word> SpiDeviceWithConfig<'a, M, BUS, CS, Word> {
/// Create a new `SpiDeviceWithConfig`. /// Create a new `SpiDeviceWithConfig`.
pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, cs: CS, config: BUS::Config) -> Self { pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, cs: CS, config: BUS::Config) -> Self {
Self { bus, cs, config, _word: core::marker::PhantomData } Self {
bus,
cs,
config,
_word: core::marker::PhantomData,
}
} }
/// Change the device's config at runtime /// Change the device's config at runtime