7
7
#include <tusb.h>
8
8
#include <bsp/board_api.h>
9
9
10
+ #include "pico/usb_reset_interface.h"
11
+
10
12
// set some example Vendor and Product ID
11
13
// the board will use to identify at the host
12
14
#define _PID_MAP (itf , n ) ( (CFG_TUD_##itf) << (n) )
13
15
#define CDC_EXAMPLE_VID 0xCafe
14
16
// use _PID_MAP to generate unique PID for each interface
15
17
#define CDC_EXAMPLE_PID (0x4000 | _PID_MAP(CDC, 0))
16
18
// set USB 2.0
17
- #define CDC_EXAMPLE_BCD 0x0200
19
+ #define CDC_EXAMPLE_BCD 0x0210
20
+
21
+ // String descriptors referenced with .i... in the descriptor tables
22
+
23
+ enum {
24
+ STRID_LANGID = 0 , // 0: supported language ID
25
+ STRID_MANUFACTURER , // 1: Manufacturer
26
+ STRID_PRODUCT , // 2: Product
27
+ STRID_SERIAL , // 3: Serials
28
+ STRID_CDC_0 , // 4: CDC Interface 0
29
+ STRID_CDC_1 , // 5: CDC Interface 1
30
+ STRID_RPI_RESET , // 6: Reset Interface
31
+ };
32
+
33
+ // array of pointer to string descriptors
34
+ char const * string_desc_arr [] = {
35
+ // switched because board is little endian
36
+ (const char []) { 0x09 , 0x04 }, // 0: supported language is English (0x0409)
37
+ "Raspberry Pi" , // 1: Manufacturer
38
+ "Pico (2)" , // 2: Product
39
+ NULL , // 3: Serials (null so it uses unique ID if available)
40
+ "Pico SDK stdio" , // 4: CDC Interface 0
41
+ "Custom CDC" , // 5: CDC Interface 1,
42
+ "Reset" // 6: Reset Interface
43
+ };
18
44
19
45
// defines a descriptor that will be communicated to the host
20
46
tusb_desc_device_t const desc_device = {
@@ -32,9 +58,9 @@ tusb_desc_device_t const desc_device = {
32
58
.idProduct = CDC_EXAMPLE_PID ,
33
59
.bcdDevice = 0x0100 , // Device release number
34
60
35
- .iManufacturer = 0x01 , // Index of manufacturer string
36
- .iProduct = 0x02 , // Index of product string
37
- .iSerialNumber = 0x03 , // Index of serial number string
61
+ .iManufacturer = STRID_MANUFACTURER , // Index of manufacturer string
62
+ .iProduct = STRID_PRODUCT , // Index of product string
63
+ .iSerialNumber = STRID_SERIAL , // Index of serial number string
38
64
39
65
.bNumConfigurations = 0x01 // 1 configuration
40
66
};
@@ -47,11 +73,14 @@ enum {
47
73
ITF_NUM_CDC_0_DATA ,
48
74
ITF_NUM_CDC_1 ,
49
75
ITF_NUM_CDC_1_DATA ,
76
+ ITF_NUM_RPI_RESET ,
50
77
ITF_NUM_TOTAL
51
78
};
52
79
80
+ static_assert (ITF_NUM_RPI_RESET == PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF , "ITF_NUM_RPI_RESET must be equal to the PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF set in CMakeLists.txt" );
81
+
53
82
// total length of configuration descriptor
54
- #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN)
83
+ #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + TUD_RPI_RESET_DESC_LEN )
55
84
56
85
// define endpoint numbers
57
86
#define EPNUM_CDC_0_NOTIF 0x81 // notification endpoint for CDC 0
@@ -68,14 +97,17 @@ uint8_t const desc_configuration[] = {
68
97
TUD_CONFIG_DESCRIPTOR (1 , ITF_NUM_TOTAL , 0 , CONFIG_TOTAL_LEN , 0x80 , 100 ),
69
98
70
99
// CDC 0: Communication Interface - TODO: get 64 from tusb_config.h
71
- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 64 ),
100
+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , STRID_CDC_0 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 64 ),
72
101
// CDC 0: Data Interface
73
102
//TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0_DATA, 4, 0x01, 0x02),
74
103
75
104
// CDC 1: Communication Interface - TODO: get 64 from tusb_config.h
76
- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 4 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 64 ),
105
+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , STRID_CDC_1 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 64 ),
77
106
// CDC 1: Data Interface
78
107
//TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_1_DATA, 4, 0x03, 0x04),
108
+
109
+ // RPi Reset Interface
110
+ TUD_RPI_RESET_DESCRIPTOR (ITF_NUM_RPI_RESET , STRID_RPI_RESET ),
79
111
};
80
112
81
113
// called when host requests to get configuration descriptor
@@ -99,29 +131,6 @@ tusb_desc_device_qualifier_t const desc_device_qualifier = {
99
131
// called when host requests to get device qualifier descriptor
100
132
uint8_t const * tud_descriptor_device_qualifier_cb (void );
101
133
102
- // String descriptors referenced with .i... in the descriptor tables
103
-
104
- enum {
105
- STRID_LANGID = 0 , // 0: supported language ID
106
- STRID_MANUFACTURER , // 1: Manufacturer
107
- STRID_PRODUCT , // 2: Product
108
- STRID_SERIAL , // 3: Serials
109
- STRID_CDC_0 , // 4: CDC Interface 0
110
- STRID_CDC_1 , // 5: CDC Interface 1
111
- };
112
-
113
- // array of pointer to string descriptors
114
- char const * string_desc_arr [] = {
115
- // switched because board is little endian
116
- (const char []) { 0x09 , 0x04 }, // 0: supported language is English (0x0409)
117
- "Raspberry Pi" , // 1: Manufacturer
118
- "Pico (2)" , // 2: Product
119
- NULL , // 3: Serials (null so it uses unique ID if available)
120
- "Pico SDK stdio" // 4: CDC Interface 0
121
- "Custom CDC" , // 5: CDC Interface 1,
122
- "RPiReset" // 6: Reset Interface
123
- };
124
-
125
134
// buffer to hold the string descriptor during the request | plus 1 for the null terminator
126
135
static uint16_t _desc_str [32 + 1 ];
127
136
0 commit comments