Added correct serial number to usb device
This commit is contained in:
parent
1c4714381b
commit
77eebdf795
|
@ -133,11 +133,22 @@ mod app {
|
||||||
|
|
||||||
let usb_serial = usbd_serial::SerialPort::new(unsafe { USB_BUS.as_ref().unwrap() });
|
let usb_serial = usbd_serial::SerialPort::new(unsafe { USB_BUS.as_ref().unwrap() });
|
||||||
|
|
||||||
let uid = signature::Uid::get();
|
let serial = unsafe {
|
||||||
|
let u_id0 = 0x1FFF_7A10 as *const u32;
|
||||||
|
let u_id2 = 0x1FFF_7A18 as *const u32;
|
||||||
|
|
||||||
|
defmt::debug!("UID0: {:x}", u_id0.read());
|
||||||
|
defmt::debug!("UID2: {:x}", u_id2.read());
|
||||||
|
|
||||||
|
// See https://community.st.com/t5/stm32-mcus-products/usb-bootloader-serial-number/td-p/432148
|
||||||
|
(u_id0.read() as u64 + u_id2.read() as u64) << 16
|
||||||
|
| (u_id2.read() as u64 & 0xFF00) >> 8
|
||||||
|
| (u_id2.read() as u64 & 0x00FF) << 8
|
||||||
|
};
|
||||||
|
|
||||||
static mut SERIAL: String<16> = String::new();
|
static mut SERIAL: String<16> = String::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
write!(SERIAL, "{}{:x}{:x}", uid.lot_num(), uid.x(), uid.y()).unwrap();
|
write!(SERIAL, "{:X}", serial).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let usb_dev = unsafe {
|
let usb_dev = unsafe {
|
||||||
|
|
Loading…
Reference in a new issue