Struct SpiDriver

Source
pub struct SpiDriver<'a> {
    regs: *mut RegisterBlock,
    _callback: Option<Box<dyn FnMut(Event) + 'a>>,
    config: Config,
    data_count: u32,
}
Expand description

A polling-based SPI driver for STM32F407.

Fields§

§regs: *mut RegisterBlock§_callback: Option<Box<dyn FnMut(Event) + 'a>>§config: Config§data_count: u32

Implementations§

Source§

impl<'a> SpiDriver<'a>

Source

pub fn new(spi_base_addr: u32, config: Config) -> Self

Source

pub fn new_spi1(config: Config) -> Self

Create a new SPI1 driver instance (APB2 clock)

Source

pub fn new_spi2(config: Config) -> Self

Create a new SPI2 driver instance (APB1 clock)

Source

pub fn new_spi3(config: Config) -> Self

Create a new SPI3 driver instance (APB1 clock)

Source

fn regs(&self) -> &mut RegisterBlock

Source

fn is_on_apb2(&self) -> bool

Source

fn get_flag_status(&self, flag_bit: u32) -> bool

Source

fn wait_txe(&self)

Source

fn wait_rxne(&self)

Source

fn wait_not_busy(&self)

Source

fn clear_ovr_flag(&mut self)

Source

fn configure_cr1(&mut self) -> u32

Source

fn configure_cr2(&mut self) -> u32

Trait Implementations§

Source§

impl<'a> Spi<'a> for SpiDriver<'a>

Source§

fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>

Initializes the SPI peripheral.
Source§

fn uninitialize(&mut self) -> Result<(), i32>

De-initializes the SPI peripheral.
Source§

fn configure(&mut self, config: &Config) -> Result<(), i32>

Configures the SPI peripheral.
Source§

fn send(&mut self, data: &[u8]) -> Result<(), i32>

Transmits data over the SPI bus.
Source§

fn receive(&mut self, data: &mut [u8]) -> Result<(), i32>

Receives data from the SPI bus.
Source§

fn transfer(&mut self, data_out: &[u8], data_in: &mut [u8]) -> Result<(), i32>

Simultaneously sends and receives data.
Source§

fn get_data_count(&self) -> u32

Gets the number of bytes transferred in the last transaction.
Source§

fn get_status(&self) -> Status

Gets the current status of the SPI peripheral.
Source§

fn control_slave_select(&mut self, active: bool) -> Result<(), i32>

Controls the slave select line in software-controlled modes.

Auto Trait Implementations§

§

impl<'a> Freeze for SpiDriver<'a>

§

impl<'a> !RefUnwindSafe for SpiDriver<'a>

§

impl<'a> !Send for SpiDriver<'a>

§

impl<'a> !Sync for SpiDriver<'a>

§

impl<'a> Unpin for SpiDriver<'a>

§

impl<'a> !UnwindSafe for SpiDriver<'a>

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.