Trait serpente::prelude::_embedded_hal_serial_Read[][src]

pub trait _embedded_hal_serial_Read<Word> {
    type Error;
    fn read(&mut self) -> Result<Word, Error<Self::Error>>;
}
Expand description

Read half of a serial interface

Some serial interfaces support different data sizes (8 bits, 9 bits, etc.); This can be encoded in this trait via the Word type parameter.

Associated Types

Read error

Required methods

Reads a single word from the serial interface

Implementors

Implement Read for Slave OpMode

Read is only implemented when the Pads are Rx but NotTx. If the Pads are both Rx and Tx, then use FullDuplex.

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.

Implement Read for MasterModes

Read is only implemented when the Pads are Rx but NotTx. If the Pads are both Rx and Tx, then use FullDuplex.

In a MasterMode, Read has to initiate transactions and receive the responses. To do so, it uses a static allocation to keep 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.

It should not be possible for the tracked state to become invalid using only safe code. However, if using unsafe, the state could fall out of sync. In that case, the Spi::reset_serial_read_state method can be used to reset the state. After reset, a transaction is assumed to NOT be in progress.