efm32gg12b830_pac/emu/
dcdcctrl.rs

1#[doc = "Register `DCDCCTRL` reader"]
2pub struct R(crate::R<DCDCCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DCDCCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DCDCCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DCDCCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DCDCCTRL` writer"]
17pub struct W(crate::W<DCDCCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DCDCCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<DCDCCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DCDCCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Regulator Mode\n\nValue on reset: 3"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum DCDCMODE_A {
41    #[doc = "0: DCDC regulator is operating in bypass mode. Prior to configuring DCDCMODE=BYPASS, software must set EMU_DCDCCLIMCTRL.BYPLIMEN=1 to prevent excessive current between VREGVDD and DVDD supplies."]
42    BYPASS = 0,
43    #[doc = "1: DCDC regulator is operating in low noise mode."]
44    LOWNOISE = 1,
45    #[doc = "2: DCDC regulator is operating in low power mode."]
46    LOWPOWER = 2,
47    #[doc = "3: DCDC regulator is off and the bypass switch is off. Note: DVDD must be supplied externally"]
48    OFF = 3,
49}
50impl From<DCDCMODE_A> for u8 {
51    #[inline(always)]
52    fn from(variant: DCDCMODE_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `DCDCMODE` reader - Regulator Mode"]
57pub type DCDCMODE_R = crate::FieldReader<u8, DCDCMODE_A>;
58impl DCDCMODE_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> DCDCMODE_A {
62        match self.bits {
63            0 => DCDCMODE_A::BYPASS,
64            1 => DCDCMODE_A::LOWNOISE,
65            2 => DCDCMODE_A::LOWPOWER,
66            3 => DCDCMODE_A::OFF,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `BYPASS`"]
71    #[inline(always)]
72    pub fn is_bypass(&self) -> bool {
73        *self == DCDCMODE_A::BYPASS
74    }
75    #[doc = "Checks if the value of the field is `LOWNOISE`"]
76    #[inline(always)]
77    pub fn is_lownoise(&self) -> bool {
78        *self == DCDCMODE_A::LOWNOISE
79    }
80    #[doc = "Checks if the value of the field is `LOWPOWER`"]
81    #[inline(always)]
82    pub fn is_lowpower(&self) -> bool {
83        *self == DCDCMODE_A::LOWPOWER
84    }
85    #[doc = "Checks if the value of the field is `OFF`"]
86    #[inline(always)]
87    pub fn is_off(&self) -> bool {
88        *self == DCDCMODE_A::OFF
89    }
90}
91#[doc = "Field `DCDCMODE` writer - Regulator Mode"]
92pub type DCDCMODE_W<'a> = crate::FieldWriterSafe<'a, u32, DCDCCTRL_SPEC, u8, DCDCMODE_A, 2, 0>;
93impl<'a> DCDCMODE_W<'a> {
94    #[doc = "DCDC regulator is operating in bypass mode. Prior to configuring DCDCMODE=BYPASS, software must set EMU_DCDCCLIMCTRL.BYPLIMEN=1 to prevent excessive current between VREGVDD and DVDD supplies."]
95    #[inline(always)]
96    pub fn bypass(self) -> &'a mut W {
97        self.variant(DCDCMODE_A::BYPASS)
98    }
99    #[doc = "DCDC regulator is operating in low noise mode."]
100    #[inline(always)]
101    pub fn lownoise(self) -> &'a mut W {
102        self.variant(DCDCMODE_A::LOWNOISE)
103    }
104    #[doc = "DCDC regulator is operating in low power mode."]
105    #[inline(always)]
106    pub fn lowpower(self) -> &'a mut W {
107        self.variant(DCDCMODE_A::LOWPOWER)
108    }
109    #[doc = "DCDC regulator is off and the bypass switch is off. Note: DVDD must be supplied externally"]
110    #[inline(always)]
111    pub fn off(self) -> &'a mut W {
112        self.variant(DCDCMODE_A::OFF)
113    }
114}
115#[doc = "Field `DCDCMODEEM23` reader - DCDC Mode EM23"]
116pub type DCDCMODEEM23_R = crate::BitReader<bool>;
117#[doc = "Field `DCDCMODEEM23` writer - DCDC Mode EM23"]
118pub type DCDCMODEEM23_W<'a> = crate::BitWriter<'a, u32, DCDCCTRL_SPEC, bool, 4>;
119#[doc = "Field `DCDCMODEEM4` reader - DCDC Mode EM4H"]
120pub type DCDCMODEEM4_R = crate::BitReader<bool>;
121#[doc = "Field `DCDCMODEEM4` writer - DCDC Mode EM4H"]
122pub type DCDCMODEEM4_W<'a> = crate::BitWriter<'a, u32, DCDCCTRL_SPEC, bool, 5>;
123impl R {
124    #[doc = "Bits 0:1 - Regulator Mode"]
125    #[inline(always)]
126    pub fn dcdcmode(&self) -> DCDCMODE_R {
127        DCDCMODE_R::new((self.bits & 3) as u8)
128    }
129    #[doc = "Bit 4 - DCDC Mode EM23"]
130    #[inline(always)]
131    pub fn dcdcmodeem23(&self) -> DCDCMODEEM23_R {
132        DCDCMODEEM23_R::new(((self.bits >> 4) & 1) != 0)
133    }
134    #[doc = "Bit 5 - DCDC Mode EM4H"]
135    #[inline(always)]
136    pub fn dcdcmodeem4(&self) -> DCDCMODEEM4_R {
137        DCDCMODEEM4_R::new(((self.bits >> 5) & 1) != 0)
138    }
139}
140impl W {
141    #[doc = "Bits 0:1 - Regulator Mode"]
142    #[inline(always)]
143    pub fn dcdcmode(&mut self) -> DCDCMODE_W {
144        DCDCMODE_W::new(self)
145    }
146    #[doc = "Bit 4 - DCDC Mode EM23"]
147    #[inline(always)]
148    pub fn dcdcmodeem23(&mut self) -> DCDCMODEEM23_W {
149        DCDCMODEEM23_W::new(self)
150    }
151    #[doc = "Bit 5 - DCDC Mode EM4H"]
152    #[inline(always)]
153    pub fn dcdcmodeem4(&mut self) -> DCDCMODEEM4_W {
154        DCDCMODEEM4_W::new(self)
155    }
156    #[doc = "Writes raw bits to the register."]
157    #[inline(always)]
158    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
159        self.0.bits(bits);
160        self
161    }
162}
163#[doc = "DCDC Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcdcctrl](index.html) module"]
164pub struct DCDCCTRL_SPEC;
165impl crate::RegisterSpec for DCDCCTRL_SPEC {
166    type Ux = u32;
167}
168#[doc = "`read()` method returns [dcdcctrl::R](R) reader structure"]
169impl crate::Readable for DCDCCTRL_SPEC {
170    type Reader = R;
171}
172#[doc = "`write(|w| ..)` method takes [dcdcctrl::W](W) writer structure"]
173impl crate::Writable for DCDCCTRL_SPEC {
174    type Writer = W;
175}
176#[doc = "`reset()` method sets DCDCCTRL to value 0x33"]
177impl crate::Resettable for DCDCCTRL_SPEC {
178    #[inline(always)]
179    fn reset_value() -> Self::Ux {
180        0x33
181    }
182}