Skip to content

Commit d6354a2

Browse files
authored
Merge pull request #1877 from hathach/fix-host-cdc-without-iad
Fix host cdc without iad
2 parents 49628d8 + 9b6d6a9 commit d6354a2

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. figure:: docs/assets/logo.svg
22
:alt: TinyUSB
33

4-
|Build Status| |Documentation Status| |License|
4+
|Build Status| |Documentation Status| |Fuzzing Status| |License|
55

66
TinyUSB is an open-source cross-platform USB Host/Device stack for
77
embedded system, designed to be memory-safe with no dynamic allocation
@@ -130,6 +130,8 @@ in your project.
130130
:target: https://github.com/hathach/tinyusb/actions
131131
.. |Documentation Status| image:: https://readthedocs.org/projects/tinyusb/badge/?version=latest
132132
:target: https://docs.tinyusb.org/en/latest/?badge=latest
133+
.. |Fuzzing Status| image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/tinyusb.svg
134+
:target: https://oss-fuzz-build-logs.storage.googleapis.com/index.html#tinyusb
133135
.. |License| image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
134136
:target: https://opensource.org/licenses/MIT
135137

examples/device/hid_generic_inout/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ uint8_t const desc_configuration[] =
103103
// Config number, interface count, string index, total length, attribute, power in mA
104104
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
105105

106-
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
106+
// Interface number, string index, protocol, report descriptor len, EP Out & In address, size & polling interval
107107
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, 0x80 | EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
108108
};
109109

src/host/usbh.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static bool _parse_configuration_descriptor(uint8_t dev_addr, tusb_desc_configur
15221522

15231523
#if CFG_TUH_MIDI
15241524
// MIDI has 2 interfaces (Audio Control v1 + MIDIStreaming) but does not have IAD
1525-
// manually increase the associated count
1525+
// manually force associated count = 2
15261526
if (1 == assoc_itf_count &&
15271527
TUSB_CLASS_AUDIO == desc_itf->bInterfaceClass &&
15281528
AUDIO_SUBCLASS_CONTROL == desc_itf->bInterfaceSubClass &&
@@ -1532,6 +1532,17 @@ static bool _parse_configuration_descriptor(uint8_t dev_addr, tusb_desc_configur
15321532
}
15331533
#endif
15341534

1535+
#if CFG_TUH_CDC
1536+
// Some legacy CDC device does not use IAD but rather use device class as hint to combine 2 interfaces
1537+
// manually force associated count = 2
1538+
if (1 == assoc_itf_count &&
1539+
TUSB_CLASS_CDC == desc_itf->bInterfaceClass &&
1540+
CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL == desc_itf->bInterfaceSubClass)
1541+
{
1542+
assoc_itf_count = 2;
1543+
}
1544+
#endif
1545+
15351546
uint16_t const drv_len = tu_desc_get_interface_total_len(desc_itf, assoc_itf_count, (uint16_t) (desc_end-p_desc));
15361547
TU_ASSERT(drv_len >= sizeof(tusb_desc_interface_t));
15371548

0 commit comments

Comments
 (0)