Type Alias atmega_hal::spi::Spi

source ·
pub type Spi = Spi<Atmega, SPI, PB5, PB3, PB4, PB2>;

Aliased Type§

struct Spi { /* private fields */ }

Implementations

source§

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,

source

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

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.

source

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 ) -> (Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>, ChipSelectPin<CSPIN>)

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.

source

pub fn reconfigure( &mut self, settings: Settings ) -> Result<(), Error<Infallible>>

Reconfigure the SPI peripheral after initializing

source

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

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

Trait Implementations

source§

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> ErrorType for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>
where SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>, SCLKPIN: PinOps, MOSIPIN: PinOps, MISOPIN: PinOps, CSPIN: PinOps,

§

type Error = Infallible

Error type.
source§

impl<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> SpiBus for Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>
where SPI: SpiOps<H, SCLKPIN, MOSIPIN, MISOPIN, CSPIN>, SCLKPIN: PinOps, MOSIPIN: PinOps, MISOPIN: PinOps, CSPIN: PinOps,

source§

fn flush( &mut self ) -> Result<(), <Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as ErrorType>::Error>

Wait until all operations have completed and the bus is idle. Read more
source§

fn read( &mut self, read: &mut [u8] ) -> Result<(), <Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as ErrorType>::Error>

Read words from the slave. Read more
source§

fn write( &mut self, write: &[u8] ) -> Result<(), <Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as ErrorType>::Error>

Write words to the slave, ignoring all the incoming words. Read more
source§

fn transfer( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), <Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as ErrorType>::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
source§

fn transfer_in_place( &mut self, buffer: &mut [u8] ) -> Result<(), <Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as ErrorType>::Error>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
source§

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,

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.

source§

fn send( &mut self, byte: u8 ) -> Result<(), Error<<Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as FullDuplex<u8>>::Error>>

Sets up the device for transmission and sends the data

source§

fn read( &mut self ) -> Result<u8, Error<<Spi<H, SPI, SCLKPIN, MOSIPIN, MISOPIN, CSPIN> as FullDuplex<u8>>::Error>>

Reads and returns the response in the data register

§

type Error = Infallible

An enumeration of SPI errors
source§

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,

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

source§

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,

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