Struct atsamd_hal::sercom::v2::spi::Spi [−][src]
pub struct Spi<C, A> where
C: ValidConfig,
A: Capability, { /* fields omitted */ }
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
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.
Enable interrupts for the specified flags
Disable interrupts for the specified flags
Read the interrupt 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.
Read the error status flags
Clear the corresponding error status flags
Try to read the interrupt flags, but first check the error status flags.
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.
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.
Trait Implementations
Get a shared reference to the underlying Config
struct
This can be used to call the various get_*
functions on Config
Performs the conversion.
impl<C> FullDuplex<<C as AnyConfig>::Word> for Spi<C, Duplex> where
C: ValidConfig,
C::Word: PrimInt + AsPrimitive<u16>,
u16: AsPrimitive<C::Word>,
impl<C> FullDuplex<<C as AnyConfig>::Word> for Spi<C, Duplex> where
C: ValidConfig,
C::Word: PrimInt + AsPrimitive<u16>,
u16: AsPrimitive<C::Word>,
Implement spi::FullDuplex
for Spi
structs with AtomicSize
spi::FullDuplex
is only implemented when the Spi
struct has Duplex
Capability
. The Word
size used in the implementation depends on the
corresponding CharSize
.
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
.
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
.
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.
Implement Write
for Spi
structs with Duplex
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Implement Write
for Spi
structs with Tx
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Because the Capability
is Tx
, this implementation never
reads the DATA register and ignores all buffer overflow errors.
Implement Write
for Spi
structs with Duplex
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Implement Write
for Spi
structs with Tx
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Because the Capability
is Tx
, this implementation never
reads the DATA register and ignores all buffer overflow errors.
Implement WriteIter
for Spi
structs with Duplex
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<EightBit>>,
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<EightBit>>,
Sends words
to the slave, ignoring all the incoming words
Implement WriteIter
for Spi
structs with Tx
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Because the Capability
is Tx
, this implementation never
reads the DATA register and ignores all buffer overflow errors.
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<EightBit>>,
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<EightBit>>,
Sends words
to the slave, ignoring all the incoming words
Implement WriteIter
for Spi
structs with Duplex
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<NineBit>>,
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<NineBit>>,
Sends words
to the slave, ignoring all the incoming words
Implement WriteIter
for Spi
structs with Tx
Capability
The transfer accepts a slice of primitive integers, depending on
the CharSize
(u8
or u16
).
Because the Capability
is Tx
, this implementation never
reads the DATA register and ignores all buffer overflow errors.
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<NineBit>>,
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error> where
WI: IntoIterator<Item = Word<NineBit>>,
Sends words
to the slave, ignoring all the incoming words