Last active
January 7, 2023 02:30
-
-
Save cctsao1008/4253a3e1de9c62f67692b080a4449e76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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