[][src]Struct esp32_hal::spi::SPI

pub struct SPI<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin = Gpio1<Input<Floating>>, CS: OutputPin = Gpio2<Output<PushPull>>> { /* fields omitted */ }

SPI abstraction

Implementations

impl<CS: OutputPin> SPI<SPI1, Gpio6<Output<PushPull>>, Gpio7<Output<PushPull>>, Gpio8<Input<Floating>>, CS>[src]

pub fn new(
    instance: SPI1,
    pins: Pins<Gpio6<Output<PushPull>>, Gpio7<Output<PushPull>>, Gpio8<Input<Floating>>, CS>,
    config: Config,
    clock_control: ClockControlConfig
) -> Result<Self, Error>
[src]

Create new instance of SPI controller for SPI1

SPI1 can only use fixed pin for SCLK, SDO and SDI as they are shared with SPI0.

impl<SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> SPI<SPI2, SCLK, SDO, SDI, CS>[src]

pub fn new(
    instance: SPI2,
    pins: Pins<SCLK, SDO, SDI, CS>,
    config: Config,
    clock_control: ClockControlConfig
) -> Result<Self, Error>
[src]

Create new instance of SPI controller for SPI2

impl<SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> SPI<SPI3, SCLK, SDO, SDI, CS>[src]

pub fn new(
    instance: SPI3,
    pins: Pins<SCLK, SDO, SDI, CS>,
    config: Config,
    clock_control: ClockControlConfig
) -> Result<Self, Error>
[src]

Create new instance of SPI controller for SPI3

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

pub fn change_baudrate<T: Into<Hertz> + Copy>(
    &mut self,
    baudrate: T
) -> Result<&mut Self, Error>
[src]

Change the SPI baudrate

pub fn baudrate(&self) -> Hertz[src]

Returns the current baudrate

pub fn change_bit_order(&mut self, data_mode: BitOrder) -> &mut Self[src]

Change the bit order

pub fn change_data_mode(&mut self, data_mode: Mode) -> &mut Self[src]

Change the data mode

pub fn release(self) -> INSTANCE[src]

Release and return the raw interface to the underlying SPI peripheral

Trait Implementations

impl<T: U8orU16orU32, INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> FullDuplex<T> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

Full-duplex implementation for writing/reading via SPI

Note: these functions do not lock the frequency of the APB bus, so transactions may be at lower frequency if APB bus is not locked in caller.

type Error = Error

An enumeration of SPI errors

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Transfer<u16> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Transfer<u32> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Transfer<u8> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Write<u16> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Write<u32> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> Write<u8> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> WriteIter<u16> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> WriteIter<u32> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

impl<INSTANCE: Instance, SCLK: OutputPin, SDO: OutputPin, SDI: InputPin + OutputPin, CS: OutputPin> WriteIter<u8> for SPI<INSTANCE, SCLK, SDO, SDI, CS>[src]

type Error = Error

Error type

Auto Trait Implementations

impl<INSTANCE, SCLK, SDO, SDI, CS> Send for SPI<INSTANCE, SCLK, SDO, SDI, CS> where
    CS: Send,
    INSTANCE: Send,
    SCLK: Send,
    SDI: Send,
    SDO: Send

impl<INSTANCE, SCLK, SDO, SDI, CS> Sync for SPI<INSTANCE, SCLK, SDO, SDI, CS> where
    CS: Sync,
    INSTANCE: Sync,
    SCLK: Sync,
    SDI: Sync,
    SDO: Sync

impl<INSTANCE, SCLK, SDO, SDI, CS> Unpin for SPI<INSTANCE, SCLK, SDO, SDI, CS> where
    CS: Unpin,
    INSTANCE: Unpin,
    SCLK: Unpin,
    SDI: Unpin,
    SDO: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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

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

Error type

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

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

Error type

impl<W, S> WriteIter<W> for S where
    S: Default<W>,
    W: Clone
[src]

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

Error type