pub struct Spi<C, A>where
    C: ValidConfig,
    A: Capability,
{ /* private fields */ }
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.

Disable the SPI peripheral and return the Config struct

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.

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.

An enumeration of SPI errors
Reads the word stored in the shift register Read more
Sends a word to the slave

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.

Read error
Reads a single word from the serial interface

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.

Wait for an RXC flag, then read the word

Read error

Implement Transfer for Spi structs that can Receive

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Error type
Sends words to the slave. Returns the words received from the slave

Implement Transfer for Spi structs that can Receive

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Error type
Sends words to the slave. Returns the words received from the slave

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.

Write error
Writes a single word to the serial interface
Ensures that none of the previously written words are still buffered

Implement Write for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Error type
Sends words to the slave, ignoring all the incoming words

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.

Error type
Sends words to the slave, ignoring all the incoming words

Implement Write for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Error type
Sends words to the slave, ignoring all the incoming words

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.

Error type
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).

Error type
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.

Error type
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).

Error type
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.

Error type
Sends words to the slave, ignoring all the incoming words

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
Spi transaction length Read more
Return the Spi transaction length Read more
Step size through the SpiFuture buffer Read more
Return the step size through the SpiFuture buffer Read more
Check that the buffer has a valid length 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.
The type of error that can occur when writing
Writes a slice, blocking until everything has been written Read more
Block until the serial interface has sent all buffered words