pub struct I2cTinyUsb<I: I2cBus> { /* private fields */ }Expand description
i2c-tiny-usb adapter: wraps an I2cBus and serves the vendor protocol.
The adapter needs no endpoints of its own — everything travels over the control pipe — so the type is only parameterised by the bus it drives.
Implementations§
Source§impl<I: I2cBus> I2cTinyUsb<I>
impl<I: I2cBus> I2cTinyUsb<I>
Sourcepub fn new<B: UsbBus>(alloc: &UsbBusAllocator<B>, bus: I) -> Self
pub fn new<B: UsbBus>(alloc: &UsbBusAllocator<B>, bus: I) -> Self
Create an adapter that reports func::DEFAULT functionality.
Call it before building the device, like any other class.
Sourcepub fn with_functionality<B: UsbBus>(
alloc: &UsbBusAllocator<B>,
bus: I,
functionality: u32,
) -> Self
pub fn with_functionality<B: UsbBus>( alloc: &UsbBusAllocator<B>, bus: I, functionality: u32, ) -> Self
Create an adapter that reports functionality for Get Functionality.
Report what the bus really supports: bits for features that are not implemented make the kernel issue transfers the adapter has to stall.
Sourcepub fn bus_mut(&mut self) -> &mut I
pub fn bus_mut(&mut self) -> &mut I
The wrapped I2C bus, e.g. to use it from the application as well.
Sourcepub fn functionality(&self) -> u32
pub fn functionality(&self) -> u32
Functionality reported to the host.
Sourcepub fn set_functionality(&mut self, functionality: u32)
pub fn set_functionality(&mut self, functionality: u32)
Change the reported functionality.
Trait Implementations§
Source§impl<B: UsbBus, I: I2cBus> UsbClass<B> for I2cTinyUsb<I>
impl<B: UsbBus, I: I2cBus> UsbClass<B> for I2cTinyUsb<I>
Source§fn configuration_descriptors(
&self,
w: &mut DescriptorWriter<'_>,
) -> UsbResult<()>
fn configuration_descriptors( &self, w: &mut DescriptorWriter<'_>, ) -> UsbResult<()>
Append this class’s interface and endpoint descriptors.
Source§fn control_in(&mut self, xfer: ControlIn<'_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, B>)
Handle a control IN transfer. Accept, reject, or pass (drop without acting).
Source§fn control_out(&mut self, xfer: ControlOut<'_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, B>)
Handle a control OUT transfer. Accept, reject, or pass (drop without acting).
Source§fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
Return the string for a previously allocated
StringIndex, or None.Source§fn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
Called when endpoint
addr received an OUT packet.Source§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
Called when endpoint
addr completed an IN transfer.Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
Called when endpoint
addr received a SETUP packet (non-EP0 control).Source§fn deconfigure(&mut self)
fn deconfigure(&mut self)
Called when the host sends SET_CONFIGURATION(0) or on reset.
Source§fn poll(&mut self)
fn poll(&mut self)
Called unconditionally on every
UsbDevice::poll.Source§fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
Return the current alternate setting for
interface, or None.Source§fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
Set the alternate setting for
interface. Return true if handled.Auto Trait Implementations§
impl<I> Forget for I2cTinyUsb<I>
impl<I> Freeze for I2cTinyUsb<I>where
I: Freeze,
impl<I> Move for I2cTinyUsb<I>
impl<I> RefUnwindSafe for I2cTinyUsb<I>where
I: RefUnwindSafe,
impl<I> Send for I2cTinyUsb<I>where
I: Send,
impl<I> Sync for I2cTinyUsb<I>where
I: Sync,
impl<I> Unpin for I2cTinyUsb<I>where
I: Unpin,
impl<I> UnsafeUnpin for I2cTinyUsb<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for I2cTinyUsb<I>where
I: UnwindSafe,
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