Skip to main content

I2cTinyUsb

Struct I2cTinyUsb 

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

Source

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.

Source

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.

Source

pub fn bus(&self) -> &I

The wrapped I2C bus.

Source

pub fn bus_mut(&mut self) -> &mut I

The wrapped I2C bus, e.g. to use it from the application as well.

Source

pub fn functionality(&self) -> u32

Functionality reported to the host.

Source

pub fn set_functionality(&mut self, functionality: u32)

Change the reported functionality.

Source

pub fn delay_us(&self) -> u16

Bit delay requested by the host, in microseconds.

Source

pub fn status(&self) -> u8

Status reported by Get Status.

Source

pub fn transfers(&self) -> u32

Transfers performed for the host.

Source

pub fn failures(&self) -> u32

Transfers that failed and were reported to the host as a NAK.

Trait Implementations§

Source§

impl<B: UsbBus, I: I2cBus> UsbClass<B> for I2cTinyUsb<I>

Source§

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

Handle a control IN transfer. Accept, reject, or pass (drop without acting).
Source§

fn control_out(&mut self, xfer: ControlOut<'_, B>)

Handle a control OUT transfer. Accept, reject, or pass (drop without acting).
Source§

fn configure(&mut self)

Called when the host sends SET_CONFIGURATION(1).
Source§

fn reset(&mut self)

Called after a USB bus reset.
Source§

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)

Called when endpoint addr received an OUT packet.
Source§

fn endpoint_in_complete(&mut self, addr: EndpointAddress)

Called when endpoint addr completed an IN transfer.
Source§

fn endpoint_setup(&mut self, addr: EndpointAddress)

Called when endpoint addr received a SETUP packet (non-EP0 control).
Source§

fn deconfigure(&mut self)

Called when the host sends SET_CONFIGURATION(0) or on reset.
Source§

fn poll(&mut self)

Called unconditionally on every UsbDevice::poll.
Source§

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.