[][src]Struct avr_hal_generic::spi::Spi

pub struct Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> { /* fields omitted */ }

Behavior for a SPI interface.

Stores the SPI peripheral for register access. In addition, it takes ownership of the MOSI and MISO pins to ensure they are in the correct mode. Instantiate with the new method.

Implementations

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>,
    SCLKPIN: PinOps,
    MOSIPIN: PinOps,
    MISOPIN: PinOps,
    CSPIN: PinOps
[src]

pub fn new(
    p: SPI,
    sclk: Pin<Output, SCLKPIN>,
    mosi: Pin<Output, MOSIPIN>,
    miso: Pin<Input<PullUp>, MISOPIN>,
    cs: Pin<Output, CSPIN>,
    settings: Settings
) -> (Self, ChipSelectPin<CSPIN>)
[src]

Instantiate an SPI with the registers, SCLK/MOSI/MISO/CS pins, and settings, with the internal pull-up enabled on the MISO pin.

The pins are not actually used directly, but they are moved into the struct in order to enforce that they are in the correct mode, and cannot be used by anyone else while SPI is active. CS is placed into a ChipSelectPin instance and given back so that its output state can be changed as needed.

pub fn with_external_pullup(
    p: SPI,
    sclk: Pin<Output, SCLKPIN>,
    mosi: Pin<Output, MOSIPIN>,
    miso: Pin<Input<Floating>, MISOPIN>,
    cs: Pin<Output, CSPIN>,
    settings: Settings
) -> (Self, ChipSelectPin<CSPIN>)
[src]

Instantiate an SPI with the registers, SCLK/MOSI/MISO/CS pins, and settings, with an external pull-up on the MISO pin.

The pins are not actually used directly, but they are moved into the struct in order to enforce that they are in the correct mode, and cannot be used by anyone else while SPI is active.

pub fn reconfigure(&mut self, settings: Settings) -> Result<(), Void>[src]

Reconfigure the SPI peripheral after initializing

pub fn release(
    self,
    cs: ChipSelectPin<CSPIN>
) -> (SPI, Pin<Output, SCLKPIN>, Pin<Output, MOSIPIN>, Pin<Input, MISOPIN>, Pin<Output, CSPIN>)
[src]

Disable the SPI device and release ownership of the peripheral and pins. Instance can no-longer be used after this is invoked.

Trait Implementations

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Default<u8> for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>,
    SCLKPIN: PinOps,
    MOSIPIN: PinOps,
    MISOPIN: PinOps,
    CSPIN: PinOps
[src]

Default Transfer trait implementation. Only 8-bit word size is supported for now.

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Default<u8> for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>,
    SCLKPIN: PinOps,
    MOSIPIN: PinOps,
    MISOPIN: PinOps,
    CSPIN: PinOps
[src]

Default Write trait implementation. Only 8-bit word size is supported for now.

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> FullDuplex<u8> for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>,
    SCLKPIN: PinOps,
    MOSIPIN: PinOps,
    MISOPIN: PinOps,
    CSPIN: PinOps
[src]

FullDuplex trait implementation, allowing this struct to be provided to drivers that require it for operation. Only 8-bit word size is supported for now.

type Error = Void

An enumeration of SPI errors

pub fn send(&mut self, byte: u8) -> Result<(), Self::Error>[src]

Sets up the device for transmission and sends the data

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

Reads and returns the response in the data register

Auto Trait Implementations

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Send for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    CSPIN: Send,
    H: Send,
    MISOPIN: Send,
    MOSIPIN: Send,
    SCLKPIN: Send,
    SPI: Send
[src]

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Sync for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    CSPIN: Sync,
    H: Sync,
    MISOPIN: Sync,
    MOSIPIN: Sync,
    SCLKPIN: Sync,
    SPI: Sync
[src]

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> Unpin for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> where
    CSPIN: Unpin,
    H: Unpin,
    MISOPIN: Unpin,
    MOSIPIN: Unpin,
    SCLKPIN: Unpin,
    SPI: Unpin
[src]

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
    W: Clone,
    S: Default<W>, 
[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
    W: Clone,
    S: Default<W>, 
[src]

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

Error type