Struct itsybitsy_m4::spi::Spi

source ·
pub struct Spi<C, A>
where C: ValidConfig, A: Capability,
{ /* private fields */ }
Expand description

An enabled SPI peripheral that can perform transactions

See the impl_ehal documentation for details on the implementations of the embedded HAL traits, which vary based on Size and Capability.

Implementations§

source§

impl<C, A> Spi<C, A>
where C: ValidConfig, A: Capability,

source

pub fn length<L>( self ) -> Spi<Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, L>, A>
where L: Length, Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, L>: ValidConfig,

Change the transaction Length

Changing the transaction Length while is enabled is permissible but dangerous. If you have sent or received any bytes at the current Length, you must wait for a TXC flag before changing to a new Length.

source

pub fn reconfigure( &mut self, update: impl FnOnce(&mut Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, <C as AnyConfig>::Size>) )

Update the SPI configuration.

Calling this method will temporarily disable the SERCOM peripheral, as some registers are enable-protected. This may interrupt any ongoing transactions.

source

pub fn enable_interrupts(&mut self, flags: Flags)

Enable interrupts for the specified flags

source

pub fn disable_interrupts(&mut self, flags: Flags)

Disable interrupts for the specified flags

source

pub fn read_flags(&self) -> Flags

Read the interrupt flags

source

pub fn clear_flags(&mut self, flags: Flags)

Clear the corresponding interrupt flags

Only the ERROR, SSL and TXC flags can be cleared.

Note: The implementation of of serial::Write::flush waits on and clears the TXC flag. Manually clearing this flag could cause it to hang indefinitely.

source

pub fn read_status(&self) -> Status

Read the error status flags

source

pub fn clear_status(&mut self, status: Status)

Clear the corresponding error status flags

source

pub fn read_flags_errors(&self) -> Result<Flags, Error>

Try to read the interrupt flags, but first check the error status flags.

source

pub unsafe fn read_data(&mut self) -> u32

Read from the DATA register

Reading from the data register directly is unsafe, because it will clear the RXC flag, which could break assumptions made elsewhere in this module.

source

pub unsafe fn write_data(&mut self, data: u32)

Write to the DATA register

Writing to the data register directly is unsafe, because it will clear the DRE flag, which could break assumptions made elsewhere in this module.

source

pub fn disable(self) -> C

Disable the SPI peripheral and return the Config struct

source§

impl<P, M, A> Spi<Config<P, M, UTerm>, A>
where P: ValidPads, M: OpMode, Config<P, M, UTerm>: ValidConfig, A: Capability,

source

pub fn get_dyn_length(&self) -> u8

Return the current transaction length

Read the LENGTH register to determine the current transaction length

source

pub fn set_dyn_length(&mut self, length: u8)

Set the transaction length

Write the LENGTH register to set the transaction length. Panics if the length is zero.

Changing the transaction LENGTH while is enabled is permissible but dangerous. If you have sent or received any bytes at the current LENGTH, you must wait for a TXC flag before changing to a new LENGTH.

Trait Implementations§

source§

impl<C, A> AnySpi for Spi<C, A>
where C: ValidConfig, A: Capability,

§

type Sercom = <C as AnyConfig>::Sercom

§

type Pads = <C as AnyConfig>::Pads

§

type Capability = A

§

type OpMode = <C as AnyConfig>::OpMode

§

type Size = <C as AnyConfig>::Size

§

type Word = <C as AnyConfig>::Word

§

type Config = C

source§

impl<C, A> AsMut<Spi<C, A>> for Spi<C, A>
where C: ValidConfig, A: Capability,

source§

fn as_mut(&mut self) -> &mut Spi<C, A>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<C, A> AsRef<Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, <C as AnyConfig>::Size>> for Spi<C, A>
where C: ValidConfig, A: Capability,

Get a shared reference to the underlying Config struct

This can be used to call the various get_* functions on Config

source§

fn as_ref( &self ) -> &Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, <C as AnyConfig>::Size>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<C, A> AsRef<Spi<C, A>> for Spi<C, A>
where C: ValidConfig, A: Capability,

