2021-02-15 23:51:48 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "tusb.h"
|
|
|
|
|
2021-06-13 23:32:21 +00:00
|
|
|
static inline char nyb2hex(int x) {
|
|
|
|
if (x < 0xa) return '0'+x;
|
|
|
|
else return 'A'+x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
|
|
|
const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/
|
|
|
|
uint32_t tmp = 0;
|
|
|
|
uint8_t chr_count = 0;
|
|
|
|
|
|
|
|
for (int digit = 0; digit < 24; digit++) {
|
|
|
|
if (0 == (digit & 7)) tmp = *idpnt++;
|
|
|
|
desc_str[chr_count++] = nyb2hex(tmp & 0xf);
|
|
|
|
tmp >>= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return chr_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
|
|
|
const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/
|
|
|
|
uint32_t tmp = 0;
|
|
|
|
uint8_t chr_count = 0;
|
|
|
|
|
|
|
|
for (int digit = 0; digit < 24; digit++) {
|
|
|
|
if (0 == (digit & 7)) tmp = *idpnt++;
|
|
|
|
desc_str[chr_count++] = nyb2hex(tmp & 0xf);
|
|
|
|
tmp >>= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return chr_count;
|
2021-02-15 23:51:48 +00:00
|
|
|
}
|
|
|
|
|