Struct serpente::sercom::v2::spi::Config [−][src]
pub struct Config<P, M = Master, C = EightBit> where
C: CharSize,
P: ValidPads,
M: OpMode, { /* fields omitted */ }
Expand description
A configurable, disabled SPI peripheral
This struct
represents a configurable SPI peripheral in its disabled
state. It is generic over the set of Pads
, OpMode
and
CharSize
. Upon creation, the Config
takes ownership of the
Sercom
and resets it, returning it configured as an SPI peripheral in
Master
OpMode
with an EightBit
CharSize
.
Config
uses a builder-pattern API to configure the peripheral,
culminating in a call to enable
, which consumes the Config
and
returns an enabled Spi
peripheral. The enable
function is restricted
to ValidConfig
s.
Implementations
Create a new Config
in the default configuration
This function will enable the corresponding APB clock, reset the
Sercom
peripheral, and return a Config
in the default
configuration, Master
OpMode
with an EightBit
CharSize
.
Config
takes ownership of the Sercom
and Pads
.
Users must configure GCLK manually. The freq
parameter represents the
GCLK frequency for this Sercom
instance.
Obtain a reference to the PAC SERCOM
struct
Directly accessing the SERCOM
could break the invariants of the
type-level tracking in this module, so it is unsafe.
Change the SPI mode (clock polarity & phase)
Change the bit order of transmission (MSB/LSB first)
Set the baud rate
This function will calculate the best BAUD register setting based on the stored GCLK frequency and desired baud rate. The maximum baud rate is half the GCLK frequency. The minimum baud rate is the GCLK frequency / 512. Values outside this range will saturate at the extremes.
Control the buffer overflow notification
If set to true, an Error::Overflow
will be issued as soon as an
overflow occurs. Otherwise, it will not be issued until its place within
the data stream.
Run in standby mode
When set, the SPI peripheral will run in standby mode. See the datasheet for more details.
Enable interrupts for the specified flags
Disable interrupts for the specified flags
Enable the SPI peripheral
SPI transactions are not possible until the peripheral is enabled.
This function is limited to ValidConfig
s.