1use crate::rcc::{Enable, APB1R1};
4use crate::stm32::{pwr, PWR};
5
6pub struct Pwr {
7 pub cr1: CR1,
8 pub cr2: CR2,
9 pub cr3: CR3,
10 pub cr4: CR4,
11}
12
13pub trait PwrExt {
15 fn constrain(self, _: &mut APB1R1) -> Pwr;
17}
18
19impl PwrExt for PWR {
20 fn constrain(self, apb1r1: &mut APB1R1) -> Pwr {
21 PWR::enable(apb1r1);
23 Pwr {
24 cr1: CR1 { _0: () },
25 cr2: CR2 { _0: () },
26 cr3: CR3 { _0: () },
27 cr4: CR4 { _0: () },
28 }
29 }
30}
31
32pub struct CR1 {
34 _0: (),
35}
36
37impl CR1 {
38 #[allow(dead_code)]
40 pub(crate) fn reg(&mut self) -> &pwr::CR1 {
41 unsafe { &(*PWR::ptr()).cr1 }
43 }
44}
45pub struct CR2 {
47 _0: (),
48}
49
50impl CR2 {
51 #[allow(dead_code)]
53 pub(crate) fn reg(&mut self) -> &pwr::CR2 {
54 unsafe { &(*PWR::ptr()).cr2 }
56 }
57}
58pub struct CR3 {
60 _0: (),
61}
62
63impl CR3 {
64 #[allow(dead_code)]
66 pub(crate) fn reg(&mut self) -> &pwr::CR3 {
67 unsafe { &(*PWR::ptr()).cr3 }
69 }
70}
71pub struct CR4 {
73 _0: (),
74}
75
76impl CR4 {
77 #[allow(dead_code)]
79 pub(crate) fn reg(&mut self) -> &pwr::CR4 {
80 unsafe { &(*PWR::ptr()).cr4 }
82 }
83}