Skip to content

Commit 23fd362

Browse files
committed
USBCore: Read the SAMD51 serial number
Export the unique hardware serial number from the SAMD51 MCU to the USB device descriptor. Remove the concatenation of the USB class device string, it is superfluous, and an USB interface property should not become a part of the USB device property. Tested on SAMD21 and SAMD51: Before: SAMD21: 10BD8E4051504C3750202020FF0B1410MIDI SAMD51: MIDI After: SAMD21: 10BD8E4051504C3750202020FF0B1410 SAMD51: AAFC165853574E514D202020FF083C44
1 parent 5c60a5a commit 23fd362

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

cores/arduino/USB/USBCore.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)