stm32g473_hal_oppe/
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, 0x1FFF_7590);
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 { from_utf8_unchecked(&self.waf_lot[1..]) }
54 }
55}
56
57#[derive(Debug)]
59#[repr(C)]
60pub struct FlashSize(u16);
61define_ptr_type!(FlashSize, 0x1FFF_75E0);
62
63impl FlashSize {
64 pub fn kilo_bytes(&self) -> u16 {
66 self.0
67 }
68
69 pub fn bytes(&self) -> usize {
71 usize::from(self.kilo_bytes()) * 1024
72 }
73}
74
75#[derive(Debug)]
77#[repr(C)]
78pub struct VrefCal(u16);
79define_ptr_type!(VrefCal, 0x1FFF_75AA);
80
81impl VrefCal {
82 pub fn read(&self) -> u16 {
84 self.0
85 }
86}
87
88#[derive(Debug)]
90#[repr(C)]
91pub struct VtempCal30(u16);
92define_ptr_type!(VtempCal30, 0x1FFF_75A8);
93
94impl VtempCal30 {
95 pub fn read(&self) -> u16 {
97 self.0
98 }
99}
100
101#[derive(Debug)]
103#[repr(C)]
104pub struct VtempCal110(u16);
105define_ptr_type!(VtempCal110, 0x1FFF_75CA);
106
107impl VtempCal110 {
108 pub fn read(&self) -> u16 {
110 self.0
111 }
112}