23
23
*
24
24
*/
25
25
26
+ #include "pico/unique_id.h"
26
27
#include "tusb.h"
27
28
#include "usb_descriptors.h"
28
29
@@ -177,13 +178,16 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
177
178
// String Descriptors
178
179
//--------------------------------------------------------------------+
179
180
181
+ // buffer to hold flash ID
182
+ char serial [2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1 ];
183
+
180
184
// array of pointer to string descriptors
181
185
char const * string_desc_arr [] =
182
186
{
183
187
(const char []) { 0x09 , 0x04 }, // 0: is supported language is English (0x0409)
184
188
"TinyUSB" , // 1: Manufacturer
185
189
"TinyUSB Device" , // 2: Product
186
- "123456" , // 3: Serials, should use chip ID
190
+ serial , // 3: Serials, uses the flash ID
187
191
};
188
192
189
193
static uint16_t _desc_str [32 ];
@@ -205,6 +209,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
205
209
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
206
210
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
207
211
212
+ if (index == 3 ) pico_get_unique_board_id_string (serial , sizeof (serial ));
213
+
208
214
if ( !(index < sizeof (string_desc_arr )/sizeof (string_desc_arr [0 ])) ) return NULL ;
209
215
210
216
const char * str = string_desc_arr [index ];
0 commit comments