pub trait Driver: Debug {
// Required methods
fn want_device(&self, device: &DeviceDescriptor) -> bool;
fn add_device(
&mut self,
device: DeviceDescriptor,
address: u8,
) -> Result<(), DriverError>;
fn remove_device(&mut self, address: u8);
fn tick(
&mut self,
millis: usize,
usbhost: &mut dyn USBHost,
) -> Result<(), DriverError>;
}
Expand description
Trait for drivers on the USB host.
Required Methods§
Sourcefn want_device(&self, device: &DeviceDescriptor) -> bool
fn want_device(&self, device: &DeviceDescriptor) -> bool
Does this driver want device
?
Answering true
to this not necessarily mean the driver will
get device
.
Sourcefn add_device(
&mut self,
device: DeviceDescriptor,
address: u8,
) -> Result<(), DriverError>
fn add_device( &mut self, device: DeviceDescriptor, address: u8, ) -> Result<(), DriverError>
Add device
with address address
to the driver’s registry,
if necessary.
Sourcefn remove_device(&mut self, address: u8)
fn remove_device(&mut self, address: u8)
Remove the device at address address
from the driver’s
registry, if necessary.
Sourcefn tick(
&mut self,
millis: usize,
usbhost: &mut dyn USBHost,
) -> Result<(), DriverError>
fn tick( &mut self, millis: usize, usbhost: &mut dyn USBHost, ) -> Result<(), DriverError>
Called regularly by the USB host to allow the driver to do any work necessary on its registered devices.
millis
is the current time, in milliseconds from some
arbitrary starting point. It should be expected that after a
long enough run-time, this value will wrap.
usbhost
may be used for communication with the USB when
required.