Struct stm32f4xx_hal::spi::SpiSlave

source ·
pub struct SpiSlave<SPI: Instance, const BIDI: bool = false, W = u8> { /* private fields */ }
Expand description

Spi in Slave mode

Implementations§

source§

impl<SPI: Instance, const BIDI: bool, W: FrameSize> SpiSlave<SPI, BIDI, W>

source

pub fn init(self) -> Self

source§

impl<SPI: Instance, W: FrameSize> SpiSlave<SPI, false, W>

source

pub fn to_bidi_transfer_mode(self) -> SpiSlave<SPI, true, W>

source§

impl<SPI: Instance, W: FrameSize> SpiSlave<SPI, true, W>

source

pub fn to_normal_transfer_mode(self) -> SpiSlave<SPI, false, W>

source§

impl<SPI, const BIDI: bool> SpiSlave<SPI, BIDI, u8>
where SPI: Instance,

source

pub fn frame_size_16bit(self) -> SpiSlave<SPI, BIDI, u16>

Converts from 8bit dataframe to 16bit.

source§

impl<SPI, const BIDI: bool> SpiSlave<SPI, BIDI, u16>
where SPI: Instance,

source

pub fn frame_size_8bit(self) -> SpiSlave<SPI, BIDI, u8>

Converts from 16bit dataframe to 8bit.

source§

impl<SPI: Instance> SpiSlave<SPI, false, u8>

source

pub fn new( spi: SPI, pins: (impl Into<SPI::Sck>, impl Into<SPI::Miso>, impl Into<SPI::Mosi>, Option<SPI::Nss>), mode: impl Into<Mode> ) -> Self

Enables the SPI clock, resets the peripheral, sets Alternate mode for pins and initialize the peripheral as SPI Slave Normal mode.

Note

Depending on freq you may need to set GPIO speed for pins (the Speed::Low is default for GPIO) before create Spi instance. Otherwise it may lead to the ‘wrong last bit in every received byte’ problem.

source§

impl<SPI: Instance> SpiSlave<SPI, true, u8>

source

pub fn new_bidi( spi: SPI, pins: (impl Into<SPI::Sck>, impl Into<SPI::Miso>, Option<SPI::Nss>), mode: impl Into<Mode> ) -> Self
where NoPin: Into<SPI::Mosi>,

Enables the SPI clock, resets the peripheral, sets Alternate mode for pins and initialize the peripheral as SPI Slave BIDI mode.

Note

Depending on freq you may need to set GPIO speed for pins (the Speed::Low is default for GPIO) before create Spi instance. Otherwise it may lead to the ‘wrong last bit in every received byte’ problem.

source§

impl<SPI: Instance, const BIDI: bool, W> SpiSlave<SPI, BIDI, W>

source

pub fn release( self ) -> (SPI, (SPI::Sck, SPI::Miso, SPI::Mosi, Option<SPI::Nss>))

source§

impl<SPI: Instance, const BIDI: bool, W> SpiSlave<SPI, BIDI, W>

source

pub fn set_internal_nss(&mut self, value: bool)

Set the slave select bit programmatically.

source§

impl<SPI: Instance, const BIDI: bool> SpiSlave<SPI, BIDI, u8>

source

pub fn use_dma(self) -> DmaBuilder<SPI>

source§

impl<SPI: Instance, const BIDI: bool, W: FrameSize> SpiSlave<SPI, BIDI, W>

source

pub fn read_nonblocking(&mut self) -> Result<W, Error>

source

pub fn write_nonblocking(&mut self, byte: W) -> Result<(), Error>

source

pub fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Error>

source

pub fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Error>

source

pub fn flush(&mut self) -> Result<(), Error>

source

pub fn write(&mut self, words: &[W]) -> Result<(), Error>

source

pub fn read(&mut self, words: &mut [W]) -> Result<(), Error>

Methods from Deref<Target = Inner<SPI>>§

source

pub fn enable(&mut self, enable: bool)

Enable/disable spi

source

pub fn bit_format(&mut self, format: BitFormat)

Select which frame format is used for data transfers

source

pub fn is_tx_empty(&self) -> bool

Return true if the TXE flag is set, i.e. new data to transmit can be written to the SPI.

source

pub fn is_rx_not_empty(&self) -> bool

Return true if the RXNE flag is set, i.e. new data has been received and can be read from the SPI.

source

pub fn is_modf(&self) -> bool

Return true if the MODF flag is set, i.e. the SPI has experienced a Master Mode Fault. (see chapter 28.3.10 of the STM32F4 Reference Manual)

source

pub fn is_busy(&self) -> bool

Returns true if the transfer is in progress

source

pub fn is_overrun(&self) -> bool

Return true if the OVR flag is set, i.e. new data has been received while the receive data register was already filled.

Trait Implementations§

source§

impl<SPI: Debug + Instance, const BIDI: bool, W: Debug> Debug for SpiSlave<SPI, BIDI, W>
where SPI::Sck: Debug, SPI::Miso: Debug, SPI::Mosi: Debug, SPI::Nss: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<SPI: Instance, const BIDI: bool, W> Deref for SpiSlave<SPI, BIDI, W>

§

type Target = Inner<SPI>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<SPI: Instance, const BIDI: bool, W> DerefMut for SpiSlave<SPI, BIDI, W>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<SPI, const BIDI: bool, W> RefUnwindSafe for SpiSlave<SPI, BIDI, W>

§

impl<SPI, const BIDI: bool, W> Send for SpiSlave<SPI, BIDI, W>
where SPI: Send, W: Send, <SPI as SpiCommon>::Miso: Send, <SPI as SpiCommon>::Mosi: Send, <SPI as SpiCommon>::Nss: Send, <SPI as SpiCommon>::Sck: Send,

§

impl<SPI, const BIDI: bool, W> Sync for SpiSlave<SPI, BIDI, W>
where SPI: Sync, W: Sync, <SPI as SpiCommon>::Miso: Sync, <SPI as SpiCommon>::Mosi: Sync, <SPI as SpiCommon>::Nss: Sync, <SPI as SpiCommon>::Sck: Sync,

§

impl<SPI, const BIDI: bool, W> Unpin for SpiSlave<SPI, BIDI, W>
where SPI: Unpin, W: Unpin, <SPI as SpiCommon>::Miso: Unpin, <SPI as SpiCommon>::Mosi: Unpin, <SPI as SpiCommon>::Nss: Unpin, <SPI as SpiCommon>::Sck: Unpin,

§

impl<SPI, const BIDI: bool, W> UnwindSafe for SpiSlave<SPI, BIDI, W>
where SPI: UnwindSafe, W: UnwindSafe, <SPI as SpiCommon>::Miso: UnwindSafe, <SPI as SpiCommon>::Mosi: UnwindSafe, <SPI as SpiCommon>::Nss: UnwindSafe, <SPI as SpiCommon>::Sck: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.