Skip to content

Commit e7ff232

Browse files
authored
Merge pull request #339 from ibrahim1416/fix/usb-descriptor-debug-build
usb_descriptors: fix CDC interface numbers and total count in debug build
2 parents 994e01a + 6c6b537 commit e7ff232

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/usb_descriptors.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,13 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
176176
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN)
177177

178178
#else
179-
#define ITF_NUM_CDC 4
180-
#define ITF_NUM_TOTAL 3
181-
#define ITF_NUM_TOTAL_CONFIG 5
179+
/* CDC uses 2 interfaces (control + data). In normal mode, place it right after
180+
the 2 HID interfaces (at 2, 3). In config mode, place it after HID_VENDOR (2)
181+
and MSC (3), so at 4, 5. */
182+
#define ITF_NUM_CDC 2
183+
#define ITF_NUM_CDC_CONFIG 4
184+
#define ITF_NUM_TOTAL 4
185+
#define ITF_NUM_TOTAL_CONFIG 6
182186

183187
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 2 * TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN)
184188
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN + TUD_CDC_DESC_LEN)
@@ -254,7 +258,7 @@ uint8_t const desc_configuration_config[] = {
254258
#ifdef DH_DEBUG
255259
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
256260
TUD_CDC_DESCRIPTOR(
257-
ITF_NUM_CDC, STRID_DEBUG, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, CFG_TUD_CDC_EP_BUFSIZE),
261+
ITF_NUM_CDC_CONFIG, STRID_DEBUG, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, CFG_TUD_CDC_EP_BUFSIZE),
258262
#endif
259263
};
260264

0 commit comments

Comments
 (0)