From a23944035dab67a206edad9e31e3ee7400b68bbb Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 15 Sep 2021 00:51:01 +0700 Subject: [PATCH] correct assoc_itf_count for bth driver --- src/device/usbd.c | 11 +++++++++++ src/device/usbd.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/device/usbd.c b/src/device/usbd.c index f23d3048d..f7846cc0a 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -921,6 +921,17 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) } #endif +#if CFG_TUD_BTH && CFG_TUD_BTH_ISO_ALT_COUNT + // BTH implementation currently does not use IAD. TODO should also use IAD for composite device + if (1 == assoc_itf_count && + TUD_BT_APP_CLASS == desc_itf->bInterfaceClass && + TUD_BT_APP_SUBCLASS == desc_itf->bInterfaceSubClass && + TUD_BT_PROTOCOL_PRIMARY_CONTROLLER == desc_itf->bInterfaceProtocol) + { + assoc_itf_count = 2; + } +#endif + uint16_t const drv_len = tu_desc_get_interface_total_len(desc_itf, assoc_itf_count, desc_end-p_desc); TU_ASSERT(drv_len >= sizeof(tusb_desc_interface_t)); diff --git a/src/device/usbd.h b/src/device/usbd.h index 638d93094..c83509234 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -777,6 +777,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb // BT Primary controller descriptor // Interface number, string index, attributes, event endpoint, event endpoint size, interval, data in, data out, data endpoint size, iso endpoint sizes +// TODO BTH should also use IAD like CDC for composite device #define TUD_BTH_DESCRIPTOR(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size,...) \ TUD_BTH_PRI_ITF(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size) \ TUD_BTH_ISO_ITFS(_itfnum + 1, _ep_in + 1, _ep_out + 1, __VA_ARGS__)