stm32f1/stm32f107/sdio/
power.rs1pub type R = crate::R<POWERrs>;
3pub type W = crate::W<POWERrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u8)]
11pub enum PWRCTRL {
12 PowerOff = 0,
14 PowerOn = 3,
16}
17impl From<PWRCTRL> for u8 {
18 #[inline(always)]
19 fn from(variant: PWRCTRL) -> Self {
20 variant as _
21 }
22}
23impl crate::FieldSpec for PWRCTRL {
24 type Ux = u8;
25}
26impl crate::IsEnum for PWRCTRL {}
27pub type PWRCTRL_R = crate::FieldReader<PWRCTRL>;
29impl PWRCTRL_R {
30 #[inline(always)]
32 pub const fn variant(&self) -> Option<PWRCTRL> {
33 match self.bits {
34 0 => Some(PWRCTRL::PowerOff),
35 3 => Some(PWRCTRL::PowerOn),
36 _ => None,
37 }
38 }
39 #[inline(always)]
41 pub fn is_power_off(&self) -> bool {
42 *self == PWRCTRL::PowerOff
43 }
44 #[inline(always)]
46 pub fn is_power_on(&self) -> bool {
47 *self == PWRCTRL::PowerOn
48 }
49}
50pub type PWRCTRL_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PWRCTRL>;
52impl<'a, REG> PWRCTRL_W<'a, REG>
53where
54 REG: crate::Writable + crate::RegisterSpec,
55 REG::Ux: From<u8>,
56{
57 #[inline(always)]
59 pub fn power_off(self) -> &'a mut crate::W<REG> {
60 self.variant(PWRCTRL::PowerOff)
61 }
62 #[inline(always)]
64 pub fn power_on(self) -> &'a mut crate::W<REG> {
65 self.variant(PWRCTRL::PowerOn)
66 }
67}
68impl R {
69 #[inline(always)]
71 pub fn pwrctrl(&self) -> PWRCTRL_R {
72 PWRCTRL_R::new((self.bits & 3) as u8)
73 }
74}
75impl core::fmt::Debug for R {
76 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
77 f.debug_struct("POWER")
78 .field("pwrctrl", &self.pwrctrl())
79 .finish()
80 }
81}
82impl W {
83 #[inline(always)]
85 pub fn pwrctrl(&mut self) -> PWRCTRL_W<POWERrs> {
86 PWRCTRL_W::new(self, 0)
87 }
88}
89pub struct POWERrs;
95impl crate::RegisterSpec for POWERrs {
96 type Ux = u32;
97}
98impl crate::Readable for POWERrs {}
100impl crate::Writable for POWERrs {
102 type Safety = crate::Unsafe;
103}
104impl crate::Resettable for POWERrs {}