mirror of
https://github.com/rene-dev/stmbl.git
synced 2026-02-06 02:02:34 +08:00
switch usb device serial to unique cpu id
This commit is contained in:
@@ -53,11 +53,9 @@
|
|||||||
#define USB_SIZ_DEVICE_DESC 18
|
#define USB_SIZ_DEVICE_DESC 18
|
||||||
#define USB_SIZ_STRING_LANGID 4
|
#define USB_SIZ_STRING_LANGID 4
|
||||||
|
|
||||||
#define DEVICE_ID1 (0x1FFFF7E8)
|
#define DEVICE_ID ((__IO uint32_t *)0x1FFF7A10)
|
||||||
#define DEVICE_ID2 (0x1FFFF7EA)
|
|
||||||
#define DEVICE_ID3 (0x1FFFF7EC)
|
|
||||||
|
|
||||||
#define USB_SIZ_STRING_SERIAL 0x1A
|
#define USB_SIZ_STRING_SERIAL 0x1A
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|||||||
@@ -70,8 +70,8 @@
|
|||||||
#ifndef USBD_PRODUCT_STRING
|
#ifndef USBD_PRODUCT_STRING
|
||||||
#define USBD_PRODUCT_STRING "STM32 Virtual ComPort"
|
#define USBD_PRODUCT_STRING "STM32 Virtual ComPort"
|
||||||
#endif
|
#endif
|
||||||
#define USBD_CONFIGURATION_STRING "VCP Config"
|
#define USBD_CONFIGURATION_STRING "VCP Config"
|
||||||
#define USBD_INTERFACE_STRING "VCP Interface"
|
#define USBD_INTERFACE_STRING "VCP Interface"
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -301,18 +301,15 @@ uint8_t *USBD_USR_InterfaceStrDescriptor(uint8_t speed, uint16_t *length)
|
|||||||
*/
|
*/
|
||||||
static void Get_SerialNum(void)
|
static void Get_SerialNum(void)
|
||||||
{
|
{
|
||||||
uint32_t deviceserial0, deviceserial1, deviceserial2;
|
uint32_t deviceserial;
|
||||||
|
|
||||||
deviceserial0 = *(uint32_t*)DEVICE_ID1;
|
deviceserial = DEVICE_ID[0];
|
||||||
deviceserial1 = *(uint32_t*)DEVICE_ID2;
|
deviceserial += DEVICE_ID[2];
|
||||||
deviceserial2 = *(uint32_t*)DEVICE_ID3;
|
|
||||||
|
|
||||||
deviceserial0 += deviceserial2;
|
if (deviceserial != 0)
|
||||||
|
|
||||||
if (deviceserial0 != 0)
|
|
||||||
{
|
{
|
||||||
IntToUnicode (deviceserial0, &USBD_StringSerial[2] ,8);
|
IntToUnicode (deviceserial, &USBD_StringSerial[2] ,8);
|
||||||
IntToUnicode (deviceserial1, &USBD_StringSerial[18] ,4);
|
IntToUnicode (DEVICE_ID[1], &USBD_StringSerial[18] ,4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user