efm32pg1b200_pac/cmu/
hfxoctrl.rs1#[doc = "Register `HFXOCTRL` reader"]
2pub struct R(crate::R<HFXOCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HFXOCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HFXOCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HFXOCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `HFXOCTRL` writer"]
17pub struct W(crate::W<HFXOCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<HFXOCTRL_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<HFXOCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<HFXOCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MODE` reader - HFXO Mode"]
38pub type MODE_R = crate::BitReader<bool>;
39#[doc = "Field `MODE` writer - HFXO Mode"]
40pub type MODE_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 0>;
41#[doc = "HFXO Automatic Peak Detection and Shunt Current Optimization Mode\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum PEAKDETSHUNTOPTMODE_A {
45    #[doc = "0: Automatic control of HFXO peak detection and shunt optimization sequences. CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can also be used."]
46    AUTOCMD = 0,
47    #[doc = "1: CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can be used to trigger peak detection and shunt optimization sequences."]
48    CMD = 1,
49    #[doc = "2: CMU_HFXOSTEADYSTATECTRL IBTRIMXOCORE, REGISH, REGSELILOW, and PEAKDETEN are under full software control and are allowed to be changed once HFXO is ready."]
50    MANUAL = 2,
51}
52impl From<PEAKDETSHUNTOPTMODE_A> for u8 {
53    #[inline(always)]
54    fn from(variant: PEAKDETSHUNTOPTMODE_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `PEAKDETSHUNTOPTMODE` reader - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
59pub type PEAKDETSHUNTOPTMODE_R = crate::FieldReader<u8, PEAKDETSHUNTOPTMODE_A>;
60impl PEAKDETSHUNTOPTMODE_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<PEAKDETSHUNTOPTMODE_A> {
64        match self.bits {
65            0 => Some(PEAKDETSHUNTOPTMODE_A::AUTOCMD),
66            1 => Some(PEAKDETSHUNTOPTMODE_A::CMD),
67            2 => Some(PEAKDETSHUNTOPTMODE_A::MANUAL),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `AUTOCMD`"]
72    #[inline(always)]
73    pub fn is_autocmd(&self) -> bool {
74        *self == PEAKDETSHUNTOPTMODE_A::AUTOCMD
75    }
76    #[doc = "Checks if the value of the field is `CMD`"]
77    #[inline(always)]
78    pub fn is_cmd(&self) -> bool {
79        *self == PEAKDETSHUNTOPTMODE_A::CMD
80    }
81    #[doc = "Checks if the value of the field is `MANUAL`"]
82    #[inline(always)]
83    pub fn is_manual(&self) -> bool {
84        *self == PEAKDETSHUNTOPTMODE_A::MANUAL
85    }
86}
87#[doc = "Field `PEAKDETSHUNTOPTMODE` writer - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
88pub type PEAKDETSHUNTOPTMODE_W<'a> =
89    crate::FieldWriter<'a, u32, HFXOCTRL_SPEC, u8, PEAKDETSHUNTOPTMODE_A, 2, 4>;
90impl<'a> PEAKDETSHUNTOPTMODE_W<'a> {
91    #[doc = "Automatic control of HFXO peak detection and shunt optimization sequences. CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can also be used."]
92    #[inline(always)]
93    pub fn autocmd(self) -> &'a mut W {
94        self.variant(PEAKDETSHUNTOPTMODE_A::AUTOCMD)
95    }
96    #[doc = "CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can be used to trigger peak detection and shunt optimization sequences."]
97    #[inline(always)]
98    pub fn cmd(self) -> &'a mut W {
99        self.variant(PEAKDETSHUNTOPTMODE_A::CMD)
100    }
101    #[doc = "CMU_HFXOSTEADYSTATECTRL IBTRIMXOCORE, REGISH, REGSELILOW, and PEAKDETEN are under full software control and are allowed to be changed once HFXO is ready."]
102    #[inline(always)]
103    pub fn manual(self) -> &'a mut W {
104        self.variant(PEAKDETSHUNTOPTMODE_A::MANUAL)
105    }
106}
107#[doc = "Field `LOWPOWER` reader - Low Power Mode Control"]
108pub type LOWPOWER_R = crate::BitReader<bool>;
109#[doc = "Field `LOWPOWER` writer - Low Power Mode Control"]
110pub type LOWPOWER_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 8>;
111#[doc = "Field `XTI2GND` reader - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
112pub type XTI2GND_R = crate::BitReader<bool>;
113#[doc = "Field `XTI2GND` writer - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
114pub type XTI2GND_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 9>;
115#[doc = "Field `XTO2GND` reader - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
116pub type XTO2GND_R = crate::BitReader<bool>;
117#[doc = "Field `XTO2GND` writer - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
118pub type XTO2GND_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 10>;
119#[doc = "HFXO Low Frequency Timeout\n\nValue on reset: 0"]
120#[derive(Clone, Copy, Debug, PartialEq)]
121#[repr(u8)]
122pub enum LFTIMEOUT_A {
123    #[doc = "0: Timeout period of 0 cycles (disabled)"]
124    _0CYCLES = 0,
125    #[doc = "1: Timeout period of 2 cycles"]
126    _2CYCLES = 1,
127    #[doc = "2: Timeout period of 4 cycles"]
128    _4CYCLES = 2,
129    #[doc = "3: Timeout period of 16 cycles"]
130    _16CYCLES = 3,
131    #[doc = "4: Timeout period of 32 cycles"]
132    _32CYCLES = 4,
133    #[doc = "5: Timeout period of 64 cycles"]
134    _64CYCLES = 5,
135    #[doc = "6: Timeout period of 1024 cycles"]
136    _1KCYCLES = 6,
137    #[doc = "7: Timeout period of 4096 cycles"]
138    _4KCYCLES = 7,
139}
140impl From<LFTIMEOUT_A> for u8 {
141    #[inline(always)]
142    fn from(variant: LFTIMEOUT_A) -> Self {
143        variant as _
144    }
145}
146#[doc = "Field `LFTIMEOUT` reader - HFXO Low Frequency Timeout"]
147pub type LFTIMEOUT_R = crate::FieldReader<u8, LFTIMEOUT_A>;
148impl LFTIMEOUT_R {
149    #[doc = "Get enumerated values variant"]
150    #[inline(always)]
151    pub fn variant(&self) -> LFTIMEOUT_A {
152        match self.bits {
153            0 => LFTIMEOUT_A::_0CYCLES,
154            1 => LFTIMEOUT_A::_2CYCLES,
155            2 => LFTIMEOUT_A::_4CYCLES,
156            3 => LFTIMEOUT_A::_16CYCLES,
157            4 => LFTIMEOUT_A::_32CYCLES,
158            5 => LFTIMEOUT_A::_64CYCLES,
159            6 => LFTIMEOUT_A::_1KCYCLES,
160            7 => LFTIMEOUT_A::_4KCYCLES,
161            _ => unreachable!(),
162        }
163    }
164    #[doc = "Checks if the value of the field is `_0CYCLES`"]
165    #[inline(always)]
166    pub fn is_0cycles(&self) -> bool {
167        *self == LFTIMEOUT_A::_0CYCLES
168    }
169    #[doc = "Checks if the value of the field is `_2CYCLES`"]
170    #[inline(always)]
171    pub fn is_2cycles(&self) -> bool {
172        *self == LFTIMEOUT_A::_2CYCLES
173    }
174    #[doc = "Checks if the value of the field is `_4CYCLES`"]
175    #[inline(always)]
176    pub fn is_4cycles(&self) -> bool {
177        *self == LFTIMEOUT_A::_4CYCLES
178    }
179    #[doc = "Checks if the value of the field is `_16CYCLES`"]
180    #[inline(always)]
181    pub fn is_16cycles(&self) -> bool {
182        *self == LFTIMEOUT_A::_16CYCLES
183    }
184    #[doc = "Checks if the value of the field is `_32CYCLES`"]
185    #[inline(always)]
186    pub fn is_32cycles(&self) -> bool {
187        *self == LFTIMEOUT_A::_32CYCLES
188    }
189    #[doc = "Checks if the value of the field is `_64CYCLES`"]
190    #[inline(always)]
191    pub fn is_64cycles(&self) -> bool {
192        *self == LFTIMEOUT_A::_64CYCLES
193    }
194    #[doc = "Checks if the value of the field is `_1KCYCLES`"]
195    #[inline(always)]
196    pub fn is_1kcycles(&self) -> bool {
197        *self == LFTIMEOUT_A::_1KCYCLES
198    }
199    #[doc = "Checks if the value of the field is `_4KCYCLES`"]
200    #[inline(always)]
201    pub fn is_4kcycles(&self) -> bool {
202        *self == LFTIMEOUT_A::_4KCYCLES
203    }
204}
205#[doc = "Field `LFTIMEOUT` writer - HFXO Low Frequency Timeout"]
206pub type LFTIMEOUT_W<'a> = crate::FieldWriterSafe<'a, u32, HFXOCTRL_SPEC, u8, LFTIMEOUT_A, 3, 24>;
207impl<'a> LFTIMEOUT_W<'a> {
208    #[doc = "Timeout period of 0 cycles (disabled)"]
209    #[inline(always)]
210    pub fn _0cycles(self) -> &'a mut W {
211        self.variant(LFTIMEOUT_A::_0CYCLES)
212    }
213    #[doc = "Timeout period of 2 cycles"]
214    #[inline(always)]
215    pub fn _2cycles(self) -> &'a mut W {
216        self.variant(LFTIMEOUT_A::_2CYCLES)
217    }
218    #[doc = "Timeout period of 4 cycles"]
219    #[inline(always)]
220    pub fn _4cycles(self) -> &'a mut W {
221        self.variant(LFTIMEOUT_A::_4CYCLES)
222    }
223    #[doc = "Timeout period of 16 cycles"]
224    #[inline(always)]
225    pub fn _16cycles(self) -> &'a mut W {
226        self.variant(LFTIMEOUT_A::_16CYCLES)
227    }
228    #[doc = "Timeout period of 32 cycles"]
229    #[inline(always)]
230    pub fn _32cycles(self) -> &'a mut W {
231        self.variant(LFTIMEOUT_A::_32CYCLES)
232    }
233    #[doc = "Timeout period of 64 cycles"]
234    #[inline(always)]
235    pub fn _64cycles(self) -> &'a mut W {
236        self.variant(LFTIMEOUT_A::_64CYCLES)
237    }
238    #[doc = "Timeout period of 1024 cycles"]
239    #[inline(always)]
240    pub fn _1kcycles(self) -> &'a mut W {
241        self.variant(LFTIMEOUT_A::_1KCYCLES)
242    }
243    #[doc = "Timeout period of 4096 cycles"]
244    #[inline(always)]
245    pub fn _4kcycles(self) -> &'a mut W {
246        self.variant(LFTIMEOUT_A::_4KCYCLES)
247    }
248}
249#[doc = "Field `AUTOSTARTEM0EM1` reader - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
250pub type AUTOSTARTEM0EM1_R = crate::BitReader<bool>;
251#[doc = "Field `AUTOSTARTEM0EM1` writer - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
252pub type AUTOSTARTEM0EM1_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 28>;
253#[doc = "Field `AUTOSTARTSELEM0EM1` reader - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
254pub type AUTOSTARTSELEM0EM1_R = crate::BitReader<bool>;
255#[doc = "Field `AUTOSTARTSELEM0EM1` writer - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
256pub type AUTOSTARTSELEM0EM1_W<'a> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, 29>;
257impl R {
258    #[doc = "Bit 0 - HFXO Mode"]
259    #[inline(always)]
260    pub fn mode(&self) -> MODE_R {
261        MODE_R::new((self.bits & 1) != 0)
262    }
263    #[doc = "Bits 4:5 - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
264    #[inline(always)]
265    pub fn peakdetshuntoptmode(&self) -> PEAKDETSHUNTOPTMODE_R {
266        PEAKDETSHUNTOPTMODE_R::new(((self.bits >> 4) & 3) as u8)
267    }
268    #[doc = "Bit 8 - Low Power Mode Control"]
269    #[inline(always)]
270    pub fn lowpower(&self) -> LOWPOWER_R {
271        LOWPOWER_R::new(((self.bits >> 8) & 1) != 0)
272    }
273    #[doc = "Bit 9 - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
274    #[inline(always)]
275    pub fn xti2gnd(&self) -> XTI2GND_R {
276        XTI2GND_R::new(((self.bits >> 9) & 1) != 0)
277    }
278    #[doc = "Bit 10 - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
279    #[inline(always)]
280    pub fn xto2gnd(&self) -> XTO2GND_R {
281        XTO2GND_R::new(((self.bits >> 10) & 1) != 0)
282    }
283    #[doc = "Bits 24:26 - HFXO Low Frequency Timeout"]
284    #[inline(always)]
285    pub fn lftimeout(&self) -> LFTIMEOUT_R {
286        LFTIMEOUT_R::new(((self.bits >> 24) & 7) as u8)
287    }
288    #[doc = "Bit 28 - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
289    #[inline(always)]
290    pub fn autostartem0em1(&self) -> AUTOSTARTEM0EM1_R {
291        AUTOSTARTEM0EM1_R::new(((self.bits >> 28) & 1) != 0)
292    }
293    #[doc = "Bit 29 - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
294    #[inline(always)]
295    pub fn autostartselem0em1(&self) -> AUTOSTARTSELEM0EM1_R {
296        AUTOSTARTSELEM0EM1_R::new(((self.bits >> 29) & 1) != 0)
297    }
298}
299impl W {
300    #[doc = "Bit 0 - HFXO Mode"]
301    #[inline(always)]
302    pub fn mode(&mut self) -> MODE_W {
303        MODE_W::new(self)
304    }
305    #[doc = "Bits 4:5 - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
306    #[inline(always)]
307    pub fn peakdetshuntoptmode(&mut self) -> PEAKDETSHUNTOPTMODE_W {
308        PEAKDETSHUNTOPTMODE_W::new(self)
309    }
310    #[doc = "Bit 8 - Low Power Mode Control"]
311    #[inline(always)]
312    pub fn lowpower(&mut self) -> LOWPOWER_W {
313        LOWPOWER_W::new(self)
314    }
315    #[doc = "Bit 9 - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
316    #[inline(always)]
317    pub fn xti2gnd(&mut self) -> XTI2GND_W {
318        XTI2GND_W::new(self)
319    }
320    #[doc = "Bit 10 - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
321    #[inline(always)]
322    pub fn xto2gnd(&mut self) -> XTO2GND_W {
323        XTO2GND_W::new(self)
324    }
325    #[doc = "Bits 24:26 - HFXO Low Frequency Timeout"]
326    #[inline(always)]
327    pub fn lftimeout(&mut self) -> LFTIMEOUT_W {
328        LFTIMEOUT_W::new(self)
329    }
330    #[doc = "Bit 28 - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
331    #[inline(always)]
332    pub fn autostartem0em1(&mut self) -> AUTOSTARTEM0EM1_W {
333        AUTOSTARTEM0EM1_W::new(self)
334    }
335    #[doc = "Bit 29 - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
336    #[inline(always)]
337    pub fn autostartselem0em1(&mut self) -> AUTOSTARTSELEM0EM1_W {
338        AUTOSTARTSELEM0EM1_W::new(self)
339    }
340    #[doc = "Writes raw bits to the register."]
341    #[inline(always)]
342    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
343        self.0.bits(bits);
344        self
345    }
346}
347#[doc = "HFXO Control 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 [hfxoctrl](index.html) module"]
348pub struct HFXOCTRL_SPEC;
349impl crate::RegisterSpec for HFXOCTRL_SPEC {
350    type Ux = u32;
351}
352#[doc = "`read()` method returns [hfxoctrl::R](R) reader structure"]
353impl crate::Readable for HFXOCTRL_SPEC {
354    type Reader = R;
355}
356#[doc = "`write(|w| ..)` method takes [hfxoctrl::W](W) writer structure"]
357impl crate::Writable for HFXOCTRL_SPEC {
358    type Writer = W;
359}
360#[doc = "`reset()` method sets HFXOCTRL to value 0"]
361impl crate::Resettable for HFXOCTRL_SPEC {
362    #[inline(always)]
363    fn reset_value() -> Self::Ux {
364        0
365    }
366}