File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
cores/arduino/Adafruit_TinyUSB_Core Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ static void usb_hardware_init(void)
8484
8585uint8_t load_serial_number (uint16_t * serial_str)
8686{
87+ enum { SERIAL_BYTE_LEN = 16 };
88+
8789#ifdef __SAMD51__
8890 uint32_t * id_addresses[4 ] = {(uint32_t *) 0x008061FC , (uint32_t *) 0x00806010 ,
8991 (uint32_t *) 0x00806014 , (uint32_t *) 0x00806018 };
@@ -93,7 +95,8 @@ uint8_t load_serial_number(uint16_t* serial_str)
9395
9496#endif
9597
96- uint8_t raw_id[8 ];
98+ uint8_t raw_id[SERIAL_BYTE_LEN];
99+
97100 for (int i=0 ; i<4 ; i++) {
98101 for (int k=0 ; k<4 ; k++) {
99102 raw_id[4 * i + k] = (*(id_addresses[i]) >> k * 8 ) & 0xff ;
@@ -110,7 +113,7 @@ uint8_t load_serial_number(uint16_t* serial_str)
110113 }
111114 }
112115
113- return 16 ;
116+ return sizeof (raw_id)* 2 ;
114117}
115118
116119void Adafruit_TinyUSB_Core_init (void )
Original file line number Diff line number Diff line change @@ -164,7 +164,8 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
164164 return USBDevice._desc_cfg ;
165165}
166166
167- static uint16_t _desc_str[32 ];
167+ // up to 32 unicode characters (header make it 33)
168+ static uint16_t _desc_str[33 ];
168169
169170// Invoked when received GET STRING DESCRIPTOR request
170171// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
@@ -187,7 +188,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
187188
188189 // cap at max char
189190 chr_count = strlen (str);
190- if ( chr_count > 31 ) chr_count = 31 ;
191+ if ( chr_count > 32 ) chr_count = 32 ;
191192
192193 for (uint8_t i=0 ; i<chr_count; i++)
193194 {
You can’t perform that action at this time.
0 commit comments