pub trait UsbHid<'a, T: UsbHidType> {
// Required methods
fn send_buffer(
&'a self,
send: &'static mut T,
) -> Result<usize, (ErrorCode, &'static mut T)>;
fn send_cancel(&'a self) -> Result<&'static mut T, ErrorCode>;
fn receive_buffer(
&'a self,
recv: &'static mut T,
) -> Result<(), (ErrorCode, &'static mut T)>;
fn receive_cancel(&'a self) -> Result<&'static mut T, ErrorCode>;
}
Required Methods§
Sourcefn send_buffer(
&'a self,
send: &'static mut T,
) -> Result<usize, (ErrorCode, &'static mut T)>
fn send_buffer( &'a self, send: &'static mut T, ) -> Result<usize, (ErrorCode, &'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 BUSY.
On success returns the length of data to be sent. On failure returns an error code and the buffer passed in.
Sourcefn send_cancel(&'a self) -> Result<&'static mut T, ErrorCode>
fn send_cancel(&'a self) -> Result<&'static mut T, ErrorCode>
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(INVAL)
.
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(BUSY)
and the callback will still occur.
Note that unless the transaction completes the callback will
indicate a result of CANCEL
.
Sourcefn receive_buffer(
&'a self,
recv: &'static mut T,
) -> Result<(), (ErrorCode, &'static mut T)>
fn receive_buffer( &'a self, recv: &'static mut T, ) -> Result<(), (ErrorCode, &'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 BUSY.
On success returns nothing. On failure returns an error code and the buffer passed in.
Sourcefn receive_cancel(&'a self) -> Result<&'static mut T, ErrorCode>
fn receive_cancel(&'a self) -> Result<&'static mut T, ErrorCode>
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(INVAL)
.
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(BUSY)
and the callback will still occur.
Note that unless the transaction completes the callback will
indicate a result of CANCEL
.