Trait kernel::hil::uart::Receive

source ·
pub trait Receive<'a> {
    // Required methods
    fn set_receive_client(&self, client: &'a dyn ReceiveClient);
    fn receive_buffer(
        &self,
        rx_buffer: &'static mut [u8],
        rx_len: usize
    ) -> Result<(), (ErrorCode, &'static mut [u8])>;
    fn receive_word(&self) -> Result<(), ErrorCode>;
    fn receive_abort(&self) -> Result<(), ErrorCode>;
}

Required Methods§

source

fn set_receive_client(&self, client: &'a dyn ReceiveClient)

Set the receive client, which will he called when reads complete.

source

fn receive_buffer( &self, rx_buffer: &'static mut [u8], rx_len: usize ) -> Result<(), (ErrorCode, &'static mut [u8])>

Receive rx_len bytes into rx_buffer, making a callback to the ReceiveClient when complete. If the Result<(), ErrorCode> of receive_buffer’s return is Ok(()), the struct will issue a received_buffer callback in the future. If the value of the Result<(), ErrorCode> is Err(), then the rx_buffer argument is returned in the Err(). Valid ErrorCode values are:

  • OFF: The underlying hardware is not available, perhaps because it has not been initialized or in the case of a shared hardware USART controller because it is set up for SPI.
  • BUSY: the UART is already receiving and has not made a reception complete callback yet.
  • SIZE : rx_len is larger than the passed slice. Each byte in rx_buffer is a UART transfer word of 8 or fewer bits. The width is determined by the UART configuration. Clients that need to transfer 9-bit words should use receive_word. Calling receive_buffer while there is an outstanding receive_buffer or receive_word operation will return Err(BUSY, rx_buffer).
source

fn receive_word(&self) -> Result<(), ErrorCode>

Receive a single word of data. The word length is determined by the UART configuration: it can be 6, 7, 8, or 9 bits long. If the Result<(), ErrorCode> is Ok(()), on completion, received_word will be called on the ReceiveClient. Other valid ErrorCode values are:

  • OFF: The underlying hardware is not available, perhaps because it has not been initialized or in the case of a shared hardware USART controller because it is set up for SPI.
  • BUSY: the UART is already receiving and has not made a reception callback yet.
  • FAIL: not supported or some other error. Calling receive_word while there is an outstanding receive_buffer or receive_word operation will return `Err(BUSY).
source

fn receive_abort(&self) -> Result<(), ErrorCode>

Abort any ongoing receive transfers and return what is in the receive buffer with the receive_complete callback. If Ok(()) is returned, there will be no callback (no call to receive was outstanding). If there was a receive outstanding, which is cancelled successfully then BUSY will be returned and there will be a callback with a Result<(), ErrorCode> of CANCEL. If there was a reception outstanding, which is not cancelled successfully, then FAIL will be returned and there will be a later callback.

Implementors§