embassy-usb

Crates

git

Versions

default

Flavors

embassy_usb

Struct Config

Source
#[non_exhaustive]
pub struct Config<'a> {
Show 13 fields pub bcd_usb: UsbVersion, pub device_class: u8, pub device_sub_class: u8, pub device_protocol: u8, pub device_release: u16, pub max_packet_size_0: u8, pub manufacturer: Option<&'a str>, pub product: Option<&'a str>, pub serial_number: Option<&'a str>, pub supports_remote_wakeup: bool, pub composite_with_iads: bool, pub self_powered: bool, pub max_power: u16, /* private fields */
}
Expand description

Configuration used when creating UsbDevice.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§bcd_usb: UsbVersion

Device BCD USB version.

Default: 0x0210 (“2.1”)

§device_class: u8

Device class code assigned by USB.org. Set to 0xff for vendor-specific devices that do not conform to any class.

Default: 0x00 (class code specified by interfaces)

§device_sub_class: u8

Device sub-class code. Depends on class.

Default: 0x00

§device_protocol: u8

Device protocol code. Depends on class and sub-class.

Default: 0x00

§device_release: u16

Device release version in BCD.

Default: 0x0010 (“0.1”)

§max_packet_size_0: u8

Maximum packet size in bytes for the control endpoint 0.

Valid values depend on the speed at which the bus is enumerated.

  • low speed: 8
  • full speed: 8, 16, 32, or 64
  • high speed: 64

Default: 64 bytes

§manufacturer: Option<&'a str>

Manufacturer name string descriptor.

Default: (none)

§product: Option<&'a str>

Product name string descriptor.

Default: (none)

§serial_number: Option<&'a str>

Serial number string descriptor.

Default: (none)

§supports_remote_wakeup: bool

Whether the device supports remotely waking up the host is requested.

Default: false

§composite_with_iads: bool

Configures the device as a composite device with interface association descriptors.

If set to true, the following fields should have the given values:

  • device_class = 0xEF
  • device_sub_class = 0x02
  • device_protocol = 0x01
§self_powered: bool

Whether the device has its own power source.

This should be set to true even if the device is sometimes self-powered and may not always draw power from the USB bus.

Default: false

See also: max_power

§max_power: u16

Maximum current drawn from the USB bus by the device, in milliamps.

The default is 100 mA. If your device always uses an external power source and never draws power from the USB bus, this can be set to 0.

See also: self_powered

Default: 100mA Max: 500mA

Implementations§

Source§

impl<'a> Config<'a>

Source

pub const fn new(vid: u16, pid: u16) -> Self

Create default configuration with the provided vid and pid values.

Trait Implementations§

Source§

impl<'a> Clone for Config<'a>

Source§

fn clone(&self) -> Config<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Config<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Format for Config<'a>

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl<'a> Copy for Config<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Config<'a>

§

impl<'a> RefUnwindSafe for Config<'a>

§

impl<'a> Send for Config<'a>

§

impl<'a> Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> UnwindSafe for Config<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = 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>,

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.