[][src]Trait kernel::hil::usb_hid::UsbHid

pub trait UsbHid<'a, T: UsbHidType> {
    fn send_buffer(
        &'a self,
        send: &'static mut T
    ) -> Result<usize, (ReturnCode, &'static mut T)>;
fn send_cancel(&'a self) -> Result<&'static mut T, ReturnCode>;
fn receive_buffer(
        &'a self,
        recv: &'static mut T
    ) -> Result<(), (ReturnCode, &'static mut T)>;
fn receive_cancel(&'a self) -> Result<&'static mut T, ReturnCode>; }

Required methods

fn send_buffer(
    &'a self,
    send: &'static mut T
) -> Result<usize, (ReturnCode, &'static mut T)>

Sets the buffer to be sent and starts a send transaction. Once the packet is sent the packet_transmitted() callback will be triggered and no more data will be sent until this is called again.

Once this is called, the implementation will wait until either the packet is sent or send_cancel() is called.

Calling send_buffer() while there is an outstanding send_buffer() operation will return EBUSY.

On success returns the length of data to be sent. On failure returns an error code and the buffer passed in.

fn send_cancel(&'a self) -> Result<&'static mut T, ReturnCode>

Cancels a send called by send_buffer(). If send_cancel() successfully cancels a send transaction before the transaction has been acted upon this function will return the buffer passed via send_buffer() and no callback will occur. If there is currently no send transaction (send_buffer() hasn't been called) this will return Err(EINVAL). If the transaction can't be cancelled cleanly, either because the send has already occured, a partial send has occured or the send can not be cancelled by the hardware this will return Err(EBUSY) and the callback will still occur. Note that unless the transaction completes the callback will indicate a result of ECANCEL.

fn receive_buffer(
    &'a self,
    recv: &'static mut T
) -> Result<(), (ReturnCode, &'static mut T)>

Sets the buffer for received data to be stored and enables receive transactions. Once this is called the implementation will enable receiving via USB. Once a packet is received the packet_received() callback will be triggered and no more data will be received until this is called again.

Once this is called, the implementation will wait until either a packet is received or receive_cancel() is called.

Calling receive_buffer() while there is an outstanding receive_buffer() operation will return EBUSY.

On success returns nothing. On failure returns an error code and the buffer passed in.

fn receive_cancel(&'a self) -> Result<&'static mut T, ReturnCode>

Cancels a receive called by receive_buffer(). If receive_cancel() successfully cancels a receive transaction before the transaction has been acted upon this function will return the buffer passed via receive_buffer() and no callback will occur. If there is currently no receive transaction (receive_buffer() hasn't been called) this will return Err(EINVAL). If the transaction can't be cancelled cleanly, either because the receive has already occured, a partial receive has occured or the receive can not be cancelled by the hardware this will return Err(EBUSY) and the callback will still occur. Note that unless the transaction completes the callback will indicate a result of ECANCEL.

Loading content...

Implementors

Loading content...