[][src]Trait kernel::hil::uart::Receive

pub trait Receive<'a> {
    fn set_receive_client(&self, client: &'a dyn ReceiveClient);
fn receive_buffer(
        &self,
        rx_buffer: &'static mut [u8],
        rx_len: usize
    ) -> (ReturnCode, Option<&'static mut [u8]>);
fn receive_word(&self) -> ReturnCode;
fn receive_abort(&self) -> ReturnCode; }

Required methods

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

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

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

Receive rx_len bytes into rx_buffer, making a callback to the ReceiveClient when complete. If the ReturnCode of receive_buffer's return tuple is SUCCESS, the Option will be None and the struct will issue a received_buffer callback in the future. If the value of the ReturnCode is not SUCCESS, then the rx_buffer argument is returned in the Option. Other valid return values are:

  • EOFF: 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.
  • EBUSY: the UART is already receiving and has not made a reception complete callback yet.
  • ESIZE : 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 EBUSY.

fn receive_word(&self) -> ReturnCode

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 ReturnCode is SUCCESS, on completion, received_word will be called on the ReceiveClient. Other valid ReturnCode values are:

  • EOFF: 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.
  • EBUSY: 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 EBUSY.

fn receive_abort(&self) -> ReturnCode

Abort any ongoing receive transfers and return what is in the receive buffer with the receive_complete callback. If SUCCESS is returned, there will be no callback (no call to receive was outstanding). If there was a receive outstanding, which is cancelled successfully then EBUSY will be returned and there will be a callback with a ReturnCode of ECANCEL. If there was a reception outstanding, which is not cancelled successfully, then FAIL will be returned and there will be a later callback.

Loading content...

Implementors

Loading content...