diff options
Diffstat (limited to 'cmd/sbc_harness/main.c')
-rw-r--r-- | cmd/sbc_harness/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 4683c72..9eacc81 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -21,6 +21,8 @@ #include "usb_keyboard.h" +#define ARRAY_LEN(arr) (sizeof(arr)/sizeof((arr)[0])) + COROUTINE hello_world_cr(void *_chan) { const char *msg = "Hello world!\n"; usb_keyboard_rpc_t *chan = _chan; @@ -50,8 +52,11 @@ struct { struct rp2040_hwspi dev_spi; struct w5500 dev_w5500; usb_keyboard_rpc_t keyboard_chan; + uint16_t usb_serial[sizeof(uint64_t)*2]; /* UTF-16 */ } globals; +const char *hexdig = "0123456789ABCDEF"; + COROUTINE init_cr(void *) { cr_begin(); @@ -86,7 +91,10 @@ COROUTINE init_cr(void *) { flash_id24[0], flash_id24[1], flash_id24[2], }})); - usb_common_earlyinit(); + static_assert(sizeof(flash_id64)*2 == ARRAY_LEN(globals.usb_serial)); + for (size_t i = 0; i < ARRAY_LEN(globals.usb_serial); i++) + globals.usb_serial[i] = hexdig[(flash_id64 >> ((sizeof(flash_id64)*8)-((i+1)*4))) & 0xF]; + usb_common_earlyinit(globals.usb_serial, sizeof(globals.usb_serial)); usb_keyboard_init(); usb_common_lateinit(); |