Struct capsules_extra::usb::keyboard_hid::KeyboardHid

source ·
pub struct KeyboardHid<'a, U: 'a> { /* private fields */ }
Expand description

Implementation of the CTAP HID (Human Interface Device)

Implementations§

source§

impl<'a, U: UsbController<'a>> KeyboardHid<'a, U>

source

pub fn new( controller: &'a U, vendor_id: u16, product_id: u16, strings: &'static [&'static str; 3], ) -> Self

source

pub fn set_client(&'a self, client: &'a dyn Client<'a, [u8; 64]>)

Trait Implementations§

source§

impl<'a, U: UsbController<'a>> Client<'a> for KeyboardHid<'a, U>

source§

fn ctrl_setup(&'a self, endpoint: usize) -> CtrlSetupResult

Handle a Control Setup transaction.

source§

fn ctrl_in(&'a self, endpoint: usize) -> CtrlInResult

Handle a Control In transaction

source§

fn ctrl_out(&'a self, _endpoint: usize, _packet_bytes: u32) -> CtrlOutResult

Handle a Control Out transaction

source§

fn ctrl_status_complete(&'a self, endpoint: usize)

Handle the completion of a Control transfer

source§

fn packet_in( &'a self, transfer_type: TransferType, _endpoint: usize, ) -> InResult

Handle a Bulk/Interrupt IN transaction.

This is called when we can send data to the host. It should get called when we tell the controller we want to resume the IN endpoint (meaning we know we have data to send) and afterwards until we return hil::usb::InResult::Delay from this function. That means we can use this as a callback to mean that the transmission finished by waiting until this function is called when we don’t have anything left to send.

source§

fn packet_out( &'a self, transfer_type: TransferType, _endpoint: usize, _packet_bytes: u32, ) -> OutResult

Handle a Bulk/Interrupt OUT transaction

Unused for keyboard.

source§

fn enable(&'a self)

source§

fn attach(&'a self)

source§

fn bus_reset(&'a self)

source§

fn ctrl_status(&'a self, endpoint: usize)

source§

fn packet_transmitted(&'a self, endpoint: usize)

source§

impl<'a, U: UsbController<'a>> UsbHid<'a, [u8; 64]> for KeyboardHid<'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 KeyboardHid<'a, U>

§

impl<'a, U> !RefUnwindSafe for KeyboardHid<'a, U>

§

impl<'a, U> !Send for KeyboardHid<'a, U>

§

impl<'a, U> !Sync for KeyboardHid<'a, U>

§

impl<'a, U> Unpin for KeyboardHid<'a, U>

§

impl<'a, U> !UnwindSafe for KeyboardHid<'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.