@@ -244,26 +244,25 @@ bool USBDeviceClass::sendDescriptor(USBSetup &setup)
244244 }
245245 else if (setup.wValueL == ISERIAL) {
246246#ifdef PLUGGABLE_USB_ENABLED
247- #if defined(__SAMD51__)
248- char name[ISERIAL_MAX_LEN];
249- PluggableUSB ().getShortName (name);
250- return sendStringDescriptor ((uint8_t *)name, setup.wLength );
251- #else
247+ #ifdef __SAMD51__
248+ #define SERIAL_NUMBER_WORD_0 *(volatile uint32_t *)(0x008061FC )
249+ #define SERIAL_NUMBER_WORD_1 *(volatile uint32_t *)(0x00806010 )
250+ #define SERIAL_NUMBER_WORD_2 *(volatile uint32_t *)(0x00806014 )
251+ #define SERIAL_NUMBER_WORD_3 *(volatile uint32_t *)(0x00806018 )
252+ #else // samd21
252253 // from section 9.3.3 of the datasheet
253254 #define SERIAL_NUMBER_WORD_0 *(volatile uint32_t *)(0x0080A00C )
254255 #define SERIAL_NUMBER_WORD_1 *(volatile uint32_t *)(0x0080A040 )
255256 #define SERIAL_NUMBER_WORD_2 *(volatile uint32_t *)(0x0080A044 )
256257 #define SERIAL_NUMBER_WORD_3 *(volatile uint32_t *)(0x0080A048 )
257-
258+ # endif
258259 char name[ISERIAL_MAX_LEN];
259260 utox8 (SERIAL_NUMBER_WORD_0, &name[0 ]);
260261 utox8 (SERIAL_NUMBER_WORD_1, &name[8 ]);
261262 utox8 (SERIAL_NUMBER_WORD_2, &name[16 ]);
262263 utox8 (SERIAL_NUMBER_WORD_3, &name[24 ]);
263-
264- PluggableUSB ().getShortName (&name[32 ]);
264+ name[32 ] = ' \0 ' ;
265265 return sendStringDescriptor ((uint8_t *)name, setup.wLength );
266- #endif
267266#endif
268267 }
269268 else {
0 commit comments