Spi

Struct Spi 

Source
pub struct Spi<SPI, PINS> { /* private fields */ }
Expand description

SPI peripheral operating in full duplex master mode

Implementations§

Source§

impl<SCK, MISO, MOSI> Spi<SPI1, (SCK, MISO, MOSI)>

Source

pub fn spi1( spi: SPI1, pins: (SCK, MISO, MOSI), mode: Mode, freq: Hertz, clocks: Clocks, apb2: &mut <SPI1 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI1>, MISO: MisoPin<SPI1>, MOSI: MosiPin<SPI1>,

Configures the SPI peripheral to operate in full duplex master mode

Source

pub fn spi1_slave( spi: SPI1, pins: (SCK, MISO, MOSI), mode: Mode, apb2: &mut <SPI1 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI1>, MISO: MisoPin<SPI1>, MOSI: MosiPin<SPI1>,

Source

pub fn clear_overrun(&mut self)

Source

pub fn reclock(&mut self, freq: Hertz, clocks: Clocks)

Change the baud rate of the SPI

Source

pub fn free(self) -> (SPI1, (SCK, MISO, MOSI))

Releases the SPI peripheral and associated pins

Source§

impl<SCK, MISO, MOSI> Spi<SPI3, (SCK, MISO, MOSI)>

Source

pub fn spi3( spi: SPI3, pins: (SCK, MISO, MOSI), mode: Mode, freq: Hertz, clocks: Clocks, apb2: &mut <SPI3 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI3>, MISO: MisoPin<SPI3>, MOSI: MosiPin<SPI3>,

Configures the SPI peripheral to operate in full duplex master mode

Source

pub fn spi3_slave( spi: SPI3, pins: (SCK, MISO, MOSI), mode: Mode, apb2: &mut <SPI3 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI3>, MISO: MisoPin<SPI3>, MOSI: MosiPin<SPI3>,

Source

pub fn clear_overrun(&mut self)

Source

pub fn reclock(&mut self, freq: Hertz, clocks: Clocks)

Change the baud rate of the SPI

Source

pub fn free(self) -> (SPI3, (SCK, MISO, MOSI))

Releases the SPI peripheral and associated pins

Source§

impl<SCK, MISO, MOSI> Spi<SPI2, (SCK, MISO, MOSI)>

Source

pub fn spi2( spi: SPI2, pins: (SCK, MISO, MOSI), mode: Mode, freq: Hertz, clocks: Clocks, apb2: &mut <SPI2 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI2>, MISO: MisoPin<SPI2>, MOSI: MosiPin<SPI2>,

Configures the SPI peripheral to operate in full duplex master mode

Source

pub fn spi2_slave( spi: SPI2, pins: (SCK, MISO, MOSI), mode: Mode, apb2: &mut <SPI2 as RccBus>::Bus, ) -> Self
where SCK: SckPin<SPI2>, MISO: MisoPin<SPI2>, MOSI: MosiPin<SPI2>,

Source

pub fn clear_overrun(&mut self)

Source

pub fn reclock(&mut self, freq: Hertz, clocks: Clocks)

Change the baud rate of the SPI

Source

pub fn free(self) -> (SPI2, (SCK, MISO, MOSI))

Releases the SPI peripheral and associated pins

Source§

impl<PINS> Spi<SPI1, PINS>

Source

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

Source

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

Source

pub fn with_rxtx_dma( self, rx_channel: C2, tx_channel: C3, ) -> SpiRxTxDma<SPI1, PINS, C2, C3>

Source§

impl<PINS> Spi<SPI3, PINS>

Source

pub fn with_rx_dma(self, channel: C1) -> SpiRxDma<SPI3, PINS, C1>

Source

pub fn with_tx_dma(self, channel: C2) -> SpiTxDma<SPI3, PINS, C2>

Source

pub fn with_rxtx_dma( self, rx_channel: C1, tx_channel: C2, ) -> SpiRxTxDma<SPI3, PINS, C1, C2>

Trait Implementations§

Source§

impl<PINS> FullDuplex<u8> for Spi<SPI1, PINS>

Source§

type Error = Error

An enumeration of SPI errors
Source§

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

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

fn send(&mut self, byte: u8) -> Result<(), Error>

Sends a word to the slave
Source§

impl<PINS> FullDuplex<u8> for Spi<SPI2, PINS>

Source§

type Error = Error

An enumeration of SPI errors
Source§

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

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

fn send(&mut self, byte: u8) -> Result<(), Error>

Sends a word to the slave
Source§

impl<PINS> FullDuplex<u8> for Spi<SPI3, PINS>

Source§

type Error = Error

An enumeration of SPI errors
Source§

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

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

fn send(&mut self, byte: u8) -> Result<(), Error>

Sends a word to the slave
Source§

impl<PINS> Default<u8> for Spi<SPI1, PINS>

Source§

impl<PINS> Default<u8> for Spi<SPI1, PINS>

Source§

impl<PINS> Default<u8> for Spi<SPI2, PINS>

Source§

impl<PINS> Default<u8> for Spi<SPI2, PINS>

Source§

impl<PINS> Default<u8> for Spi<SPI3, PINS>

Source§

impl<PINS> Default<u8> for Spi<SPI3, PINS>

Auto Trait Implementations§

§

impl<SPI, PINS> Freeze for Spi<SPI, PINS>
where SPI: Freeze, PINS: Freeze,

§

impl<SPI, PINS> RefUnwindSafe for Spi<SPI, PINS>
where SPI: RefUnwindSafe, PINS: RefUnwindSafe,

§

impl<SPI, PINS> Send for Spi<SPI, PINS>
where SPI: Send, PINS: Send,

§

impl<SPI, PINS> Sync for Spi<SPI, PINS>
where SPI: Sync, PINS: Sync,

§

impl<SPI, PINS> Unpin for Spi<SPI, PINS>
where SPI: Unpin, PINS: Unpin,

§

impl<SPI, PINS> UnwindSafe for Spi<SPI, PINS>
where SPI: UnwindSafe, PINS: 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
Source§

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

Source§

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

Error type
Source§

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

Sends words to the slave, ignoring all the incoming words