Struct capsules_extra::usb_hid_driver::UsbHidDriver

source ·
pub struct UsbHidDriver<'a, U: UsbHid<'a, [u8; 64]>> { /* private fields */ }

Implementations§

source§

impl<'a, U: UsbHid<'a, [u8; 64]>> UsbHidDriver<'a, U>

source

pub fn new( usb: Option<&'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>

source§

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, )

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§

fn can_receive(&'a self) -> bool

Called when checking if we can start a new receive operation. Should return true if we are ready to receive and not currently in the process of receiving anything. That is if we are currently idle. If there is an outstanding call to receive, a callback already waiting to be called then this will return false.
source§

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

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>

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)>

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 more
source§

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])>

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 more
source§

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])>

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 more
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.