2828#include "tusb.h"
2929#include "get_serial.h"
3030#include "probe_config.h"
31+ #include "pico/usb_reset_interface.h"
3132
3233//--------------------------------------------------------------------+
3334// Device Descriptors
7172 ITF_NUM_PROBE , // Old versions of Keil MDK only look at interface 0
7273 ITF_NUM_CDC_COM ,
7374 ITF_NUM_CDC_DATA ,
75+ ITF_NUM_RESET ,
7476 ITF_NUM_TOTAL
7577};
7678
8385#if (PROBE_DEBUG_PROTOCOL == PROTO_DAP_V1 )
8486#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_HID_INOUT_DESC_LEN)
8587#else
86- #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_VENDOR_DESC_LEN)
88+ #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_VENDOR_DESC_LEN + TUD_RPI_RESET_DESC_LEN )
8789#endif
8890
8991static uint8_t const desc_hid_report [] =
@@ -113,6 +115,8 @@ uint8_t desc_configuration[] =
113115#endif
114116 // Interface 1 + 2
115117 TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_COM , 6 , CDC_NOTIFICATION_EP_NUM , 64 , CDC_DATA_OUT_EP_NUM , CDC_DATA_IN_EP_NUM , 64 ),
118+ // Reset interface
119+ TUD_RPI_RESET_DESCRIPTOR (ITF_NUM_RESET , 7 ),
116120};
117121
118122// Invoked when received GET CONFIGURATION DESCRIPTOR
@@ -122,7 +126,7 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
122126{
123127 (void ) index ; // for multiple configurations
124128 /* Hack in CAP_BREAK support */
125- desc_configuration [CONFIG_TOTAL_LEN - TUD_CDC_DESC_LEN + 8 + 9 + 5 + 5 + 4 - 1 ] = 0x6 ;
129+ desc_configuration [CONFIG_TOTAL_LEN - TUD_RPI_RESET_DESC_LEN - TUD_CDC_DESC_LEN + 8 + 9 + 5 + 5 + 4 - 1 ] = 0x6 ;
126130 return desc_configuration ;
127131}
128132
@@ -140,6 +144,7 @@ char const* string_desc_arr [] =
140144 "CMSIS-DAP v1 Interface" , // 4: Interface descriptor for HID transport
141145 "CMSIS-DAP v2 Interface" , // 5: Interface descriptor for Bulk transport
142146 "CDC-ACM UART Interface" , // 6: Interface descriptor for CDC
147+ "Reset" , // 7: Interface descriptor for Reset
143148};
144149
145150static uint16_t _desc_str [32 ];
@@ -198,7 +203,8 @@ will insert "DeviceInterfaceGUIDs" multistring property.
198203https://developers.google.com/web/fundamentals/native-hardware/build-for-webusb/
199204(Section Microsoft OS compatibility descriptors)
200205*/
201- #define MS_OS_20_DESC_LEN 0xB2
206+ #define MS_OS_FEATURE_DESC_LEN 0xA0
207+ #define MS_OS_20_DESC_LEN (0x0A + 0x08 + (MS_OS_FEATURE_DESC_LEN*2))
202208
203209#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
204210
@@ -220,14 +226,14 @@ uint8_t const desc_ms_os_20[] =
220226 U16_TO_U8S_LE (0x0008 ), U16_TO_U8S_LE (MS_OS_20_SUBSET_HEADER_CONFIGURATION ), 0 , 0 , U16_TO_U8S_LE (MS_OS_20_DESC_LEN - 0x0A ),
221227
222228 // Function Subset header: length, type, first interface, reserved, subset length
223- U16_TO_U8S_LE (0x0008 ), U16_TO_U8S_LE (MS_OS_20_SUBSET_HEADER_FUNCTION ), ITF_NUM_PROBE , 0 , U16_TO_U8S_LE (MS_OS_20_DESC_LEN - 0x0A - 0x08 ),
229+ U16_TO_U8S_LE (0x0008 ), U16_TO_U8S_LE (MS_OS_20_SUBSET_HEADER_FUNCTION ), ITF_NUM_PROBE , 0 , U16_TO_U8S_LE (MS_OS_FEATURE_DESC_LEN ),
224230
225231 // MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID
226232 U16_TO_U8S_LE (0x0014 ), U16_TO_U8S_LE (MS_OS_20_FEATURE_COMPATBLE_ID ), 'W' , 'I' , 'N' , 'U' , 'S' , 'B' , 0x00 , 0x00 ,
227233 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // sub-compatible
228234
229235 // MS OS 2.0 Registry property descriptor: length, type
230- U16_TO_U8S_LE (MS_OS_20_DESC_LEN - 0x0A - 0x08 - 0x08 - 0x14 ), U16_TO_U8S_LE (MS_OS_20_FEATURE_REG_PROPERTY ),
236+ U16_TO_U8S_LE (MS_OS_FEATURE_DESC_LEN - 0x08 - 0x14 ), U16_TO_U8S_LE (MS_OS_20_FEATURE_REG_PROPERTY ),
231237 U16_TO_U8S_LE (0x0007 ), U16_TO_U8S_LE (0x002A ), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16
232238 'D' , 0x00 , 'e' , 0x00 , 'v' , 0x00 , 'i' , 0x00 , 'c' , 0x00 , 'e' , 0x00 , 'I' , 0x00 , 'n' , 0x00 , 't' , 0x00 , 'e' , 0x00 ,
233239 'r' , 0x00 , 'f' , 0x00 , 'a' , 0x00 , 'c' , 0x00 , 'e' , 0x00 , 'G' , 0x00 , 'U' , 0x00 , 'I' , 0x00 , 'D' , 0x00 , 's' , 0x00 , 0x00 , 0x00 ,
@@ -236,7 +242,26 @@ uint8_t const desc_ms_os_20[] =
236242 '{' , 0x00 , 'C' , 0x00 , 'D' , 0x00 , 'B' , 0x00 , '3' , 0x00 , 'B' , 0x00 , '5' , 0x00 , 'A' , 0x00 , 'D' , 0x00 , '-' , 0x00 ,
237243 '2' , 0x00 , '9' , 0x00 , '3' , 0x00 , 'B' , 0x00 , '-' , 0x00 , '4' , 0x00 , '6' , 0x00 , '6' , 0x00 , '3' , 0x00 , '-' , 0x00 ,
238244 'A' , 0x00 , 'A' , 0x00 , '3' , 0x00 , '6' , 0x00 , '-' , 0x00 , '1' , 0x00 , 'A' , 0x00 , 'A' , 0x00 , 'E' , 0x00 , '4' , 0x00 ,
239- '6' , 0x00 , '4' , 0x00 , '6' , 0x00 , '3' , 0x00 , '7' , 0x00 , '7' , 0x00 , '6' , 0x00 , '}' , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
245+ '6' , 0x00 , '4' , 0x00 , '6' , 0x00 , '3' , 0x00 , '7' , 0x00 , '7' , 0x00 , '6' , 0x00 , '}' , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
246+
247+ // Function Subset header: length, type, first interface, reserved, subset length
248+ U16_TO_U8S_LE (0x0008 ), U16_TO_U8S_LE (MS_OS_20_SUBSET_HEADER_FUNCTION ), ITF_NUM_RESET , 0 , U16_TO_U8S_LE (MS_OS_FEATURE_DESC_LEN ),
249+
250+ // MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID
251+ U16_TO_U8S_LE (0x0014 ), U16_TO_U8S_LE (MS_OS_20_FEATURE_COMPATBLE_ID ), 'W' , 'I' , 'N' , 'U' , 'S' , 'B' , 0x00 , 0x00 ,
252+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // sub-compatible
253+
254+ // MS OS 2.0 Registry property descriptor: length, type
255+ U16_TO_U8S_LE (MS_OS_FEATURE_DESC_LEN - 0x08 - 0x14 ), U16_TO_U8S_LE (MS_OS_20_FEATURE_REG_PROPERTY ),
256+ U16_TO_U8S_LE (0x0007 ), U16_TO_U8S_LE (0x002A ), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16
257+ 'D' , 0x00 , 'e' , 0x00 , 'v' , 0x00 , 'i' , 0x00 , 'c' , 0x00 , 'e' , 0x00 , 'I' , 0x00 , 'n' , 0x00 , 't' , 0x00 , 'e' , 0x00 ,
258+ 'r' , 0x00 , 'f' , 0x00 , 'a' , 0x00 , 'c' , 0x00 , 'e' , 0x00 , 'G' , 0x00 , 'U' , 0x00 , 'I' , 0x00 , 'D' , 0x00 , 's' , 0x00 , 0x00 , 0x00 ,
259+ U16_TO_U8S_LE (0x0050 ), // wPropertyDataLength
260+ // bPropertyData "{BDB3B5AD-293B-4663-AA36-1AAE46463776}" as a UTF-16 string (b doesn't mean bytes)
261+ '{' , 0x00 , 'B' , 0x00 , 'D' , 0x00 , 'B' , 0x00 , '3' , 0x00 , 'B' , 0x00 , '5' , 0x00 , 'A' , 0x00 , 'D' , 0x00 , '-' , 0x00 ,
262+ '2' , 0x00 , '9' , 0x00 , '3' , 0x00 , 'B' , 0x00 , '-' , 0x00 , '4' , 0x00 , '6' , 0x00 , '6' , 0x00 , '3' , 0x00 , '-' , 0x00 ,
263+ 'A' , 0x00 , 'A' , 0x00 , '3' , 0x00 , '6' , 0x00 , '-' , 0x00 , '1' , 0x00 , 'A' , 0x00 , 'A' , 0x00 , 'E' , 0x00 , '4' , 0x00 ,
264+ '6' , 0x00 , '4' , 0x00 , '6' , 0x00 , '3' , 0x00 , '7' , 0x00 , '7' , 0x00 , '6' , 0x00 , '}' , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
240265};
241266
242267TU_VERIFY_STATIC (sizeof (desc_ms_os_20 ) == MS_OS_20_DESC_LEN , "Incorrect size" );
0 commit comments