Spi

Struct Spi 

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

Spi Peripheral Interface

Implementations§

Source§

impl Spi<SPI0, Disabled, DefaultPins>

Source

pub fn into_alt_pins(self) -> Spi<SPI0, Disabled, AltPins>

Change to alternate pins

Source

pub fn enable_as_controller<T2, T3, T4, T5>( self, clock: PTB2<T2>, sdo: PTB3<T3>, sdi: PTB4<T4>, cs: Option<PTB5<T5>>, manage_cs: bool, mode: Mode, ) -> Spi<SPI0, Controller, DefaultPins>

Enable SPI0 with default pins

Source

pub fn enable_as_peripheral<T2, T3, T4, T5>( self, clock: PTB2<T2>, sdi: PTB3<T3>, sdo: PTB4<T4>, cs: PTB5<T5>, mode: Mode, ) -> Spi<SPI0, Enabled<Peripheral>, DefaultPins>

Enable SPI0 in peripheral mode with Alternate Pins

Source§

impl Spi<SPI0, Disabled, AltPins>

Source

pub fn enable_as_controller<T0, T1, T2, T3>( self, clock: PTE0<T0>, sdo: PTE1<T1>, sdi: PTE2<T2>, cs: Option<PTE3<T3>>, manage_cs: bool, mode: Mode, ) -> Spi<SPI0, Controller, AltPins>

Enable SPI0 in controller mode with Alternate Pins

Source

pub fn enable_as_peripheral<T0, T1, T2, T3>( self, clock: PTE0<T0>, sdi: PTE1<T1>, sdo: PTE2<T2>, cs: PTE3<T3>, mode: Mode, ) -> Spi<SPI0, Enabled<Peripheral>, AltPins>

Enable SPI0 in peripheral mode with Alternate Pins

Source§

impl Spi<SPI1, Disabled, DefaultPins>

Source

pub fn enable_as_controller<T0, T1, T2, T3>( self, clock: PTD0<T0>, sdo: PTD1<T1>, sdi: PTD2<T2>, cs: Option<PTD3<T3>>, manage_cs: bool, mode: Mode, ) -> Spi<SPI1, Enabled<Controller>, DefaultPins>

Enable SPI1 as the controller with default pins

When manage_cs is set (and the cs pin has been provided) SPI1 will automatically drive the CS pin when doing SPI transfers. If manage_cs is not set, then this pin is used to detect if there is another Controller on the bus, which throws the Master Mode Fault flag

Source

pub fn enable_as_peripheral<T0, T1, T2, T3>( self, clock: PTD0<T0>, sdi: PTD1<T1>, sdo: PTD2<T2>, cs: PTD3<T3>, mode: Mode, ) -> Spi<SPI1, Enabled<Peripheral>, DefaultPins>

Enable SPI1 as peripheral with default pins

Source§

impl<Pins, Mode> Spi<SPI0, Enabled<Mode>, Pins>

Source

pub fn set_baudrate(&self, baudrate: Hertz, bus_freq: Hertz)

Set the baud rate of transmission

This is only used when the MCU is the bus Controller. This relies on accurately inputting the bus frequency until a way to share the current bus frequency is worked out.

Source

pub fn set_baudrate_divisor(&self, divisor: &BaudrateDivisor)

Set the baud rate by directly setting the divisor

Source

pub fn baudrate_divisor(&self) -> BaudrateDivisor

Get the current baudrate divisor

Source

pub fn mode_fault(&self) -> bool

Check if mode fault occured

Source§

impl<Mode, Pins> Spi<SPI0, Mode, Pins>

Source

pub fn read_ready(&self) -> bool

Check if read buffer full (ready to read)

Source

pub fn read_matches(&self) -> bool

Check if read matches value in match register

Source

pub fn send_ready(&self) -> bool

Check if transmit buffer empty (ready to send)

Source

pub fn set_hw_match(&self, value: u8)

Set the value for hardware read match

Source§

impl<Pins, Mode> Spi<SPI1, Enabled<Mode>, Pins>

Source

pub fn set_baudrate(&self, baudrate: Hertz, bus_freq: Hertz)

Set the baud rate of transmission

This is only used when the MCU is the bus Controller. This relies on accurately inputting the bus frequency until a way to share the current bus frequency is worked out.

Source

pub fn set_baudrate_divisor(&self, divisor: &BaudrateDivisor)

Set the baud rate by directly setting the divisor

Source

pub fn baudrate_divisor(&self) -> BaudrateDivisor

Get the current baudrate divisor

Source

pub fn mode_fault(&self) -> bool

Check if mode fault occured

Source§

impl<Mode, Pins> Spi<SPI1, Mode, Pins>

Source

pub fn read_ready(&self) -> bool

Check if read buffer full (ready to read)

Source

pub fn read_matches(&self) -> bool

Check if read matches value in match register

Source

pub fn send_ready(&self) -> bool

Check if transmit buffer empty (ready to send)

Source

pub fn set_hw_match(&self, value: u8)

Set the value for hardware read match

Trait Implementations§

Source§

impl<Pins, Mode> FullDuplex<u8> for Spi<SPI0, Enabled<Mode>, Pins>

Source§

type Error = Infallible

An enumeration of SPI errors
Source§

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

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

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

Sends a word to the slave
Source§

impl<Pins, Mode> FullDuplex<u8> for Spi<SPI1, Enabled<Mode>, Pins>

Source§

type Error = Infallible

An enumeration of SPI errors
Source§

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

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

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

Sends a word to the slave

Auto Trait Implementations§

§

impl<SPI, Disabled, Pins> Freeze for Spi<SPI, Disabled, Pins>
where SPI: Freeze,

§

impl<SPI, Disabled, Pins> RefUnwindSafe for Spi<SPI, Disabled, Pins>
where SPI: RefUnwindSafe, Disabled: RefUnwindSafe, Pins: RefUnwindSafe,

§

impl<SPI, Disabled, Pins> Send for Spi<SPI, Disabled, Pins>
where SPI: Send, Disabled: Send, Pins: Send,

§

impl<SPI, Disabled, Pins> Sync for Spi<SPI, Disabled, Pins>
where SPI: Sync, Disabled: Sync, Pins: Sync,

§

impl<SPI, Disabled, Pins> Unpin for Spi<SPI, Disabled, Pins>
where SPI: Unpin, Disabled: Unpin, Pins: Unpin,

§

impl<SPI, Disabled, Pins> UnwindSafe for Spi<SPI, Disabled, Pins>
where SPI: UnwindSafe, Disabled: 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.