@@ -87,64 +87,83 @@ uint8_t const * tud_descriptor_device_cb(void)
8787
8888enum
8989{
90- ITF_NUM_CDC = 0 ,
91- ITF_NUM_CDC_DATA ,
90+ ITF_NUM_CDC_0 = 0 ,
91+ ITF_NUM_CDC_0_DATA ,
92+ ITF_NUM_CDC_1 ,
93+ ITF_NUM_CDC_1_DATA ,
9294 ITF_NUM_MSC ,
9395 ITF_NUM_TOTAL
9496};
9597
9698#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
9799 // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
98- // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
99- #define EPNUM_CDC_NOTIF 0x81
100- #define EPNUM_CDC_OUT 0x02
101- #define EPNUM_CDC_IN 0x82
100+ // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
101+ #define EPNUM_CDC_0_NOTIF 0x81
102+ #define EPNUM_CDC_0_OUT 0x02
103+ #define EPNUM_CDC_0_IN 0x82
102104
103- #define EPNUM_MSC_OUT 0x05
104- #define EPNUM_MSC_IN 0x85
105+ #define EPNUM_CDC_1_NOTIF 0x84
106+ #define EPNUM_CDC_1_OUT 0x05
107+ #define EPNUM_CDC_1_IN 0x85
105108
106- #elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
107- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
108- // e.g EP1 OUT & EP1 IN cannot exist together
109- #define EPNUM_CDC_NOTIF 0x81
110- #define EPNUM_CDC_OUT 0x02
111- #define EPNUM_CDC_IN 0x83
112-
113- #define EPNUM_MSC_OUT 0x04
114- #define EPNUM_MSC_IN 0x85
109+ #define EPNUM_MSC_OUT 0x08
110+ #define EPNUM_MSC_IN 0x88
115111
116112#elif CFG_TUSB_MCU == OPT_MCU_CXD56
117- // CXD56 doesn't support a same endpoint number with different direction IN and OUT
118- // e.g EP1 OUT & EP1 IN cannot exist together
119113 // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
120114 // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
121- #define EPNUM_CDC_NOTIF 0x83
122- #define EPNUM_CDC_OUT 0x02
123- #define EPNUM_CDC_IN 0x81
115+ #define EPNUM_CDC_0_NOTIF 0x83
116+ #define EPNUM_CDC_0_OUT 0x02
117+ #define EPNUM_CDC_0_IN 0x81
124118
125- #define EPNUM_MSC_OUT 0x05
126- #define EPNUM_MSC_IN 0x84
119+ #define EPNUM_CDC_1_NOTIF 0x86
120+ #define EPNUM_CDC_1_OUT 0x05
121+ #define EPNUM_CDC_1_IN 0x84
122+
123+ #define EPNUM_MSC_OUT 0x07
124+ #define EPNUM_MSC_IN 0x08
125+
126+ #elif defined(TUD_ENDPOINT_ONE_DIRECTION_ONLY )
127+ // MCUs that don't support a same endpoint number with different direction IN and OUT
128+ // e.g EP1 OUT & EP1 IN cannot exist together
129+ #define EPNUM_CDC_0_NOTIF 0x81
130+ #define EPNUM_CDC_0_OUT 0x02
131+ #define EPNUM_CDC_0_IN 0x83
132+
133+ #define EPNUM_CDC_1_NOTIF 0x84
134+ #define EPNUM_CDC_1_OUT 0x05
135+ #define EPNUM_CDC_1_IN 0x86
136+
137+ #define EPNUM_MSC_OUT 0x07
138+ #define EPNUM_MSC_IN 0x88
127139
128140#else
129- #define EPNUM_CDC_NOTIF 0x81
130- #define EPNUM_CDC_OUT 0x02
131- #define EPNUM_CDC_IN 0x82
141+ #define EPNUM_CDC_0_NOTIF 0x81
142+ #define EPNUM_CDC_0_OUT 0x02
143+ #define EPNUM_CDC_0_IN 0x82
144+
145+ #define EPNUM_CDC_1_NOTIF 0x83
146+ #define EPNUM_CDC_1_OUT 0x04
147+ #define EPNUM_CDC_1_IN 0x84
132148
133- #define EPNUM_MSC_OUT 0x03
134- #define EPNUM_MSC_IN 0x83
149+ #define EPNUM_MSC_OUT 0x05
150+ #define EPNUM_MSC_IN 0x85
135151
136152#endif
137153
138- #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
154+ #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
139155
140156// full speed configuration
141157uint8_t const desc_fs_configuration [] =
142158{
143159 // Config number, interface count, string index, total length, attribute, power in mA
144160 TUD_CONFIG_DESCRIPTOR (1 , ITF_NUM_TOTAL , 0 , CONFIG_TOTAL_LEN , 0x00 , 100 ),
145161
146- // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
147- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC , 4 , EPNUM_CDC_NOTIF , 8 , EPNUM_CDC_OUT , EPNUM_CDC_IN , 64 ),
162+ // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
163+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 64 ),
164+
165+ // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
166+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 6 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 64 ),
148167
149168 // Interface number, string index, EP Out & EP In address, EP size
150169 TUD_MSC_DESCRIPTOR (ITF_NUM_MSC , 5 , EPNUM_MSC_OUT , EPNUM_MSC_IN , 64 ),
@@ -159,8 +178,11 @@ uint8_t const desc_hs_configuration[] =
159178 // Config number, interface count, string index, total length, attribute, power in mA
160179 TUD_CONFIG_DESCRIPTOR (1 , ITF_NUM_TOTAL , 0 , CONFIG_TOTAL_LEN , 0x00 , 100 ),
161180
162- // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
163- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC , 4 , EPNUM_CDC_NOTIF , 8 , EPNUM_CDC_OUT , EPNUM_CDC_IN , 512 ),
181+ // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
182+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 512 ),
183+
184+ // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
185+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 6 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 512 ),
164186
165187 // Interface number, string index, EP Out & EP In address, EP size
166188 TUD_MSC_DESCRIPTOR (ITF_NUM_MSC , 5 , EPNUM_MSC_OUT , EPNUM_MSC_IN , 512 ),
@@ -249,8 +271,9 @@ char const *string_desc_arr[] =
249271 "PicoRuby" , // 1: Manufacturer
250272 "R2P2" , // 2: Product
251273 NULL , // 3: Serials will use unique ID if possible
252- "PicoRuby CDC" , // 4: CDC Interface
274+ "PicoRuby CDC" , // 4: CDC Interface 0 (Application)
253275 "PicoRuby MSC" , // 5: MSC Interface
276+ "PicoRuby CDC Debug" , // 6: CDC Interface 1 (Debug)
254277};
255278
256279static uint16_t _desc_str [32 + 1 ];
0 commit comments