Spi

Struct Spi 

Source
pub struct Spi<SPI: Instance, W, PULL = Floating> { /* private fields */ }
Expand description

Spi in Master mode

Implementations§

Source§

impl<SPI: Instance, PULL: UpMode> Spi<SPI, u8, PULL>

Source

pub fn new<const R: u8>( spi: impl Into<Rmp<SPI, R>>, pins: (Option<impl RInto<SPI::MSck, R>>, Option<impl RInto<SPI::Mi<PULL>, R>>, Option<impl RInto<SPI::Mo, R>>), mode: Mode, freq: Hertz, rcc: &mut Rcc, ) -> Self

Constructs an SPI instance using SPI1 in 8bit dataframe mode.

The pin parameter tuple (sck, miso, mosi) should be (PA5, PA6, PA7) or (PB3, PB4, PB5) configured as (Alternate<PushPull>, Input<...>, Alternate<PushPull>).

You can also use NoSck, NoMiso or NoMosi if you don’t want to use the pins

Source§

impl<SPI: Instance, PULL> Spi<SPI, u8, PULL>

Source

pub fn release( self, ) -> (SPI, (Option<SPI::MSck>, Option<SPI::Mi<PULL>>, Option<SPI::Mo>))

Source§

impl<SPI: Instance, PULL> Spi<SPI, u8, PULL>

Source

pub fn frame_size_16bit(self) -> Spi<SPI, u16, PULL>

Converts from 8bit dataframe to 16bit.

Source§

impl<SPI: Instance, PULL> Spi<SPI, u16, PULL>

Source

pub fn frame_size_8bit(self) -> Spi<SPI, u16, PULL>

Converts from 16bit dataframe to 8bit.

Source§

impl<PULL> Spi<SPI1, u8, PULL>

Source

pub fn with_tx_dma(self, channel: C3) -> SpiTxDma<SPI1, C3, PULL>

Source

pub fn with_rx_dma(self, channel: C2) -> SpiRxDma<SPI1, C2, PULL>

Source

pub fn with_rx_tx_dma( self, rxchannel: C2, txchannel: C3, ) -> SpiRxTxDma<SPI1, C2, C3, PULL>

Source§

impl<PULL> Spi<SPI2, u8, PULL>

Source

pub fn with_tx_dma(self, channel: C5) -> SpiTxDma<SPI2, C5, PULL>

Source

pub fn with_rx_dma(self, channel: C4) -> SpiRxDma<SPI2, C4, PULL>

Source

pub fn with_rx_tx_dma( self, rxchannel: C4, txchannel: C5, ) -> SpiRxTxDma<SPI2, C4, C5, PULL>

Methods from Deref<Target = SpiInner<SPI, W>>§

Source

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

Select which frame format is used for data transfers

Source

pub fn listen(&mut self, event: Event)

Starts listening to the SPI by enabling the Received data ready to be read (RXNE) interrupt and Transmit data register empty (TXE) interrupt

Source

pub fn unlisten(&mut self, event: Event)

Stops listening to the SPI by disabling the Received data ready to be read (RXNE) interrupt and Transmit data register empty (TXE) interrupt

Source

pub fn is_tx_empty(&self) -> bool

Returns true if the tx register is empty (and can accept data)

Source

pub fn is_rx_not_empty(&self) -> bool

Returns true if the rx register is not empty (and can be read)

Source

pub fn is_busy(&self) -> bool

Returns true if the transfer is in progress

Source

pub fn is_overrun(&self) -> bool

Returns true if data are received and the previous data have not yet been read from SPI_DR.

Source

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

Source

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

Source

