pub struct UsbHidDriver<'a, U: UsbHid<'a, [u8; 64]>> { /* private fields */ }
Implementations§
Source§impl<'a, U: UsbHid<'a, [u8; 64]>> UsbHidDriver<'a, U>
impl<'a, U: UsbHid<'a, [u8; 64]>> UsbHidDriver<'a, U>
pub fn new( usb: &'a U, send_buffer: &'static mut [u8; 64], recv_buffer: &'static mut [u8; 64], grant: Grant<App, UpcallCount<1>, AllowRoCount<0>, AllowRwCount<{ rw_allow::COUNT }>>, ) -> UsbHidDriver<'a, U>
Trait Implementations§
Source§impl<'a, U: UsbHid<'a, [u8; 64]>> Client<'a, [u8; 64]> for UsbHidDriver<'a, U>
impl<'a, U: UsbHid<'a, [u8; 64]>> Client<'a, [u8; 64]> for UsbHidDriver<'a, U>
Source§fn packet_received(
&'a self,
_result: Result<(), ErrorCode>,
buffer: &'static mut [u8; 64],
_endpoint: usize,
)
fn packet_received( &'a self, _result: Result<(), ErrorCode>, buffer: &'static mut [u8; 64], _endpoint: usize, )
Called when a packet is received.
This will return the buffer passed into
receive_buffer()
as well as
the endpoint where the data was received. If the buffer length is smaller
then the data length the buffer will only contain part of the packet and
result
will contain indicate an SIZE
error. Result will indicate
CANCEL
if a receive was cancelled by receive_cancel()
but the
callback still occurred. See receive_cancel()
for more details.Source§fn packet_transmitted(
&'a self,
_result: Result<(), ErrorCode>,
buffer: &'static mut [u8; 64],
_endpoint: usize,
)
fn packet_transmitted( &'a self, _result: Result<(), ErrorCode>, buffer: &'static mut [u8; 64], _endpoint: usize, )
Called when a packet has been finished transmitting.
This will return the buffer passed into
send_buffer()
as well as
the endpoint where the data was sent. If not all of the data could
be sent the result
will contain the SIZE
error. Result will
indicate CANCEL
if a send was cancelled by send_cancel()
but the callback still occurred. See send_cancel()
for more
details.Source§impl<'a, U: UsbHid<'a, [u8; 64]>> SyscallDriver for UsbHidDriver<'a, U>
impl<'a, U: UsbHid<'a, [u8; 64]>> SyscallDriver for UsbHidDriver<'a, U>
Source§fn command(
&self,
command_num: usize,
_data1: usize,
_data2: usize,
processid: ProcessId,
) -> CommandReturn
fn command( &self, command_num: usize, _data1: usize, _data2: usize, processid: ProcessId, ) -> CommandReturn
System call for a process to perform a short synchronous operation or
start a long-running split-phase operation (whose completion is signaled
with an upcall). Command 0 is a reserved command to detect if a
peripheral system call driver is installed and must always return a
CommandReturn::success
.Source§fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
Request to allocate a capsule’s grant for a specific process. Read more
Source§fn allow_userspace_readable(
&self,
app: ProcessId,
which: usize,
slice: ReadWriteProcessBuffer,
) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
System call for a process to pass a buffer (a
UserspaceReadableProcessBuffer
) to the kernel that the kernel can
either read or write. The kernel calls this method only after it checks
that the entire buffer is within memory the process can both read and
write. Read moreSource§impl<'a, U: UsbHid<'a, [u8; 64]>> UsbHid<'a, [u8; 64]> for UsbHidDriver<'a, U>
impl<'a, U: UsbHid<'a, [u8; 64]>> UsbHid<'a, [u8; 64]> for UsbHidDriver<'a, U>
Source§fn send_buffer(
&'a self,
send: &'static mut [u8; 64],
) -> Result<usize, (ErrorCode, &'static mut [u8; 64])>
fn send_buffer( &'a self, send: &'static mut [u8; 64], ) -> Result<usize, (ErrorCode, &'static mut [u8; 64])>
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. Read moreSource§fn send_cancel(&'a self) -> Result<&'static mut [u8; 64], ErrorCode>
fn send_cancel(&'a self) -> Result<&'static mut [u8; 64], 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
.Source§fn receive_buffer(
&'a self,
recv: &'static mut [u8; 64],
) -> Result<(), (ErrorCode, &'static mut [u8; 64])>
fn receive_buffer( &'a self, recv: &'static mut [u8; 64], ) -> Result<(), (ErrorCode, &'static mut [u8; 64])>
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. Read moreSource§fn receive_cancel(&'a self) -> Result<&'static mut [u8; 64], ErrorCode>
fn receive_cancel(&'a self) -> Result<&'static mut [u8; 64], 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
.Auto Trait Implementations§
impl<'a, U> !Freeze for UsbHidDriver<'a, U>
impl<'a, U> !RefUnwindSafe for UsbHidDriver<'a, U>
impl<'a, U> !Send for UsbHidDriver<'a, U>
impl<'a, U> !Sync for UsbHidDriver<'a, U>
impl<'a, U> Unpin for UsbHidDriver<'a, U>
impl<'a, U> !UnwindSafe for UsbHidDriver<'a, U>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more