From b8147bcba2e8dfef419ba14053285bc9750dc319 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 30 May 2024 22:06:31 +0200 Subject: firmware: Rename from uid64 to eui64 The term EUI-64 is more commonly known (see Wikipedia about MAC addresses [1]). The term UID-64 was introduced because of ST documentation. [1]: https://en.wikipedia.org/wiki/MAC_address --- firmware/CMakeLists.txt | 2 +- firmware/boards/nucleo_wl55jc.overlay | 2 +- firmware/src/eui64.c | 42 +++++++++++++++++++++++++++++++++++ firmware/src/eui64.h | 8 +++++++ firmware/src/uid64.c | 42 ----------------------------------- firmware/src/uid64.h | 8 ------- 6 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 firmware/src/eui64.c create mode 100644 firmware/src/eui64.h delete mode 100644 firmware/src/uid64.c delete mode 100644 firmware/src/uid64.h (limited to 'firmware') diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index ad51a9d..8af1e4a 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -4,4 +4,4 @@ project(iot-core) target_sources(app PRIVATE src/main.c - src/uid64.c) + src/eui64.c) diff --git a/firmware/boards/nucleo_wl55jc.overlay b/firmware/boards/nucleo_wl55jc.overlay index b04f810..7125410 100644 --- a/firmware/boards/nucleo_wl55jc.overlay +++ b/firmware/boards/nucleo_wl55jc.overlay @@ -1,6 +1,6 @@ / { soc { - uid64: uid64@1fff7580 { + eui64: eui64@1fff7580 { reg = <0x1fff7580 0x8>; }; }; diff --git a/firmware/src/eui64.c b/firmware/src/eui64.c new file mode 100644 index 0000000..516ff84 --- /dev/null +++ b/firmware/src/eui64.c @@ -0,0 +1,42 @@ +#include +#include + +#include + +#include "eui64.h" + +#define UID64_NODE DT_NODELABEL(eui64) + +uint64_t eui64_get(void) { +#if DT_NODE_EXISTS(UID64_NODE) + return *(volatile uint64_t *) DT_REG_ADDR(UID64_NODE); +#else + return 0; +#endif +} + +void eui64_to_string(uint64_t uid, char *str) { + uint8_t *source = (uint8_t *)&uid + 7; + char *sink = str; + + for (unsigned int i = 0; i < 8; i++) { + /* delimiter */ + if (i > 0) { + *sink = ':'; + sink++; + } + + /* byte values */ + snprintf(sink, 3, "%02x", *source); + source--; + sink += 2; + } +} + +bool eui64_available(void) { +#if DT_NODE_EXISTS(UID64_NODE) + return true; +#else + return false; +#endif +} diff --git a/firmware/src/eui64.h b/firmware/src/eui64.h new file mode 100644 index 0000000..b7a8a6f --- /dev/null +++ b/firmware/src/eui64.h @@ -0,0 +1,8 @@ +#include + +/* 2 chars per byte (hex), 1 char per ':' delimiter and one char for \0 */ +#define UID64_STR_LEN (8*2 + 7*1 + 1) + +uint64_t eui64_get(void); +void eui64_to_string(uint64_t, char *str); +bool eui64_available(void); diff --git a/firmware/src/uid64.c b/firmware/src/uid64.c deleted file mode 100644 index afe5b33..0000000 --- a/firmware/src/uid64.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#include - -#include "uid64.h" - -#define UID64_NODE DT_NODELABEL(uid64) - -uint64_t uid64_get(void) { -#if DT_NODE_EXISTS(UID64_NODE) - return *(volatile uint64_t *) DT_REG_ADDR(UID64_NODE); -#else - return 0; -#endif -} - -void uid64_to_string(uint64_t uid, char *str) { - uint8_t *source = (uint8_t *)&uid + 7; - char *sink = str; - - for (unsigned int i = 0; i < 8; i++) { - /* delimiter */ - if (i > 0) { - *sink = ':'; - sink++; - } - - /* byte values */ - snprintf(sink, 3, "%02x", *source); - source--; - sink += 2; - } -} - -bool uid64_available(void) { -#if DT_NODE_EXISTS(UID64_NODE) - return true; -#else - return false; -#endif -} diff --git a/firmware/src/uid64.h b/firmware/src/uid64.h deleted file mode 100644 index cd3fb13..0000000 --- a/firmware/src/uid64.h +++ /dev/null @@ -1,8 +0,0 @@ -#include - -/* 2 chars per byte (hex), 1 char per ':' delimiter and one char for \0 */ -#define UID64_STR_LEN (8*2 + 7*1 + 1) - -uint64_t uid64_get(void); -void uid64_to_string(uint64_t, char *str); -bool uid64_available(void); -- cgit v1.2.3-70-g09d2