mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
usb: allow setting the interface string for interface alt settings
This commit is contained in:
parent
b0c8c688c7
commit
7ecb05ff77
@ -306,14 +306,25 @@ impl<'a, 'd, D: Driver<'d>> InterfaceBuilder<'a, 'd, D> {
|
|||||||
/// Alternate setting numbers are guaranteed to be allocated consecutively, starting from 0.
|
/// Alternate setting numbers are guaranteed to be allocated consecutively, starting from 0.
|
||||||
///
|
///
|
||||||
/// The first alternate setting, with number 0, is the default one.
|
/// The first alternate setting, with number 0, is the default one.
|
||||||
pub fn alt_setting(&mut self, class: u8, subclass: u8, protocol: u8) -> InterfaceAltBuilder<'_, 'd, D> {
|
pub fn alt_setting(
|
||||||
|
&mut self,
|
||||||
|
class: u8,
|
||||||
|
subclass: u8,
|
||||||
|
protocol: u8,
|
||||||
|
interface_string: Option<StringIndex>,
|
||||||
|
) -> InterfaceAltBuilder<'_, 'd, D> {
|
||||||
let number = self.next_alt_setting_number;
|
let number = self.next_alt_setting_number;
|
||||||
self.next_alt_setting_number += 1;
|
self.next_alt_setting_number += 1;
|
||||||
self.builder.interfaces[self.interface_number.0 as usize].num_alt_settings += 1;
|
self.builder.interfaces[self.interface_number.0 as usize].num_alt_settings += 1;
|
||||||
|
|
||||||
self.builder
|
self.builder.config_descriptor.interface_alt(
|
||||||
.config_descriptor
|
self.interface_number,
|
||||||
.interface_alt(self.interface_number, number, class, subclass, protocol, None);
|
number,
|
||||||
|
class,
|
||||||
|
subclass,
|
||||||
|
protocol,
|
||||||
|
interface_string,
|
||||||
|
);
|
||||||
|
|
||||||
InterfaceAltBuilder {
|
InterfaceAltBuilder {
|
||||||
builder: self.builder,
|
builder: self.builder,
|
||||||
|
@ -171,7 +171,7 @@ impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> {
|
|||||||
iface.handler(control);
|
iface.handler(control);
|
||||||
let comm_if = iface.interface_number();
|
let comm_if = iface.interface_number();
|
||||||
let data_if = u8::from(comm_if) + 1;
|
let data_if = u8::from(comm_if) + 1;
|
||||||
let mut alt = iface.alt_setting(USB_CLASS_CDC, CDC_SUBCLASS_ACM, CDC_PROTOCOL_NONE);
|
let mut alt = iface.alt_setting(USB_CLASS_CDC, CDC_SUBCLASS_ACM, CDC_PROTOCOL_NONE, None);
|
||||||
|
|
||||||
alt.descriptor(
|
alt.descriptor(
|
||||||
CS_INTERFACE,
|
CS_INTERFACE,
|
||||||
@ -205,7 +205,7 @@ impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> {
|
|||||||
// Data interface
|
// Data interface
|
||||||
let mut iface = func.interface();
|
let mut iface = func.interface();
|
||||||
let data_if = iface.interface_number();
|
let data_if = iface.interface_number();
|
||||||
let mut alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NONE);
|
let mut alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NONE, None);
|
||||||
let read_ep = alt.endpoint_bulk_out(max_packet_size);
|
let read_ep = alt.endpoint_bulk_out(max_packet_size);
|
||||||
let write_ep = alt.endpoint_bulk_in(max_packet_size);
|
let write_ep = alt.endpoint_bulk_in(max_packet_size);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ impl<'d, D: Driver<'d>> CdcNcmClass<'d, D> {
|
|||||||
mac_addr_str: [0; 12],
|
mac_addr_str: [0; 12],
|
||||||
}));
|
}));
|
||||||
let comm_if = iface.interface_number();
|
let comm_if = iface.interface_number();
|
||||||
let mut alt = iface.alt_setting(USB_CLASS_CDC, CDC_SUBCLASS_NCM, CDC_PROTOCOL_NONE);
|
let mut alt = iface.alt_setting(USB_CLASS_CDC, CDC_SUBCLASS_NCM, CDC_PROTOCOL_NONE, None);
|
||||||
|
|
||||||
alt.descriptor(
|
alt.descriptor(
|
||||||
CS_INTERFACE,
|
CS_INTERFACE,
|
||||||
@ -304,8 +304,8 @@ impl<'d, D: Driver<'d>> CdcNcmClass<'d, D> {
|
|||||||
let mut iface = func.interface();
|
let mut iface = func.interface();
|
||||||
iface.handler(state.data_control.write(DataControl {}));
|
iface.handler(state.data_control.write(DataControl {}));
|
||||||
let data_if = iface.interface_number();
|
let data_if = iface.interface_number();
|
||||||
let _alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NTB);
|
let _alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NTB, None);
|
||||||
let mut alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NTB);
|
let mut alt = iface.alt_setting(USB_CLASS_CDC_DATA, 0x00, CDC_PROTOCOL_NTB, None);
|
||||||
let read_ep = alt.endpoint_bulk_out(max_packet_size);
|
let read_ep = alt.endpoint_bulk_out(max_packet_size);
|
||||||
let write_ep = alt.endpoint_bulk_in(max_packet_size);
|
let write_ep = alt.endpoint_bulk_in(max_packet_size);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ fn build<'d, D: Driver<'d>>(
|
|||||||
let mut func = builder.function(USB_CLASS_HID, USB_SUBCLASS_NONE, USB_PROTOCOL_NONE);
|
let mut func = builder.function(USB_CLASS_HID, USB_SUBCLASS_NONE, USB_PROTOCOL_NONE);
|
||||||
let mut iface = func.interface();
|
let mut iface = func.interface();
|
||||||
iface.handler(control);
|
iface.handler(control);
|
||||||
let mut alt = iface.alt_setting(USB_CLASS_HID, USB_SUBCLASS_NONE, USB_PROTOCOL_NONE);
|
let mut alt = iface.alt_setting(USB_CLASS_HID, USB_SUBCLASS_NONE, USB_PROTOCOL_NONE, None);
|
||||||
|
|
||||||
// HID descriptor
|
// HID descriptor
|
||||||
alt.descriptor(
|
alt.descriptor(
|
||||||
|
Loading…
Reference in New Issue
Block a user