pub struct Config<P, M = Master, Z = UInt<UTerm, B1>> where
P: ValidPads,
M: OpMode,
Z: Size, { /* fields omitted */ }
Expand description
A configurable SPI peripheral in its disabled state
See the module-level documentation for more details on declaring
and instantiating Pads
types.
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. The default OpMode
is Master
, while the default
Size
is an
EightBit
CharSize
for SAMD11 and SAMD21 chips or a
Length
of U1
for SAMx5x chips. Note that Config
takes ownership of both the
PAC Sercom
struct as well as the 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
using the builder pattern
To use a run-time dynamic length, set the Length
type to
DynLength
and then use the dyn_length
method.
Set the clock polarity using the builder pattern
Set the clock phase using the builder pattern
Get the SPI mode (clock polarity & phase)
Set the SPI mode (clock polarity & phase)
Set the SPI mode (clock polarity & phase) using the builder pattern
Get 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 bit order of transmission (MSB/LSB first) using the builder pattern
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 bit order of transmission (MSB/LSB first) using the builder pattern
This only affects the order of bits within each byte. Bytes are always transferred in little endian order from the 32-bit DATA register.
Get the baud rate
The returned baud rate may not exactly match what was set.
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.
Set the baud rate using the builder API
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.
Read the enabled state of the immediate 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.
Enable or disable the immediate 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.
Enable or disable the immediate buffer overflow notification using the builder API
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.
Read the enable state of run in standby mode
Enable or disable run in standby mode
Enable or disable run in standby mode using the builder API
pub fn enable(self) -> Spi<Config<P, M, Z>, <P as ValidPads>::Capability> where
Config<P, M, Z>: ValidConfig,
pub fn enable(self) -> Spi<Config<P, M, Z>, <P as ValidPads>::Capability> where
Config<P, M, Z>: ValidConfig,
Enable the SPI peripheral
SPI transactions are not possible until the peripheral is enabled.
This function is limited to ValidConfig
s.
Get the transaction length
Set the transaction length
Write the LENGTH register to set the transaction length. If the length is zero, it will be set to 1.
Set the transaction length using the builder API
Write the LENGTH register to set the transaction length. If the length is zero, it will be set to 1.
Trait Implementations
Get a shared reference to the underlying Config
struct
This can be used to call the various get_*
functions on Config
impl<P, Z> ValidConfig for Config<P, MasterHWSS, Z> where
P: ValidPads,
Z: Size,
<P as PadSet>::SS: SomePad,
Auto Trait Implementations
impl<P, M, Z> RefUnwindSafe for Config<P, M, Z> where
M: RefUnwindSafe,
P: RefUnwindSafe,
Z: RefUnwindSafe,
<P as PadSet>::Sercom: RefUnwindSafe,
impl<P, M, Z> Send for Config<P, M, Z> where
M: Send,
P: Send,
Z: Send,
<P as PadSet>::Sercom: Send,
impl<P, M, Z> Unpin for Config<P, M, Z> where
M: Unpin,
P: Unpin,
Z: Unpin,
<P as PadSet>::Sercom: Unpin,
impl<P, M, Z> UnwindSafe for Config<P, M, Z> where
M: UnwindSafe,
P: UnwindSafe,
Z: UnwindSafe,
<P as PadSet>::Sercom: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Casts the value.
OverflowingCasts the value.
Casts the value.
Casts the value.
Casts the value.
UnwrappedCasts the value.
Casts the value.
WrappingCasts the value.