1use crate::rcc::{APB1R1};
4use crate::stm32::{pwr, PWR};
5
6
7pub struct Pwr {
8 pub cr1: CR1,
9 pub cr2: CR2,
10 pub cr3: CR3,
11 pub cr4: CR4,
12}
13
14pub trait PwrExt {
16 fn constrain(self, _: &mut APB1R1) -> Pwr;
18}
19
20impl PwrExt for PWR {
21 fn constrain(self, apb1r1: &mut APB1R1) -> Pwr {
22 apb1r1.enr().modify(|_, w| w.pwren().set_bit());
24 Pwr {
25 cr1: CR1 { _0: () },
26 cr2: CR2 { _0: () },
27 cr3: CR3 { _0: () },
28 cr4: CR4 { _0: () },
29 }
30 }
31}
32
33pub struct CR1 {
35 _0: (),
36}
37
38impl CR1 {
39 #[allow(dead_code)]
41 pub(crate) fn reg(&mut self) -> &pwr::CR1 {
42 unsafe { &(*PWR::ptr()).cr1 }
44 }
45}
46pub struct CR2 {
48 _0: (),
49}
50
51impl CR2 {
52 #[allow(dead_code)]
54 pub(crate) fn reg(&mut self) -> &pwr::CR2 {
55 unsafe { &(*PWR::ptr()).cr2 }
57 }
58}
59pub struct CR3 {
61 _0: (),
62}
63
64impl CR3 {
65 #[allow(dead_code)]
67 pub(crate) fn reg(&mut self) -> &pwr::CR3 {
68 unsafe { &(*PWR::ptr()).cr3 }
70 }
71}
72pub struct CR4 {
74 _0: (),
75}
76
77impl CR4 {
78 #[allow(dead_code)]
80 pub(crate) fn reg(&mut self) -> &pwr::CR4 {
81 unsafe { &(*PWR::ptr()).cr4 }
83 }
84}