efm32lg330_pac/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> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, 0>;
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> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, 1>;
45#[doc = "Select EM4 duty oscillator\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum OSC_A {
49    #[doc = "0: ULFRCO is available."]
50    ULFRCO = 0,
51    #[doc = "1: LFRCO is available. Can only be set if LFRCO is running before EM4/backup entry."]
52    LFRCO = 1,
53    #[doc = "2: LFXO is available. Can only be set if LFXO is available before EM4/backup entry."]
54    LFXO = 2,
55}
56impl From<OSC_A> for u8 {
57    #[inline(always)]
58    fn from(variant: OSC_A) -> Self {
59        variant as _
60    }
61}
62#[doc = "Field `OSC` reader - Select EM4 duty oscillator"]
63pub type OSC_R = crate::FieldReader<u8, OSC_A>;
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> = crate::FieldWriter<'a, u32, EM4CONF_SPEC, u8, OSC_A, 2, 2>;
93impl<'a> OSC_W<'a> {
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> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, 4>;
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> = crate::BitWriter<'a, u32, EM4CONF_SPEC, bool, 16>;
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    pub fn vregen(&mut self) -> VREGEN_W {
149        VREGEN_W::new(self)
150    }
151    #[doc = "Bit 1 - Backup RTC EM4 wakeup enable"]
152    #[inline(always)]
153    pub fn burtcwu(&mut self) -> BURTCWU_W {
154        BURTCWU_W::new(self)
155    }
156    #[doc = "Bits 2:3 - Select EM4 duty oscillator"]
157    #[inline(always)]
158    pub fn osc(&mut self) -> OSC_W {
159        OSC_W::new(self)
160    }
161    #[doc = "Bit 4 - Disable reset from Backup BOD in EM4"]
162    #[inline(always)]
163    pub fn bubodrstdis(&mut self) -> BUBODRSTDIS_W {
164        BUBODRSTDIS_W::new(self)
165    }
166    #[doc = "Bit 16 - EM4 configuration lock enable"]
167    #[inline(always)]
168    pub fn lockconf(&mut self) -> LOCKCONF_W {
169        LOCKCONF_W::new(self)
170    }
171    #[doc = "Writes raw bits to the register."]
172    #[inline(always)]
173    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
174        self.0.bits(bits);
175        self
176    }
177}
178#[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"]
179pub struct EM4CONF_SPEC;
180impl crate::RegisterSpec for EM4CONF_SPEC {
181    type Ux = u32;
182}
183#[doc = "`read()` method returns [em4conf::R](R) reader structure"]
184impl crate::Readable for EM4CONF_SPEC {
185    type Reader = R;
186}
187#[doc = "`write(|w| ..)` method takes [em4conf::W](W) writer structure"]
188impl crate::Writable for EM4CONF_SPEC {
189    type Writer = W;
190}
191#[doc = "`reset()` method sets EM4CONF to value 0"]
192impl crate::Resettable for EM4CONF_SPEC {
193    #[inline(always)]
194    fn reset_value() -> Self::Ux {
195        0
196    }
197}