diff --git a/libraries/USBDevice/inc/usbd_desc.h b/libraries/USBDevice/inc/usbd_desc.h index aa832b2772..a1b84608fb 100644 --- a/libraries/USBDevice/inc/usbd_desc.h +++ b/libraries/USBDevice/inc/usbd_desc.h @@ -28,7 +28,18 @@ /* Exported constants --------------------------------------------------------*/ #define DEVICE_ID1 (UID_BASE) #define DEVICE_ID2 (UID_BASE + 0x4U) - #define DEVICE_ID3 (UID_BASE + 0x8U) + /* + * On STM32L0 and STM32L1 the three unique-ID words are NOT contiguous: + * the reference manuals place bits 95:64 at offset 0x14, not 0x08 + * (RM0376/RM0377/RM0367/RM0451 "Unique device ID registers (96 bits)", + * and RM0038 for STM32L1). UID_BASE + 0x8U is a reserved location there. + * ST's own HAL_GetUIDw2() already uses 0x14U for these two families. + */ + #if defined(STM32L0xx) || defined(STM32L1xx) + #define DEVICE_ID3 (UID_BASE + 0x14U) + #else + #define DEVICE_ID3 (UID_BASE + 0x8U) + #endif /* * USB Billboard Class USER string desc Defines Template