pub struct UsbDeviceBuilder<'a, B: UsbBus> { /* private fields */ }Expand description
Builder for UsbDevice.
§Example
ⓘ
use my_hal_usb::{UsbBusAllocator, UsbDeviceBuilder};
use my_hal_usb::class::cdc_acm::CdcAcm;
use my_hal_usb::MyBus;
let alloc = UsbBusAllocator::new(MyBus::new(/* peripheral */));
let mut serial = CdcAcm::new(&alloc);
let mut usb_dev = UsbDeviceBuilder::new(&alloc, 0x1234, 0x5678)
.product("My Device")
.manufacturer("My Company")
.serial_number("001")
.build();
loop {
if usb_dev.poll(&mut [&mut serial]) { /* … */ }
}Implementations§
Source§impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B>
impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B>
Sourcepub fn new(
alloc: &'a UsbBusAllocator<B>,
vendor_id: u16,
product_id: u16,
) -> Self
pub fn new( alloc: &'a UsbBusAllocator<B>, vendor_id: u16, product_id: u16, ) -> Self
Create a builder with the required VID/PID pair.
Sourcepub fn build(self) -> UsbDevice<'a, B>
pub fn build(self) -> UsbDevice<'a, B>
Build the UsbDevice. Allocates EP0 and enables the peripheral.
Sourcepub fn device_class(self, c: u8) -> Self
pub fn device_class(self, c: u8) -> Self
Set the device class code.
Sourcepub fn device_sub_class(self, c: u8) -> Self
pub fn device_sub_class(self, c: u8) -> Self
Set the device subclass code.
Sourcepub fn device_protocol(self, c: u8) -> Self
pub fn device_protocol(self, c: u8) -> Self
Set the device protocol code.
Sourcepub fn device_release(self, r: u16) -> Self
pub fn device_release(self, r: u16) -> Self
Set the device release number (BCD).
Sourcepub fn max_packet_size_0(self, s: u8) -> Self
pub fn max_packet_size_0(self, s: u8) -> Self
Set the EP0 maximum packet size (8, 16, 32 or 64).
Sourcepub fn manufacturer(self, s: &'a str) -> Self
pub fn manufacturer(self, s: &'a str) -> Self
Set the manufacturer string.
Sourcepub fn serial_number(self, s: &'a str) -> Self
pub fn serial_number(self, s: &'a str) -> Self
Set the serial-number string.
Sourcepub fn self_powered(self, v: bool) -> Self
pub fn self_powered(self, v: bool) -> Self
Declare that the device is self-powered.
Sourcepub fn supports_remote_wakeup(self, v: bool) -> Self
pub fn supports_remote_wakeup(self, v: bool) -> Self
Declare remote-wakeup support.
Sourcepub fn max_power_ma(self, ma: u16) -> Self
pub fn max_power_ma(self, ma: u16) -> Self
Set maximum power in mA (stored as mA/2 per USB spec).
Sourcepub fn composite_with_iads(self) -> Self
pub fn composite_with_iads(self) -> Self
Configure as a composite device with Interface Association Descriptors.
Auto Trait Implementations§
impl<'a, B> !RefUnwindSafe for UsbDeviceBuilder<'a, B>
impl<'a, B> !UnwindSafe for UsbDeviceBuilder<'a, B>
impl<'a, B> Forget for UsbDeviceBuilder<'a, B>
impl<'a, B> Freeze for UsbDeviceBuilder<'a, B>where
&'a UsbBusAllocator<B>: Freeze,
impl<'a, B> Move for UsbDeviceBuilder<'a, B>
impl<'a, B> Send for UsbDeviceBuilder<'a, B>where
&'a UsbBusAllocator<B>: Send,
impl<'a, B> Sync for UsbDeviceBuilder<'a, B>where
&'a UsbBusAllocator<B>: Sync,
impl<'a, B> Unpin for UsbDeviceBuilder<'a, B>where
&'a UsbBusAllocator<B>: Unpin,
impl<'a, B> UnsafeUnpin for UsbDeviceBuilder<'a, B>where
&'a UsbBusAllocator<B>: UnsafeUnpin,
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