DragonProbe/bsp/default/unique.c

37 lines
727 B
C
Raw Normal View History

2021-06-28 23:03:02 +00:00
// vim: set et:
2021-02-15 23:51:48 +00:00
#include <stdint.h>
2021-06-14 00:01:35 +00:00
#include "util.h"
static const char uniqueid[] = "00000000"; /* placeholder */
2021-02-15 23:51:48 +00:00
uint8_t get_unique_id_u8(uint8_t *desc_str) {
uint8_t chr_count = 0;
2021-02-15 23:51:48 +00:00
for (size_t byte = 0; byte < TU_ARRAY_SIZE(uniqueid); byte++) {
uint8_t tmp = uniqueid[byte];
for (int digit = 0; digit < 2; digit++) {
desc_str[chr_count++] = nyb2hex(tmp & 0xf);
tmp >>= 4;
}
}
2021-02-15 23:51:48 +00:00
return chr_count;
}
uint8_t get_unique_id_u16(uint16_t *desc_str) {
uint8_t chr_count = 0;
for (size_t byte = 0; byte < TU_ARRAY_SIZE(uniqueid); byte++) {
uint8_t tmp = uniqueid[byte];
for (int digit = 0; digit < 2; digit++) {
desc_str[chr_count++] = nyb2hex(tmp & 0xf);
tmp >>= 4;
}
}
return chr_count;
2021-02-15 23:51:48 +00:00
}