source§

fn as_ref(&self) -> &Spi<C, A>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<P, M, L, A> CheckBufLen for Spi<Config<P, M, L>, A>
where Config<P, M, L>: ValidConfig, P: ValidPads, M: OpMode, L: StaticLength, A: Capability,

source§

const LEN: usize = <Self::Size as Unsigned>::USIZE

Spi transaction length Read more
source§

fn len(&self) -> usize

Return the Spi transaction length Read more
source§

const STEP: usize = _

Step size through the SpiFuture buffer Read more
source§

fn step(&self) -> usize

Return the step size through the SpiFuture buffer Read more
source§

fn check_buf_len(&self, buf: &impl AsRef<[u8]>)

Check that the buffer has a valid length Read more
source§

impl<P, M, A> CheckBufLen for Spi<Config<P, M, UTerm>, A>
where Config<P, M, UTerm>: ValidConfig, P: ValidPads, M: OpMode, A: Capability,

source§

fn len(&self) -> usize

Return the Spi transaction length Read more
source§

fn step(&self) -> usize

Return the step size through the SpiFuture buffer Read more
source§

const LEN: usize = <Self::Size as Unsigned>::USIZE

Spi transaction length Read more
source§

const STEP: usize = _

Step size through the SpiFuture buffer Read more
source§

fn check_buf_len(&self, buf: &impl AsRef<[u8]>)

Check that the buffer has a valid length Read more
source§

impl<P, M> WriteIter<<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Duplex>
where Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Tx>
where Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UInt<UTerm, B1>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B0>>, Duplex>
where Config<P, M, UInt<UInt<UTerm, B1>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UTerm, B1>, B0> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UInt<UTerm, B1>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B0>>, Tx>
where Config<P, M, UInt<UInt<UTerm, B1>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UTerm, B1>, B0> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UInt<UTerm, B1>, B1> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B1>>, Duplex>
where Config<P, M, UInt<UInt<UTerm, B1>, B1>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UTerm, B1>, B1> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UInt<UTerm, B1>, B1> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B1>>, Tx>
where Config<P, M, UInt<UInt<UTerm, B1>, B1>>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UInt<UTerm, B1>, B1> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UTerm, B1> as Length>::Word> for Spi<Config<P, M>, Duplex>
where Config<P, M>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UTerm, B1> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> WriteIter<<UInt<UTerm, B1> as Length>::Word> for Spi<Config<P, M>, Tx>
where Config<P, M>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = <UInt<UTerm, B1> as Length>::Word>,

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M, A> Transfer<<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, A>
where Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive and have an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn transfer<'w>( &mut self, words: &'w mut [<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word] ) -> Result<&'w [<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M, A> Transfer<<UInt<UInt<UTerm, B1>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B0>>, A>
where Config<P, M, UInt<UInt<UTerm, B1>, B0>>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive and have an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn transfer<'w>( &mut self, words: &'w mut [<UInt<UInt<UTerm, B1>, B0> as Length>::Word] ) -> Result<&'w [<UInt<UInt<UTerm, B1>, B0> as Length>::Word], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M, A> Transfer<<UInt<UInt<UTerm, B1>, B1> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B1>>, A>
where Config<P, M, UInt<UInt<UTerm, B1>, B1>>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive and have an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn transfer<'w>( &mut self, words: &'w mut [<UInt<UInt<UTerm, B1>, B1> as Length>::Word] ) -> Result<&'w [<UInt<UInt<UTerm, B1>, B1> as Length>::Word], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M, A> Transfer<<UInt<UTerm, B1> as Length>::Word> for Spi<Config<P, M>, A>
where Config<P, M>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive and have an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn transfer<'w>( &mut self, words: &'w mut [<UInt<UTerm, B1> as Length>::Word] ) -> Result<&'w [<UInt<UTerm, B1> as Length>::Word], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M, L, A> Transfer<u8> for Spi<Config<P, M, L>, A>
where Config<P, M, L>: ValidConfig, P: ValidPads, M: OpMode, L: GreaterThan4, A: Receive,

