diff --git a/CMakeLists.txt b/CMakeLists.txt index f3f0d5f..c779216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/bsp/rp2040/unique.h b/bsp/rp2040/unique.h new file mode 100644 index 0000000..6327d53 --- /dev/null +++ b/bsp/rp2040/unique.h @@ -0,0 +1,25 @@ +#include +#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; +} + diff --git a/bsp/stm32f072disco/unique.h b/bsp/stm32f072disco/unique.h index 6200ddf..90f5df2 100644 --- a/bsp/stm32f072disco/unique.h +++ b/bsp/stm32f072disco/unique.h @@ -1,7 +1,6 @@ #include #include "tusb.h" - static uint8_t get_unique_id(uint16_t *desc_str) { const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/ diff --git a/tinyusb b/tinyusb index 666a851..0986843 160000 --- a/tinyusb +++ b/tinyusb @@ -1 +1 @@ -Subproject commit 666a851a0745ea32ac57e288e3043a6b93aa87e1 +Subproject commit 09868434cd9f53394350cce682333ada97f796c3