pub struct Spi<R> {
    pub regs: R,
    pub cfg: SpiConfig,
}
Expand description

Represents a Serial Peripheral Interface (SPI) peripheral.

Fields

regs: Rcfg: SpiConfig

Implementations

Initialize an SPI peripheral, including configuration register writes, and enabling and resetting its RCC peripheral clock.

Change the SPI baud rate.

L44 RM, section 40.4.9: “Procedure for disabling the SPI” When SPI is disabled, it is mandatory to follow the disable procedures described in this paragraph. It is important to do this before the system enters a low-power mode when the peripheral clock is stopped. Ongoing transactions can be corrupted in this case. In some modes the disable procedure is the only way to stop continuous communication running.

Read a single byte if available, or block until it’s available. See L44 RM, section 40.4.9: Data transmission and reception procedures.

Write a single byte if available, or block until it’s available. See L44 RM, section 40.4.9: Data transmission and reception procedures.

Write multiple bytes on the SPI line, blocking until complete. See L44 RM, section 40.4.9: Data transmission and reception procedures.

Read multiple bytes to a buffer, blocking until complete. See L44 RM, section 40.4.9: Data transmission and reception procedures.

Transmit data using DMA. See L44 RM, section 40.4.9: Communication using DMA. Note that the channel argument has no effect on F3 and L4.

Receive data using DMA. See L44 RM, section 40.4.9: Communication using DMA. Note thay the channel argument has no effect on F3 and L4.

Transfer data from DMA; this is the basic reading API, using both write and read transfers: It performs a write with register data, and reads to a buffer.

Stop a DMA transfer. Stops the channel, and disables the txdmaen and rxdmaen bits. Run this after each transfer completes - you may wish to do this in an interrupt (eg DMA transfer complete) instead of blocking.

Enable an interrupt.

Clear an interrupt.

Trait Implementations

An enumeration of SPI errors

Reads the word stored in the shift register Read more

Sends a word to the slave

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.

Error type

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

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.

Error type

Sends words to the slave, ignoring all the incoming words