efm32gg_pac/efm32gg995/emu/
em4conf.rs

1#[doc = "Register `EM4CONF` reader"]
2pub struct R(crate::R<EM4CONF_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EM4CONF_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EM4CONF_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EM4CONF_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EM4CONF` writer"]
17pub struct W(crate::W<EM4CONF_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EM4CONF_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<EM4CONF_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EM4CONF_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `VREGEN` reader - EM4 voltage regulator enable"]
38pub type VREGEN_R = crate::BitReader<bool>;
39#[doc = "Field `VREGEN` writer - EM4 voltage regulator enable"]
40pub type VREGEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, O>;
41#[doc = "Field `BURTCWU` reader - Backup RTC EM4 wakeup enable"]
42pub type BURTCWU_R = crate::BitReader<bool>;
43#[doc = "Field `BURTCWU` writer - Backup RTC EM4 wakeup enable"]
44pub type BURTCWU_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, O>;
45#[doc = "Field `OSC` reader - Select EM4 duty oscillator"]
46pub type OSC_R = crate::FieldReader<u8, OSC_A>;
47#[doc = "Select EM4 duty oscillator\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum OSC_A {
51    #[doc = "0: ULFRCO is available."]
52    ULFRCO = 0,
53    #[doc = "1: LFRCO is available. Can only be set if LFRCO is running before EM4/backup entry."]
54    LFRCO = 1,
55    #[doc = "2: LFXO is available. Can only be set if LFXO is available before EM4/backup entry."]
56    LFXO = 2,
57}
58impl From<OSC_A> for u8 {
59    #[inline(always)]
60    fn from(variant: OSC_A) -> Self {
61        variant as _
62    }
63}
64impl OSC_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<OSC_A> {
68        match self.bits {
69            0 => Some(OSC_A::ULFRCO),
70            1 => Some(OSC_A::LFRCO),
71            2 => Some(OSC_A::LFXO),
72            _ => None,
73        }
74    }
75    #[doc = "Checks if the value of the field is `ULFRCO`"]
76    #[inline(always)]
77    pub fn is_ulfrco(&self) -> bool {
78        *self == OSC_A::ULFRCO
79    }
80    #[doc = "Checks if the value of the field is `LFRCO`"]
81    #[inline(always)]
82    pub fn is_lfrco(&self) -> bool {
83        *self == OSC_A::LFRCO
84    }
85    #[doc = "Checks if the value of the field is `LFXO`"]
86    #[inline(always)]
87    pub fn is_lfxo(&self) -> bool {
88        *self == OSC_A::LFXO
89    }
90}
91#[doc = "Field `OSC` writer - Select EM4 duty oscillator"]
92pub type OSC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EM4CONF_SPEC, u8, OSC_A, 2, O>;
93impl<'a, const O: u8> OSC_W<'a, O> {
94    #[doc = "ULFRCO is available."]
95    #[inline(always)]
96    pub fn ulfrco(self) -> &'a mut W {
97        self.variant(OSC_A::ULFRCO)
98    }
99    #[doc = "LFRCO is available. Can only be set if LFRCO is running before EM4/backup entry."]
100    #[inline(always)]
101    pub fn lfrco(self) -> &'a mut W {
102        self.variant(OSC_A::LFRCO)
103    }
104    #[doc = "LFXO is available. Can only be set if LFXO is available before EM4/backup entry."]
105    #[inline(always)]
106    pub fn lfxo(self) -> &'a mut W {
107        self.variant(OSC_A::LFXO)
108    }
109}
110#[doc = "Field `BUBODRSTDIS` reader - Disable reset from Backup BOD in EM4"]
111pub type BUBODRSTDIS_R = crate::BitReader<bool>;
112#[doc = "Field `BUBODRSTDIS` writer - Disable reset from Backup BOD in EM4"]
113pub type BUBODRSTDIS_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, O>;
114#[doc = "Field `LOCKCONF` reader - EM4 configuration lock enable"]
115pub type LOCKCONF_R = crate::BitReader<bool>;
116#[doc = "Field `LOCKCONF` writer - EM4 configuration lock enable"]
117pub type LOCKCONF_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, O>;
118impl R {
119    #[doc = "Bit 0 - EM4 voltage regulator enable"]
120    #[inline(always)]
121    pub fn vregen(&self) -> VREGEN_R {
122        VREGEN_R::new((self.bits & 1) != 0)
123    }
124    #[doc = "Bit 1 - Backup RTC EM4 wakeup enable"]
125    #[inline(always)]
126    pub fn burtcwu(&self) -> BURTCWU_R {
127        BURTCWU_R::new(((self.bits >> 1) & 1) != 0)
128    }
129    #[doc = "Bits 2:3 - Select EM4 duty oscillator"]
130    #[inline(always)]
131    pub fn osc(&self) -> OSC_R {
132        OSC_R::new(((self.bits >> 2) & 3) as u8)
133    }
134    #[doc = "Bit 4 - Disable reset from Backup BOD in EM4"]
135    #[inline(always)]
136    pub fn bubodrstdis(&self) -> BUBODRSTDIS_R {
137        BUBODRSTDIS_R::new(((self.bits >> 4) & 1) != 0)
138    }
139    #[doc = "Bit 16 - EM4 configuration lock enable"]
140    #[inline(always)]
141    pub fn lockconf(&self) -> LOCKCONF_R {
142        LOCKCONF_R::new(((self.bits >> 16) & 1) != 0)
143    }
144}
145impl W {
146    #[doc = "Bit 0 - EM4 voltage regulator enable"]
147    #[inline(always)]
148    #[must_use]
149    pub fn vregen(&mut self) -> VREGEN_W<0> {
150        VREGEN_W::new(self)
151    }
152    #[doc = "Bit 1 - Backup RTC EM4 wakeup enable"]
153    #[inline(always)]
154    #[must_use]
155    pub fn burtcwu(&mut self) -> BURTCWU_W<1> {
156        BURTCWU_W::new(self)
157    }
158    #[doc = "Bits 2:3 - Select EM4 duty oscillator"]
159    #[inline(always)]
160    #[must_use]
161    pub fn osc(&mut self) -> OSC_W<2> {
162        OSC_W::new(self)
163    }
164    #[doc = "Bit 4 - Disable reset from Backup BOD in EM4"]
165    #[inline(always)]
166    #[must_use]
167    pub fn bubodrstdis(&mut self) -> BUBODRSTDIS_W<4> {
168        BUBODRSTDIS_W::new(self)
169    }
170    #[doc = "Bit 16 - EM4 configuration lock enable"]
171    #[inline(always)]
172    #[must_use]
173    pub fn lockconf(&mut self) -> LOCKCONF_W<16> {
174        LOCKCONF_W::new(self)
175    }
176    #[doc = "Writes raw bits to the register."]
177    #[inline(always)]
178    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
179        self.0.bits(bits);
180        self
181    }
182}
183#[doc = "Energy mode 4 configuration register\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 [em4conf](index.html) module"]
184pub struct EM4CONF_SPEC;
185impl crate::RegisterSpec for EM4CONF_SPEC {
186    type Ux = u32;
187}
188#[doc = "`read()` method returns [em4conf::R](R) reader structure"]
189impl crate::Readable for EM4CONF_SPEC {
190    type Reader = R;
191}
192#[doc = "`write(|w| ..)` method takes [em4conf::W](W) writer structure"]
193impl crate::Writable for EM4CONF_SPEC {
194    type Writer = W;
195    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
196    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
197}
198#[doc = "`reset()` method sets EM4CONF to value 0"]
199impl crate::Resettable for EM4CONF_SPEC {
200    const RESET_VALUE: Self::Ux = 0;
201}