Skip to content

Commit

Permalink
Merge pull request #3682 from Eekle/usb_composite_iars_by_default
Browse files Browse the repository at this point in the history
Usb composite iads by default
  • Loading branch information
Dirbaio authored Dec 24, 2024
2 parents f58efe9 + cac7000 commit 2c87b31
Show file tree
Hide file tree
Showing 31 changed files with 14 additions and 209 deletions.
7 changes: 0 additions & 7 deletions embassy-usb-logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ impl<const N: usize, T: ReceiverHandler + Send + Sync> UsbLogger<N, T> {
config.max_power = 100;
config.max_packet_size_0 = MAX_PACKET_SIZE;

// Required for windows compatiblity.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

let mut builder = Builder::new(
driver,
config,
Expand Down
22 changes: 14 additions & 8 deletions embassy-usb/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ pub struct Config<'a> {
/// 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)
/// Default: `0xEF`
/// See also: `composite_with_iads`
pub device_class: u8,

/// Device sub-class code. Depends on class.
///
/// Default: `0x00`
/// Default: `0x02`
/// See also: `composite_with_iads`
pub device_sub_class: u8,

/// Device protocol code. Depends on class and sub-class.
///
/// Default: `0x00`
/// Default: `0x01`
/// See also: `composite_with_iads`
pub device_protocol: u8,

/// Device release version in BCD.
Expand Down Expand Up @@ -84,11 +87,14 @@ pub struct Config<'a> {

/// Configures the device as a composite device with interface association descriptors.
///
/// If set to `true`, the following fields should have the given values:
/// If set to `true` (default), the following fields should have the given values:
///
/// - `device_class` = `0xEF`
/// - `device_sub_class` = `0x02`
/// - `device_protocol` = `0x01`
///
/// If set to `false`, those fields must be set correctly for the classes that will be
/// installed on the USB device.
pub composite_with_iads: bool,

/// Whether the device has its own power source.
Expand Down Expand Up @@ -117,9 +123,9 @@ impl<'a> Config<'a> {
/// Create default configuration with the provided vid and pid values.
pub const fn new(vid: u16, pid: u16) -> Self {
Self {
device_class: 0x00,
device_sub_class: 0x00,
device_protocol: 0x00,
device_class: 0xEF,
device_sub_class: 0x02,
device_protocol: 0x01,
max_packet_size_0: 64,
vendor_id: vid,
product_id: pid,
Expand All @@ -130,7 +136,7 @@ impl<'a> Config<'a> {
serial_number: None,
self_powered: false,
supports_remote_wakeup: false,
composite_with_iads: false,
composite_with_iads: true,
max_power: 100,
}
}
Expand Down
6 changes: 0 additions & 6 deletions examples/nrf52840/src/bin/usb_ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ async fn main(spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for Windows support.
config.composite_with_iads = true;
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;

// Create embassy-usb DeviceBuilder using the driver and config.
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
Expand Down
7 changes: 0 additions & 7 deletions examples/nrf52840/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/nrf52840/src/bin/usb_serial_multitask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ async fn main(spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

static STATE: StaticCell<State> = StaticCell::new();
let state = STATE.init(State::new());

Expand Down
7 changes: 0 additions & 7 deletions examples/nrf52840/src/bin/usb_serial_winusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/pio_uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
6 changes: 0 additions & 6 deletions examples/rp/src/bin/usb_ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ async fn main(spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for Windows support.
config.composite_with_iads = true;
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;

// Create embassy-usb DeviceBuilder using the driver and config.
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/usb_midi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/usb_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// // Required for windows compatibility.
// // https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/usb_raw_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// // Required for windows compatibility.
// // https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ async fn main(spawner: Spawner) {
config.serial_number = Some("12345678");
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;
config
};

Expand Down
7 changes: 0 additions & 7 deletions examples/rp/src/bin/usb_serial_with_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/rp23/src/bin/pio_uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
6 changes: 0 additions & 6 deletions examples/stm32f4/src/bin/usb_ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ async fn main(spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for Windows support.
config.composite_with_iads = true;
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;

// Create embassy-usb DeviceBuilder using the driver and config.
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f4/src/bin/usb_hid_keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ async fn main(_spawner: Spawner) {
config.max_power = 100;
config.max_packet_size_0 = 64;

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f4/src/bin/usb_hid_mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("HID mouse example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f4/src/bin/usb_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-raw example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f4/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-serial example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f4/src/bin/usb_uac_speaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,6 @@ async fn main(spawner: Spawner) {
config.product = Some("USB-audio-speaker example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

let mut builder = embassy_usb::Builder::new(
usb_driver,
config,
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32f7/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-serial example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
5 changes: 0 additions & 5 deletions examples/stm32g4/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-Serial Example");
config.serial_number = Some("123456");

config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32h5/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-serial example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32h5/src/bin/usb_uac_speaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,6 @@ async fn main(spawner: Spawner) {
config.product = Some("USB-audio-speaker example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

let mut builder = embassy_usb::Builder::new(
usb_driver,
config,
Expand Down
7 changes: 0 additions & 7 deletions examples/stm32h7/src/bin/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-serial example");
config.serial_number = Some("12345678");

// Required for windows compatibility.
// https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
config.device_class = 0xEF;
config.device_sub_class = 0x02;
config.device_protocol = 0x01;
config.composite_with_iads = true;

// Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
Expand Down
Loading

0 comments on commit 2c87b31

Please sign in to comment.