diff options
| author | Ha Thach <[email protected]> | 2023-11-02 20:56:27 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-02 20:56:27 +0700 |
| commit | 3af44089bc52edc0349c4879e24ae9f4f8ea3f73 (patch) | |
| tree | a1d275136344b8098984639257a6f5d24cc7dce8 | |
| parent | b28d121a54bce9ce3a33b0ece6260560903702d4 (diff) | |
| parent | 89475fcf26ccf0441faac1c5934abdad5f331488 (diff) | |
Merge pull request #2308 from hathach/add-u5-uid
add unique id for u5, also allow to build with OPT_OS_CUSTOM
| -rw-r--r-- | hw/bsp/board_api.h | 3 | ||||
| -rw-r--r-- | hw/bsp/stm32u5/family.c | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h index a7dcabfcc..404509a28 100644 --- a/hw/bsp/board_api.h +++ b/hw/bsp/board_api.h @@ -97,6 +97,9 @@ static inline uint32_t board_millis(void) { return (((uint64_t)rt_tick_get()) * 1000 / RT_TICK_PER_SECOND); } +#elif CFG_TUSB_OS == OPT_OS_CUSTOM +// Implement your own board_millis() in any of .c file + #else #error "board_millis() is not implemented for this OS" #endif diff --git a/hw/bsp/stm32u5/family.c b/hw/bsp/stm32u5/family.c index d2287e9fc..d7258a717 100644 --- a/hw/bsp/stm32u5/family.c +++ b/hw/bsp/stm32u5/family.c @@ -210,6 +210,19 @@ uint32_t board_button_read(void) { return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN); } +size_t board_get_unique_id(uint8_t id[], size_t max_len) { + (void) max_len; + volatile uint32_t *stm32_uuid = (volatile uint32_t *) UID_BASE; + uint32_t *id32 = (uint32_t *) (uintptr_t) id; + uint8_t const len = 12; + + id32[0] = stm32_uuid[0]; + id32[1] = stm32_uuid[1]; + id32[2] = stm32_uuid[2]; + + return len; +} + int board_uart_read(uint8_t *buf, int len) { (void) buf; (void) len; |
