Struct stm32_hal2::spi::Spi
source · [−]pub struct Spi<R> {
pub regs: R,
pub cfg: SpiConfig,
}
Expand description
Represents a Serial Peripheral Interface (SPI) peripheral.
Fields
regs: R
cfg: SpiConfig
Implementations
Initialize an SPI peripheral, including configuration register writes, and enabling and resetting its RCC peripheral clock.
L44 RM, section 40.4.9: “Procedure for disabling the SPI” When SPI is disabled, it is mandatory to follow the disable procedures described in this paragraph. It is important to do this before the system enters a low-power mode when the peripheral clock is stopped. Ongoing transactions can be corrupted in this case. In some modes the disable procedure is the only way to stop continuous communication running.
Read a single byte if available, or block until it’s available. See L44 RM, section 40.4.9: Data transmission and reception procedures.
Write a single byte if available, or block until it’s available. See L44 RM, section 40.4.9: Data transmission and reception procedures.
Write multiple bytes on the SPI line, blocking until complete. See L44 RM, section 40.4.9: Data transmission and reception procedures.
Trait Implementations
impl<R> FullDuplex<u8> for Spi<R> where
R: Deref<Target = RegisterBlock> + DmaPeriph + RccPeriph,
impl<R> FullDuplex<u8> for Spi<R> where
R: Deref<Target = RegisterBlock> + DmaPeriph + RccPeriph,
impl<R> Default<u8> for Spi<R> where
R: Deref<Target = RegisterBlock> + DmaPeriph + RccPeriph,
Auto Trait Implementations
impl<R> RefUnwindSafe for Spi<R> where
R: RefUnwindSafe,
impl<R> UnwindSafe for Spi<R> where
R: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Error = <S as FullDuplex<W>>::Error
type Error = <S as FullDuplex<W>>::Error
Error type
pub fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
pub fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
Sends words
to the slave. Returns the words
received from the slave