stm32f1/stm32f107/sdio/
power.rs

1///Register `POWER` reader
2pub type R = crate::R<POWERrs>;
3///Register `POWER` writer
4pub type W = crate::W<POWERrs>;
5/**PWRCTRL
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u8)]
11pub enum PWRCTRL {
12    ///0: Power off
13    PowerOff = 0,
14    ///3: Power on
15    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 {}
27///Field `PWRCTRL` reader - PWRCTRL
28pub type PWRCTRL_R = crate::FieldReader<PWRCTRL>;
29impl PWRCTRL_R {
30    ///Get enumerated values variant
31    #[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    ///Power off
40    #[inline(always)]
41    pub fn is_power_off(&self) -> bool {
42        *self == PWRCTRL::PowerOff
43    }
44    ///Power on
45    #[inline(always)]
46    pub fn is_power_on(&self) -> bool {
47        *self == PWRCTRL::PowerOn
48    }
49}
50///Field `PWRCTRL` writer - PWRCTRL
51pub 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    ///Power off
58    #[inline(always)]
59    pub fn power_off(self) -> &'a mut crate::W<REG> {
60        self.variant(PWRCTRL::PowerOff)
61    }
62    ///Power on
63    #[inline(always)]
64    pub fn power_on(self) -> &'a mut crate::W<REG> {
65        self.variant(PWRCTRL::PowerOn)
66    }
67}
68impl R {
69    ///Bits 0:1 - PWRCTRL
70    #[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    ///Bits 0:1 - PWRCTRL
84    #[inline(always)]
85    pub fn pwrctrl(&mut self) -> PWRCTRL_W<POWERrs> {
86        PWRCTRL_W::new(self, 0)
87    }
88}
89/**power control register
90
91You can [`read`](crate::Reg::read) this register and get [`power::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`power::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
92
93See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F107.html#SDIO:POWER)*/
94pub struct POWERrs;
95impl crate::RegisterSpec for POWERrs {
96    type Ux = u32;
97}
98///`read()` method returns [`power::R`](R) reader structure
99impl crate::Readable for POWERrs {}
100///`write(|w| ..)` method takes [`power::W`](W) writer structure
101impl crate::Writable for POWERrs {
102    type Safety = crate::Unsafe;
103}
104///`reset()` method sets POWER to value 0
105impl crate::Resettable for POWERrs {}