Implement Transfer for Spi structs that can Receive and have long transaction Lengths

The transaction Length must be > 4. The transfer accepts a slice of u8 with a length equal to the transaction Length. If the slice length is incorrect, it will panic.

§

type Error = Error

Error type
source§

fn transfer<'w>(&mut self, buf: &'w mut [u8]) -> Result<&'w [u8], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M, A> Transfer<u8> for Spi<Config<P, M, UTerm>, A>
where Config<P, M, UTerm>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive and have DynLength

The transfer accepts a slice of u8 with a length equal to the run-time dynamic transaction length. If the slice length does not match the result of Spi::get_dyn_length, it will panic.

§

type Error = Error

Error type
source§

fn transfer<'w>(&mut self, buf: &'w mut [u8]) -> Result<&'w [u8], Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<P, M> Write<<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Duplex>
where Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Tx>
where Config<P, M, UInt<UInt<UInt<UTerm, B1>, B0>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UInt<UTerm, B1>, B0>, B0> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UInt<UTerm, B1>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B0>>, Duplex>
where Config<P, M, UInt<UInt<UTerm, B1>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UTerm, B1>, B0> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UInt<UTerm, B1>, B0> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B0>>, Tx>
where Config<P, M, UInt<UInt<UTerm, B1>, B0>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UTerm, B1>, B0> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UInt<UTerm, B1>, B1> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B1>>, Duplex>
where Config<P, M, UInt<UInt<UTerm, B1>, B1>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UTerm, B1>, B1> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UInt<UTerm, B1>, B1> as Length>::Word> for Spi<Config<P, M, UInt<UInt<UTerm, B1>, B1>>, Tx>
where Config<P, M, UInt<UInt<UTerm, B1>, B1>>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UInt<UTerm, B1>, B1> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UTerm, B1> as Length>::Word> for Spi<Config<P, M>, Duplex>
where Config<P, M>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UTerm, B1> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<<UInt<UTerm, B1> as Length>::Word> for Spi<Config<P, M>, Tx>
where Config<P, M>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability and an AtomicSize

The transaction Length must be <= 4. The transfer accepts a slice of primitive integers, depending on the Length (u8, u16 or u32).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write( &mut self, words: &[<UInt<UTerm, B1> as Length>::Word] ) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M, L> Write<u8> for Spi<Config<P, M, L>, Duplex>
where Config<P, M, L>: ValidConfig, P: ValidPads, M: OpMode, L: GreaterThan4,

Implement Write for Spi structs with Duplex Capability and long transaction Lengths

The transaction Length must be > 4. The transfer accepts a [u8] with a length equal to the transfer Length. If the slice length is incorrect, it will panic.

§

type Error = Error

Error type
source§

