Struct grand_central_m4::sercom::v2::spi::Config [−][src]
pub struct Config<P, M = Master, L = UInt<UTerm, B1>> where
P: ValidPads,
M: OpMode,
L: Length, { /* 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 transaction
Length
. Upon creation, the Config
takes ownership of the Sercom
and resets it, returning it configured as an SPI peripheral in Master
OpMode
with Length
U1
.
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 Length
U1
. 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 transaction Length
To use a run-time dynamic length, set the Length
type to
DynLength
and then use the get_dyn_length
and set_dyn_length
methods.
Change the SPI mode (clock polarity & phase)
Change the bit order of transmission (MSB/LSB first)
This only affects the order of bits within each byte. Bytes are always transferred in little endian order from the 32-bit DATA register.
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.
Return the current transaction length
Read the LENGTH register to determine the current transaction length
Set the transaction length
Write the LENGTH register to set the transaction length. Panics if the length is zero.