diff options
| -rw-r--r-- | hw/bsp/board.c | 12 | ||||
| -rw-r--r-- | hw/bsp/board_api.h | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 1ba5a1b9d..c6982ed8f 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -141,6 +141,18 @@ __strong_reference(stdin, stderr); #endif //--------------------------------------------------------------------+ +// Weak board API (to be optionally implemented by board) +//--------------------------------------------------------------------+ +TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len) { + (void) max_len; + // fixed serial string is 01234567889ABCDEF + uint32_t* uid32 = (uint32_t*) (uintptr_t)id; + uid32[0] = 0x67452301; + uid32[1] = 0xEFCDAB89; + return 8; +} + +//--------------------------------------------------------------------+ // Board API //--------------------------------------------------------------------+ int board_getchar(void) { diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h index 111829b4f..5ecd7797a 100644 --- a/hw/bsp/board_api.h +++ b/hw/bsp/board_api.h @@ -152,15 +152,7 @@ static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars size_t uid_len; // TODO work with make, but not working with esp32s3 cmake - if ( board_get_unique_id ) { - uid_len = board_get_unique_id(uid, sizeof(uid)); - }else { - // fixed serial string is 01234567889ABCDEF - uint32_t* uid32 = (uint32_t*) (uintptr_t) uid; - uid32[0] = 0x67452301; - uid32[1] = 0xEFCDAB89; - uid_len = 8; - } + uid_len = board_get_unique_id(uid, sizeof(uid)); if ( uid_len > max_chars / 2 ) uid_len = max_chars / 2; |
