diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-11-25 00:25:57 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-11-25 19:30:31 -0500 |
commit | 8f6efe5a7b8a830b6cd17b7c378fc4f2fa92f069 (patch) | |
tree | 38e190a9bf069c5c2690d33cda1aa41c35db6abf /src/stm32/chipid.c | |
parent | f76cb92b15afbb5022696bf20c7a0172e3c6f834 (diff) | |
download | kutter-8f6efe5a7b8a830b6cd17b7c378fc4f2fa92f069.tar.gz kutter-8f6efe5a7b8a830b6cd17b7c378fc4f2fa92f069.tar.xz kutter-8f6efe5a7b8a830b6cd17b7c378fc4f2fa92f069.zip |
stm32: Enable chipid as usb serial number
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/chipid.c')
-rw-r--r-- | src/stm32/chipid.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/stm32/chipid.c b/src/stm32/chipid.c new file mode 100644 index 00000000..73e27503 --- /dev/null +++ b/src/stm32/chipid.c @@ -0,0 +1,33 @@ +// Support for extracting the hardware chip id on stm32 +// +// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net> +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include "generic/usb_cdc.h" // usb_fill_serial +#include "generic/usbstd.h" // usb_string_descriptor +#include "internal.h" // UID_BASE +#include "sched.h" // DECL_INIT + +#define CHIP_UID_LEN 12 + +static struct { + struct usb_string_descriptor desc; + uint16_t data[CHIP_UID_LEN * 2]; +} cdc_chipid; + +struct usb_string_descriptor * +usbserial_get_serialid(void) +{ + return &cdc_chipid.desc; +} + +void +chipid_init(void) +{ + if (!CONFIG_USB_SERIAL_NUMBER_CHIPID) + return; + usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data) + , (void*)UID_BASE); +} +DECL_INIT(chipid_init); |