Skip to content

Instantly share code, notes, and snippets.

@MightyPork
Created November 18, 2017 23:53
Show Gist options
  • Save MightyPork/633afc3173dd1b3eb5c9031f9265e14e to your computer and use it in GitHub Desktop.
Save MightyPork/633afc3173dd1b3eb5c9031f9265e14e to your computer and use it in GitHub Desktop.
#include <inttypes.h>
#include <stdlib.h>
#include "stm32f1xx_ll_utils.h"
/**
* @brief USBD_FS_SerialStrDescriptor
* return the serial number string descriptor
* @param speed : current device speed
* @param length : pointer to data length variable
* @retval pointer to descriptor buffer
*/
uint8_t * USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length)
{
char buff[25];
sprintf(buff, "%08"PRIX32"%08"PRIX32"%08"PRIX32,
LL_GetUID_Word0(),
LL_GetUID_Word1(),
LL_GetUID_Word2()
);
USBD_GetString ((uint8_t *) &buff[0], USBD_StrDesc, length);
return USBD_StrDesc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment