pub struct Config<P, M = Master, Z = DefaultSize> where
    P: ValidPads,
    M: OpMode,
    Z: Size
{ /* private fields */ }
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.

Trigger the Sercom’s SWRST and return a Config in the default configuration.

Consume the Config, reset the peripheral, and return the Sercom and Pads

Change the OpMode

Change the CharSize using the builder pattern

Get the clock polarity

Set the clock polarity

Set the clock polarity using the builder pattern

Get the clock phase

Set the clock phase

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

Enable the SPI peripheral

SPI transactions are not possible until the peripheral is enabled. This function is limited to ValidConfigs.

Trait Implementations

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

Get a shared reference to the underlying Config struct

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

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.