added rp2040 unique id (requires submodule update)

This commit is contained in:
Peter Lawrence 2021-02-15 20:19:13 -06:00
parent 7f1af42e27
commit 26039d84c7
4 changed files with 27 additions and 3 deletions

View File

@ -41,7 +41,7 @@ if(FAMILY STREQUAL "rp2040")
target_compile_definitions(${PROJECT} PUBLIC
)
target_link_libraries(${PROJECT} pico_stdlib)
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration pico_unique_id)
pico_add_extra_outputs(${PROJECT})

25
bsp/rp2040/unique.h Normal file
View File

@ -0,0 +1,25 @@
#include <stdint.h>
#include "pico/stdlib.h"
#include "pico/unique_id.h"
#include "tusb.h"
static uint8_t get_unique_id(uint16_t *desc_str)
{
pico_unique_board_id_t uid;
uint8_t chr_count = 0;
pico_get_unique_board_id(&uid);
for (int byte = 0; byte < TU_ARRAY_SIZE(uid.id); byte++)
{
uint8_t tmp = uid.id[byte];
for (int digit = 0; digit < 2; digit++)
{
desc_str[chr_count++] = "0123456789ABCDEF"[tmp & 0xf];
tmp >>= 4;
}
}
return chr_count;
}

View File

@ -1,7 +1,6 @@
#include <stdint.h>
#include "tusb.h"
static uint8_t get_unique_id(uint16_t *desc_str)
{
const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/

@ -1 +1 @@
Subproject commit 666a851a0745ea32ac57e288e3043a6b93aa87e1
Subproject commit 09868434cd9f53394350cce682333ada97f796c3