Skip to content

Instantly share code, notes, and snippets.

@cctsao1008
Last active January 7, 2023 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cctsao1008/4253a3e1de9c62f67692b080a4449e76 to your computer and use it in GitHub Desktop.
Save cctsao1008/4253a3e1de9c62f67692b080a4449e76 to your computer and use it in GitHub Desktop.
char CHIP_UID[24 + 1] =
{ 0 };
void covert_uid_to_ascii_serial()
{
uint32_t (*func[3])(void) =
{ LL_GetUID_Word0, LL_GetUID_Word1, LL_GetUID_Word2
};
for (uint16_t j = 0; j < 3; j++)
{
uint32_t uid = (*func[j])();
for (uint16_t i = 0; i < 8; i++)
{
uint8_t temp = (uid >> (i << 2)) & 0xF;
if (temp > 9)
temp = temp + 'A';
else
temp = temp + '0';
CHIP_UID[i + j * 8] = temp;
}
}
CHIP_UID[24] = '\0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment