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

pub trait Transmit<'a> {
    fn set_transmit_client(&self, client: &'a dyn TransmitClient);
fn transmit_buffer(
        &self,
        tx_buffer: &'static mut [u8],
        tx_len: usize
    ) -> (ReturnCode, Option<&'static mut [u8]>);
fn transmit_word(&self, word: u32) -> ReturnCode;
fn transmit_abort(&self) -> ReturnCode; }

Required methods

fn set_transmit_client(&self, client: &'a dyn TransmitClient)

Set the transmit client, which will be called when transmissions complete.

fn transmit_buffer(
    &self,
    tx_buffer: &'static mut [u8],
    tx_len: usize
) -> (ReturnCode, Option<&'static mut [u8]>)

Transmit a buffer of data. On completion, transmitted_buffer in the TransmitClient will be called. If the ReturnCode of transmit's return tuple is SUCCESS, the Option will be None and the struct will issue a transmitted_buffer callback in the future. If the value of the ReturnCode is not SUCCESS, then the tx_buffer argument is returned in the Option. 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 transmitting and has not made a transmission callback yet.
  • ESIZE : tx_len is larger than the passed slice.
  • FAIL: some other error.

Each byte in tx_buffer is a UART transfer word of 8 or fewer bits. The word width is determined by the UART configuration, truncating any more significant bits. E.g., 0x18f transmitted in 8N1 will be sent as 0x8f and in 7N1 will be sent as 0x0f. Clients that need to transfer 9-bit words should use transmit_word.

Calling transmit_buffer while there is an outstanding transmit_buffer or transmit_word operation will return EBUSY.

fn transmit_word(&self, word: u32) -> ReturnCode

Transmit a single word of data asynchronously. 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, transmitted_word will be called on the TransmitClient. 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 transmitting and has not made a transmission callback yet.
  • FAIL: not supported, or some other error. If the ReturnCode is not SUCCESS, no callback will be made. Calling transmit_word while there is an outstanding transmit_buffer or transmit_word operation will return EBUSY.

fn transmit_abort(&self) -> ReturnCode

Abort an outstanding call to transmit_word or transmit_buffer. The return code indicates whether the call has fully terminated or there will be a callback. Cancelled calls to transmit_buffer MUST always make a callback, to return the passed buffer back to the caller.

If abort_transmit returns SUCCESS, there will be no future callback and the client may retransmit immediately. If abort_transmit returns any other ReturnCode there will be a callback. This means that if there is no outstanding call to transmit_word or transmit_buffer then a call to abort_transmit returns SUCCESS. If there was a transmit outstanding and 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.

Returns SUCCESS or

  • FAIL if the outstanding call to either transmit operation could not be synchronously cancelled. A callback will be made on the client indicating whether the call was successfully cancelled.
Loading content...

Implementors

Loading content...