pub fn write(&mut self, words: &[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 read(&mut self, words: &mut [W]) -> Result<(), Error>

Trait Implementations§

Source§

impl<SPI: Instance, W, PULL> Deref for Spi<SPI, W, PULL>

Source§

type Target = SpiInner<SPI, W>

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<SPI: Instance, W, PULL> DerefMut for Spi<SPI, W, PULL>

Source§

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

Mutably dereferences the value.
Source§

impl<SPI: Instance, W, PULL> ErrorType for Spi<SPI, W, PULL>

Source§

type Error = Error

Error type.
Source§

impl<SPI, W, PULL> FullDuplex<W> for Spi<SPI, W, PULL>
where SPI: Instance, W: FrameSize,

Source§

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

Reads the word stored in the shift register Read more
Source§

fn write(&mut self, data: W) -> Result<(), Error>

Writes a word to the slave
Source§

impl<SPI, W, PULL> SpiBus<W> for Spi<SPI, W, PULL>
where SPI: Instance, W: FrameSize + 'static,

Source§

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

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
Source§

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

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
Source§

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

Read words from the slave. Read more
Source§

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

Write words to the slave, ignoring all the incoming words. Read more
Source§

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

Wait until all operations have completed and the bus is idle. Read more
Source§

impl<SPI: Instance, PULL> Write<u16> for Spi<SPI, u16, PULL>

Source§

type Error = Error

Error type
Source§

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

Sends words to the slave, ignoring all the incoming words
Source§

impl<SPI: Instance, PULL> Write<u8> for Spi<SPI, u8, PULL>

Source§

type Error = Error

Error type
Source§

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

Sends words to the slave, ignoring all the incoming words
Source§

impl<SPI, W, PULL> FullDuplex<W> for Spi<SPI, W, PULL>
where SPI: Instance, W: FrameSize,

Source§

type Error = Error

An enumeration of SPI errors
Source§

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

Reads the word stored in the shift register Read more
Source§

fn send(&mut self, data: W) -> Result<(), Error>

Sends a word to the slave
Source§

impl<SPI, W, PULL> Default<W> for Spi<SPI, W, PULL>
where SPI: Instance, W: FrameSize,

Auto Trait Implementations§

§

impl<SPI, W, PULL> Freeze for Spi<SPI, W, PULL>
where SPI: Freeze, <SPI as SpiCommon>::MSck: Freeze, <SPI as SpiCommon>::Mi<PULL>: Freeze, <SPI as SpiCommon>::Mo: Freeze,

§

impl<SPI, W, PULL> RefUnwindSafe for Spi<SPI, W, PULL>
where SPI: RefUnwindSafe, W: RefUnwindSafe, <SPI as SpiCommon>::MSck: RefUnwindSafe, <SPI as SpiCommon>::Mi<PULL>: RefUnwindSafe, <SPI as SpiCommon>::Mo: RefUnwindSafe,

§

impl<SPI, W, PULL> Send for Spi<SPI, W, PULL>
where SPI: Send, W: Send, <SPI as SpiCommon>::MSck: Send, <SPI as SpiCommon>::Mi<PULL>: Send, <SPI as SpiCommon>::Mo: Send,

§

impl<SPI, W, PULL> Sync for Spi<SPI, W, PULL>
where SPI: Sync, W: Sync, <SPI as SpiCommon>::MSck: Sync, <SPI as SpiCommon>::Mi<PULL>: Sync, <SPI as SpiCommon>::Mo: Sync,

§

impl<SPI, W, PULL> Unpin for Spi<SPI, W, PULL>
where SPI: Unpin, W: Unpin, <SPI as SpiCommon>::MSck: Unpin, <SPI as SpiCommon>::Mi<PULL>: Unpin, <SPI as SpiCommon>::Mo: Unpin,

§

impl<SPI, W, PULL> UnwindSafe for Spi<SPI, W, PULL>
where SPI: UnwindSafe, W: UnwindSafe, <SPI as SpiCommon>::MSck: UnwindSafe, <SPI as SpiCommon>::Mi<PULL>: UnwindSafe, <SPI as SpiCommon>::Mo: 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, const R: u8> RFrom<T, R> for T

Source§

fn rfrom(value: T) -> T

Source§

impl<S, T, const R: u8> RInto<T, R> for S
where T: RFrom<S, R>,

Source§

fn rinto(self) -> T

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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>,

Source§

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.
Source§

impl<W, S> Transfer<W> for S
where S: Default<W>, W: Clone,

Source§

type Error = <S as FullDuplex<W>>::Error

Error type
Source§

fn transfer<'w>( &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