Skip to content

Commit

Permalink
switch usb device serial to unique cpu id
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Reinecke committed Jan 24, 2016
1 parent 13fe7e6 commit 80462e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
6 changes: 2 additions & 4 deletions lib/STM32_USB_Device_VCP-1.2.0/inc/usbd_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
#define USB_SIZ_DEVICE_DESC 18
#define USB_SIZ_STRING_LANGID 4

#define DEVICE_ID1 (0x1FFFF7E8)
#define DEVICE_ID2 (0x1FFFF7EA)
#define DEVICE_ID3 (0x1FFFF7EC)
#define DEVICE_ID ((__IO uint32_t *)0x1FFF7A10)

#define USB_SIZ_STRING_SERIAL 0x1A
#define USB_SIZ_STRING_SERIAL 0x1A

/**
* @}
Expand Down
19 changes: 8 additions & 11 deletions lib/STM32_USB_Device_VCP-1.2.0/src/usbd_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
#ifndef USBD_PRODUCT_STRING
#define USBD_PRODUCT_STRING "STM32 Virtual ComPort"
#endif
#define USBD_CONFIGURATION_STRING "VCP Config"
#define USBD_INTERFACE_STRING "VCP Interface"
#define USBD_CONFIGURATION_STRING "VCP Config"
#define USBD_INTERFACE_STRING "VCP Interface"
/**
* @}
*/
Expand Down Expand Up @@ -301,18 +301,15 @@ uint8_t *USBD_USR_InterfaceStrDescriptor(uint8_t speed, uint16_t *length)
*/
static void Get_SerialNum(void)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;
uint32_t deviceserial;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;
deviceserial = DEVICE_ID[0];
deviceserial += DEVICE_ID[2];

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
if (deviceserial != 0)
{
IntToUnicode (deviceserial0, &USBD_StringSerial[2] ,8);
IntToUnicode (deviceserial1, &USBD_StringSerial[18] ,4);
IntToUnicode (deviceserial, &USBD_StringSerial[2] ,8);
IntToUnicode (DEVICE_ID[1], &USBD_StringSerial[18] ,4);
}
}

Expand Down

0 comments on commit 80462e3

Please sign in to comment.