fn write(&mut self, buf: &[u8]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M, L> Write<u8> for Spi<Config<P, M, L>, Tx>
where Config<P, M, L>: ValidConfig, P: ValidPads, M: OpMode, L: GreaterThan4,

Implement Write for Spi structs with Tx Capability and long transaction Lengths

The transaction Length must be > 4. The transfer accepts a [u8] with a length equal to the transfer Length. If the slice length is incorrect, it will panic.

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write(&mut self, buf: &[u8]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<u8> for Spi<Config<P, M, UTerm>, Duplex>
where Config<P, M, UTerm>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability and DynLength

The transfer accepts a [u8] with a length equal to the run-time dynamic transaction length. If the slice length does not match the result of Spi::get_dyn_length, it will panic.

§

type Error = Error

Error type
source§

fn write(&mut self, buf: &[u8]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M> Write<u8> for Spi<Config<P, M, UTerm>, Tx>
where Config<P, M, UTerm>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability and DynLength

The transfer accepts a [u8] with a length equal to the run-time dynamic transaction length. If the slice length does not match the result of Spi::get_dyn_length], it will panic.

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Error type
source§

fn write(&mut self, buf: &[u8]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<P, M, L> Read<<L as Length>::Word> for Spi<Config<P, M, L>, Rx>
where Config<P, M, L>: ValidConfig, P: ValidPads, M: MasterMode, L: Length, <L as Length>::Word: PrimInt, u32: AsPrimitive<<L as Length>::Word>,

Implement serial::Read for Rx Spi structs in a MasterMode

serial::Read is only implemented for Spi structs with Rx Capability. In a MasterMode, Read has to initiate transactions, so it keeps track of the transaction state. If a transaction is in progress, it will wait on RXC. If not, it will wait on DRE, and then send 0.

§

type Error = Error

Read error
source§

fn read(&mut self) -> Result<<L as Length>::Word, Error<Error>>

Reads a single word from the serial interface
source§

impl<P, L> Read<<L as Length>::Word> for Spi<Config<P, Slave, L>, Rx>
where Config<P, Slave, L>: ValidConfig, P: ValidPads, L: Length, <L as Length>::Word: PrimInt, u32: AsPrimitive<<L as Length>::Word>,

Implement serial::Read for Rx Spi structs in Slave OpMode

serial::Read is only implemented for Spi structs with Rx Capability. In Slave OpMode, Read does not have to initiate transactions, so it does not have to store any internal state. It only has to wait on RXC.

§

type Error = Error

Read error
source§

fn read(&mut self) -> Result<<L as Length>::Word, Error<Error>>

Reads a single word from the serial interface
source§

impl<C> Write<<C as AnyConfig>::Word> for Spi<C, Tx>

Implement serial::Write for Tx Spi structs

serial::Write is only implemented for Spi structs with Tx Capability. Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

§

type Error = Error

Write error
source§

fn write(&mut self, word: <C as AnyConfig>::Word) -> Result<(), Error<Error>>

Writes a single word to the serial interface
source§

fn flush(&mut self) -> Result<(), Error<Error>>

Ensures that none of the previously written words are still buffered
source§

impl<C> FullDuplex<<C as AnyConfig>::Word> for Spi<C, Duplex>

Implement spi::FullDuplex for Spi structs with AtomicSize

spi::FullDuplex is only implemented when the Spi struct has Duplex Capability and the transaction Length is <= 4 bytes. When the Length is <= 4, the Word is a primitive integer, with a size that depends on the Length (u8, u16 or u32).

§

type Error = Error

An enumeration of SPI errors
source§

fn read(&mut self) -> Result<<C as AnyConfig>::Word, Error<Error>>

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

fn send(&mut self, word: <C as AnyConfig>::Word) -> Result<(), Error<Error>>

Sends a word to the slave
source§

impl<C> Default<<C as AnyConfig>::Word> for Spi<C, Tx>
where C: ValidConfig, Spi<C, Tx>: Write<<C as AnyConfig>::Word>,

Auto Trait Implementations§

§

impl<C, A> Freeze for Spi<C, A>
where C: Freeze, A: Freeze,

§

impl<C, A> RefUnwindSafe for Spi<C, A>

§

impl<C, A> Send for Spi<C, A>
where C: Send, A: Send,

§

impl<C, A> Sync for Spi<C, A>
where C: Sync, A: Sync,

§

impl<C, A> Unpin for Spi<C, A>
where C: Unpin, A: Unpin,

§

impl<C, A> UnwindSafe for Spi<C, A>
where C: UnwindSafe, A: 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> Is for T
where T: Sealed + AsRef<T> + AsMut<T>,

§

type Type = T

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<S, Word> Write<Word> for S
where S: Default<Word>, Word: Clone,

§

type Error = <S as Write<Word>>::Error

The type of error that can occur when writing
source§

fn bwrite_all( &mut self, buffer: &[Word] ) -> Result<(), <S as Write<Word>>::Error>

Writes a slice, blocking until everything has been written Read more
source§

fn bflush(&mut self) -> Result<(), <S as Write<Word>>::Error>

Block until the serial interface has sent all buffered words