stm32f7x7_hal/
signature.rs1use core::str::from_utf8_unchecked;
6
7pub const VDDA_CALIB: u32 = 3300;
9
10macro_rules! define_ptr_type {
11 ($name: ident, $ptr: expr) => (
12 impl $name {
13 fn ptr() -> *const Self {
14 $ptr as *const _
15 }
16
17 pub fn get() -> &'static Self {
19 unsafe { &*Self::ptr() }
20 }
21 }
22 )
23}
24
25#[derive(Hash, Debug)]
27#[repr(C)]
28pub struct Uid {
29 x: u16,
30 y: u16,
31 waf_lot: [u8; 8],
32}
33define_ptr_type!(Uid, 0x1FF0_F420);
34
35impl Uid {
36 pub fn x(&self) -> u16 {
38 self.x
39 }
40
41 pub fn y(&self) -> u16 {
43 self.y
44 }
45
46 pub fn waf_num(&self) -> u8 {
48 self.waf_lot[0]
49 }
50
51 pub fn lot_num(&self) -> &str {
53 unsafe {
54 from_utf8_unchecked(&self.waf_lot[1..])
55 }
56 }
57}
58
59#[derive(Debug)]
61#[repr(C)]
62pub struct FlashSize(u16);
63define_ptr_type!(FlashSize, 0x1FF0_F442);
64
65impl FlashSize {
66 pub fn kilo_bytes(&self) -> u16 {
68 self.0
69 }
70
71 pub fn bytes(&self) -> usize {
73 usize::from(self.kilo_bytes()) * 1024
74 }
75}
76
77#[derive(Debug)]
79#[repr(C)]
80pub struct VrefCal(u16);
81define_ptr_type!(VrefCal, 0x1FF0_F44A);
82
83impl VrefCal {
84 pub fn read(&self) -> u16 {
86 self.0
87 }
88}
89
90#[derive(Debug)]
92#[repr(C)]
93pub struct VtempCal30(u16);
94define_ptr_type!(VtempCal30, 0x1FF0_F44C);
95
96impl VtempCal30 {
97 pub fn read(&self) -> u16 {
99 self.0
100 }
101}
102
103#[derive(Debug)]
105#[repr(C)]
106pub struct VtempCal110(u16);
107define_ptr_type!(VtempCal110, 0x1FF0_F44E);
108
109impl VtempCal110 {
110 pub fn read(&self) -> u16 {
112 self.0
113 }
114}
115