Added correct serial number to usb device
This commit is contained in:
parent
2d0a54eccc
commit
77394816df
|
@ -133,11 +133,22 @@ mod app {
|
|||
|
||||
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();
|
||||
unsafe {
|
||||
write!(SERIAL, "{}{:x}{:x}", uid.lot_num(), uid.x(), uid.y()).unwrap();
|
||||
write!(SERIAL, "{:X}", serial).unwrap();
|
||||
}
|
||||
|
||||
let usb_dev = unsafe {
|
||||
|
|
Loading…
Reference in a new issue