From 80f978832479c2c0c34358d6d8e7b160798291d0 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Fri, 11 Oct 2019 12:48:16 +0200 Subject: [PATCH] cdc acm: add interface association descriptor --- sys/usb/usbus/cdc/acm/cdc_acm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/usb/usbus/cdc/acm/cdc_acm.c b/sys/usb/usbus/cdc/acm/cdc_acm.c index f67dfb7e43..0a3ba02511 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm.c @@ -47,9 +47,11 @@ static const usbus_handler_driver_t cdc_driver = { }; static size_t _gen_full_acm_descriptor(usbus_t *usbus, void *arg); +static size_t _gen_assoc_descriptor(usbus_t *usbus, void *arg); /* Descriptors */ static const usbus_hdr_gen_funcs_t _cdcacm_descriptor = { + .fmt_pre_descriptor = _gen_assoc_descriptor, .get_header = _gen_full_acm_descriptor, .len = { .fixed_len = sizeof(usb_desc_cdc_t) + @@ -60,6 +62,22 @@ static const usbus_hdr_gen_funcs_t _cdcacm_descriptor = { .len_type = USBUS_HDR_LEN_FIXED, }; +static size_t _gen_assoc_descriptor(usbus_t *usbus, void *arg) +{ + usbus_cdcacm_device_t *cdcacm = arg; + usb_descriptor_interface_association_t iad; + iad.length = sizeof(usb_descriptor_interface_association_t); + iad.type = USB_TYPE_DESCRIPTOR_INTERFACE_ASSOC; + iad.first_interface = cdcacm->iface_ctrl.idx; + iad.interface_count = 2; /* Management and data interface */ + iad.class = USB_CLASS_CDC_CONTROL; + iad.subclass = USB_CDC_SUBCLASS_ACM; + iad.protocol = 0; + iad.idx = 0; + usbus_control_slicer_put_bytes(usbus, (uint8_t*)&iad, sizeof(iad)); + return sizeof(iad); +} + static size_t _gen_mngt_descriptor(usbus_t *usbus, usbus_cdcacm_device_t *cdcacm) { usb_desc_call_mngt_t mngt;