Struct Spi

Source
pub struct Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION = Master> { /* private fields */ }

Implementations§

Source§

impl<REMAP, PINS> Spi<SPI1, REMAP, PINS, u8, Master>

Source

pub fn spi1( spi: SPI1, pins: PINS, mapr: &mut MAPR, mode: Mode, freq: Hertz, clocks: Clocks, ) -> Self
where REMAP: Remap<Periph = SPI1>, PINS: Pins<REMAP>,

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<...>, Input<...>, Alternate<...>).

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

Source§

impl<REMAP, PINS> Spi<SPI1, REMAP, PINS, u8, Slave>

Source

pub fn spi1_slave(spi: SPI1, pins: PINS, mapr: &mut MAPR, mode: Mode) -> Self
where REMAP: Remap<Periph = SPI1>, PINS: Pins<REMAP, Slave>,

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 (Input<...>, Alternate<...>, Input<...>).

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

Source§

impl<REMAP, PINS> Spi<SPI2, REMAP, PINS, u8, Master>

Source

pub fn spi2( spi: SPI2, pins: PINS, mode: Mode, freq: Hertz, clocks: Clocks, ) -> Self
where REMAP: Remap<Periph = SPI2>, PINS: Pins<REMAP>,

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

The pin parameter tuple (sck, miso, mosi) should be (PB13, PB14, PB15) configured as (Alternate<...>, Input<...>, Alternate<...>).

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

Source§

impl<REMAP, PINS> Spi<SPI2, REMAP, PINS, u8, Slave>

Source

pub fn spi2_slave(spi: SPI2, pins: PINS, mode: Mode) -> Self
where REMAP: Remap<Periph = SPI2>, PINS: Pins<REMAP, Slave>,

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

The pin parameter tuple (sck, miso, mosi) should be (PB13, PB14, PB15) configured as (Input<...>, Alternate<...>, Input<...>).

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

Source§

impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8, Master>

Source

pub fn spi3( spi: SPI3, pins: PINS, mode: Mode, freq: Hertz, clocks: Clocks, ) -> Self
where REMAP: Remap<Periph = SPI3>, PINS: Pins<REMAP>,

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

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

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

Source§

impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8, Slave>

Source

pub fn spi3_slave(spi: SPI3, pins: PINS, mode: Mode) -> Self
where REMAP: Remap<Periph = SPI3>, PINS: Pins<REMAP>,

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

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

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

Source§

impl<SPI, REMAP, PINS, FrameSize, OP> Spi<SPI, REMAP, PINS, FrameSize, OP>
where SPI: Instance, FrameSize: Copy,

Source

pub fn free(self) -> (SPI, PINS)

👎Deprecated since 0.6.0: Please use release instead
Source

pub fn release(self) -> (SPI, PINS)

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_overrun(&self) -> bool

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

Source

pub fn is_busy(&self) -> bool

Source§

impl<SPI, REMAP, PINS, OP> Spi<SPI, REMAP, PINS, u8, OP>
where SPI: Instance,

Source

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

Converts from 8bit dataframe to 16bit.

Source§

impl<SPI, REMAP, PINS, OP> Spi<SPI, REMAP, PINS, u16, OP>
where SPI: Instance,

Source

pub fn frame_size_8bit(self) -> Spi<SPI, REMAP, PINS, u8>

Converts from 16bit dataframe to 8bit.

Source§

impl<REMAP, PINS, OP> Spi<SPI1, REMAP, PINS, u8, OP>

Source

pub fn with_tx_dma(self, channel: C3) -> SpiTxDma<SPI1, REMAP, PINS, OP, C3>

Source

pub fn with_rx_dma(self, channel: C2) -> SpiRxDma<SPI1, REMAP, PINS, OP, C2>

Source

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

Source§

impl<REMAP, PINS, OP> Spi<SPI2, REMAP, PINS, u8, OP>

Source

pub fn with_tx_dma(self, channel: C5) -> SpiTxDma<SPI2, REMAP, PINS, OP, C5>

Source

pub fn with_rx_dma(self, channel: C4) -> SpiRxDma<SPI2, REMAP, PINS, OP, C4>

Source

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

Trait Implementations§

Source§

impl<SPI, REMAP, PINS, FrameSize, OP> SpiReadWrite<FrameSize> for Spi<SPI, REMAP, PINS, FrameSize, OP>
where SPI: Instance, FrameSize: Copy,

Source§

fn read_data_reg(&mut self) -> FrameSize

Source§

fn write_data_reg(&mut self, data: FrameSize)

Source§

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

Source§

impl<SPI, REMAP, PINS, OP> Write<u16> for Spi<SPI, REMAP, PINS, u16, OP>
where SPI: Instance,

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, REMAP, PINS, OP> Write<u8> for Spi<SPI, REMAP, PINS, u8, OP>
where SPI: Instance,

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, REMAP, PINS, FrameSize, OP> FullDuplex<FrameSize> for Spi<SPI, REMAP, PINS, FrameSize, OP>
where SPI: Instance, FrameSize: Copy,

Source§

type Error = Error

An enumeration of SPI errors
Source§

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

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

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

Sends a word to the slave
Source§

impl<SPI, REMAP, PINS, FrameSize, OP> Default<FrameSize> for Spi<SPI, REMAP, PINS, FrameSize, OP>
where SPI: Instance, FrameSize: Copy,

Auto Trait Implementations§

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> Freeze for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: Freeze, PINS: Freeze,

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> RefUnwindSafe for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: RefUnwindSafe, PINS: RefUnwindSafe, REMAP: RefUnwindSafe, FRAMESIZE: RefUnwindSafe, OPERATION: RefUnwindSafe,

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> Send for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: Send, PINS: Send, REMAP: Send, FRAMESIZE: Send, OPERATION: Send,

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> Sync for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: Sync, PINS: Sync, REMAP: Sync, FRAMESIZE: Sync, OPERATION: Sync,

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> Unpin for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: Unpin, PINS: Unpin, REMAP: Unpin, FRAMESIZE: Unpin, OPERATION: Unpin,

§

impl<SPI, REMAP, PINS, FRAMESIZE, OPERATION> UnwindSafe for Spi<SPI, REMAP, PINS, FRAMESIZE, OPERATION>
where SPI: UnwindSafe, PINS: UnwindSafe, REMAP: UnwindSafe, FRAMESIZE: UnwindSafe, OPERATION: 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>,

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