efm32pg12_pac/cryotimer/
ctrl.rs

1#[doc = "Reader of register CTRL"]
2pub type R = crate::R<u32, super::CTRL>;
3#[doc = "Writer for register CTRL"]
4pub type W = crate::W<u32, super::CTRL>;
5#[doc = "Register CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `EN`"]
14pub type EN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `EN`"]
16pub struct EN_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> EN_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `DEBUGRUN`"]
38pub type DEBUGRUN_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `DEBUGRUN`"]
40pub struct DEBUGRUN_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> DEBUGRUN_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
58        self.w
59    }
60}
61#[doc = "Select Low Frequency Oscillator\n\nValue on reset: 0"]
62#[derive(Clone, Copy, Debug, PartialEq)]
63#[repr(u8)]
64pub enum OSCSEL_A {
65    #[doc = "0: Output is driven low"]
66    DISABLED = 0,
67    #[doc = "1: Select Low Frequency RC Oscillator"]
68    LFRCO = 1,
69    #[doc = "2: Select Low Frequency Crystal Oscillator"]
70    LFXO = 2,
71    #[doc = "3: Select Ultra Low Frequency RC Oscillator"]
72    ULFRCO = 3,
73}
74impl From<OSCSEL_A> for u8 {
75    #[inline(always)]
76    fn from(variant: OSCSEL_A) -> Self {
77        variant as _
78    }
79}
80#[doc = "Reader of field `OSCSEL`"]
81pub type OSCSEL_R = crate::R<u8, OSCSEL_A>;
82impl OSCSEL_R {
83    #[doc = r"Get enumerated values variant"]
84    #[inline(always)]
85    pub fn variant(&self) -> OSCSEL_A {
86        match self.bits {
87            0 => OSCSEL_A::DISABLED,
88            1 => OSCSEL_A::LFRCO,
89            2 => OSCSEL_A::LFXO,
90            3 => OSCSEL_A::ULFRCO,
91            _ => unreachable!(),
92        }
93    }
94    #[doc = "Checks if the value of the field is `DISABLED`"]
95    #[inline(always)]
96    pub fn is_disabled(&self) -> bool {
97        *self == OSCSEL_A::DISABLED
98    }
99    #[doc = "Checks if the value of the field is `LFRCO`"]
100    #[inline(always)]
101    pub fn is_lfrco(&self) -> bool {
102        *self == OSCSEL_A::LFRCO
103    }
104    #[doc = "Checks if the value of the field is `LFXO`"]
105    #[inline(always)]
106    pub fn is_lfxo(&self) -> bool {
107        *self == OSCSEL_A::LFXO
108    }
109    #[doc = "Checks if the value of the field is `ULFRCO`"]
110    #[inline(always)]
111    pub fn is_ulfrco(&self) -> bool {
112        *self == OSCSEL_A::ULFRCO
113    }
114}
115#[doc = "Write proxy for field `OSCSEL`"]
116pub struct OSCSEL_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> OSCSEL_W<'a> {
120    #[doc = r"Writes `variant` to the field"]
121    #[inline(always)]
122    pub fn variant(self, variant: OSCSEL_A) -> &'a mut W {
123        {
124            self.bits(variant.into())
125        }
126    }
127    #[doc = "Output is driven low"]
128    #[inline(always)]
129    pub fn disabled(self) -> &'a mut W {
130        self.variant(OSCSEL_A::DISABLED)
131    }
132    #[doc = "Select Low Frequency RC Oscillator"]
133    #[inline(always)]
134    pub fn lfrco(self) -> &'a mut W {
135        self.variant(OSCSEL_A::LFRCO)
136    }
137    #[doc = "Select Low Frequency Crystal Oscillator"]
138    #[inline(always)]
139    pub fn lfxo(self) -> &'a mut W {
140        self.variant(OSCSEL_A::LFXO)
141    }
142    #[doc = "Select Ultra Low Frequency RC Oscillator"]
143    #[inline(always)]
144    pub fn ulfrco(self) -> &'a mut W {
145        self.variant(OSCSEL_A::ULFRCO)
146    }
147    #[doc = r"Writes raw bits to the field"]
148    #[inline(always)]
149    pub fn bits(self, value: u8) -> &'a mut W {
150        self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u32) & 0x03) << 2);
151        self.w
152    }
153}
154#[doc = "Prescaler Setting\n\nValue on reset: 0"]
155#[derive(Clone, Copy, Debug, PartialEq)]
156#[repr(u8)]
157pub enum PRESC_A {
158    #[doc = "0: LF Oscillator frequency undivided"]
159    DIV1 = 0,
160    #[doc = "1: LF Oscillator frequency divided by 2"]
161    DIV2 = 1,
162    #[doc = "2: LF Oscillator frequency divided by 4"]
163    DIV4 = 2,
164    #[doc = "3: LF Oscillator frequency divided by 8"]
165    DIV8 = 3,
166    #[doc = "4: LF Oscillator frequency divided by 16"]
167    DIV16 = 4,
168    #[doc = "5: LF Oscillator frequency divided by 32"]
169    DIV32 = 5,
170    #[doc = "6: LF Oscillator frequency divided by 64"]
171    DIV64 = 6,
172    #[doc = "7: LF Oscillator frequency divided by 128"]
173    DIV128 = 7,
174}
175impl From<PRESC_A> for u8 {
176    #[inline(always)]
177    fn from(variant: PRESC_A) -> Self {
178        variant as _
179    }
180}
181#[doc = "Reader of field `PRESC`"]
182pub type PRESC_R = crate::R<u8, PRESC_A>;
183impl PRESC_R {
184    #[doc = r"Get enumerated values variant"]
185    #[inline(always)]
186    pub fn variant(&self) -> PRESC_A {
187        match self.bits {
188            0 => PRESC_A::DIV1,
189            1 => PRESC_A::DIV2,
190            2 => PRESC_A::DIV4,
191            3 => PRESC_A::DIV8,
192            4 => PRESC_A::DIV16,
193            5 => PRESC_A::DIV32,
194            6 => PRESC_A::DIV64,
195            7 => PRESC_A::DIV128,
196            _ => unreachable!(),
197        }
198    }
199    #[doc = "Checks if the value of the field is `DIV1`"]
200    #[inline(always)]
201    pub fn is_div1(&self) -> bool {
202        *self == PRESC_A::DIV1
203    }
204    #[doc = "Checks if the value of the field is `DIV2`"]
205    #[inline(always)]
206    pub fn is_div2(&self) -> bool {
207        *self == PRESC_A::DIV2
208    }
209    #[doc = "Checks if the value of the field is `DIV4`"]
210    #[inline(always)]
211    pub fn is_div4(&self) -> bool {
212        *self == PRESC_A::DIV4
213    }
214    #[doc = "Checks if the value of the field is `DIV8`"]
215    #[inline(always)]
216    pub fn is_div8(&self) -> bool {
217        *self == PRESC_A::DIV8
218    }
219    #[doc = "Checks if the value of the field is `DIV16`"]
220    #[inline(always)]
221    pub fn is_div16(&self) -> bool {
222        *self == PRESC_A::DIV16
223    }
224    #[doc = "Checks if the value of the field is `DIV32`"]
225    #[inline(always)]
226    pub fn is_div32(&self) -> bool {
227        *self == PRESC_A::DIV32
228    }
229    #[doc = "Checks if the value of the field is `DIV64`"]
230    #[inline(always)]
231    pub fn is_div64(&self) -> bool {
232        *self == PRESC_A::DIV64
233    }
234    #[doc = "Checks if the value of the field is `DIV128`"]
235    #[inline(always)]
236    pub fn is_div128(&self) -> bool {
237        *self == PRESC_A::DIV128
238    }
239}
240#[doc = "Write proxy for field `PRESC`"]
241pub struct PRESC_W<'a> {
242    w: &'a mut W,
243}
244impl<'a> PRESC_W<'a> {
245    #[doc = r"Writes `variant` to the field"]
246    #[inline(always)]
247    pub fn variant(self, variant: PRESC_A) -> &'a mut W {
248        {
249            self.bits(variant.into())
250        }
251    }
252    #[doc = "LF Oscillator frequency undivided"]
253    #[inline(always)]
254    pub fn div1(self) -> &'a mut W {
255        self.variant(PRESC_A::DIV1)
256    }
257    #[doc = "LF Oscillator frequency divided by 2"]
258    #[inline(always)]
259    pub fn div2(self) -> &'a mut W {
260        self.variant(PRESC_A::DIV2)
261    }
262    #[doc = "LF Oscillator frequency divided by 4"]
263    #[inline(always)]
264    pub fn div4(self) -> &'a mut W {
265        self.variant(PRESC_A::DIV4)
266    }
267    #[doc = "LF Oscillator frequency divided by 8"]
268    #[inline(always)]
269    pub fn div8(self) -> &'a mut W {
270        self.variant(PRESC_A::DIV8)
271    }
272    #[doc = "LF Oscillator frequency divided by 16"]
273    #[inline(always)]
274    pub fn div16(self) -> &'a mut W {
275        self.variant(PRESC_A::DIV16)
276    }
277    #[doc = "LF Oscillator frequency divided by 32"]
278    #[inline(always)]
279    pub fn div32(self) -> &'a mut W {
280        self.variant(PRESC_A::DIV32)
281    }
282    #[doc = "LF Oscillator frequency divided by 64"]
283    #[inline(always)]
284    pub fn div64(self) -> &'a mut W {
285        self.variant(PRESC_A::DIV64)
286    }
287    #[doc = "LF Oscillator frequency divided by 128"]
288    #[inline(always)]
289    pub fn div128(self) -> &'a mut W {
290        self.variant(PRESC_A::DIV128)
291    }
292    #[doc = r"Writes raw bits to the field"]
293    #[inline(always)]
294    pub fn bits(self, value: u8) -> &'a mut W {
295        self.w.bits = (self.w.bits & !(0x07 << 5)) | (((value as u32) & 0x07) << 5);
296        self.w
297    }
298}
299impl R {
300    #[doc = "Bit 0 - Enable CRYOTIMER"]
301    #[inline(always)]
302    pub fn en(&self) -> EN_R {
303        EN_R::new((self.bits & 0x01) != 0)
304    }
305    #[doc = "Bit 1 - Debug Mode Run Enable"]
306    #[inline(always)]
307    pub fn debugrun(&self) -> DEBUGRUN_R {
308        DEBUGRUN_R::new(((self.bits >> 1) & 0x01) != 0)
309    }
310    #[doc = "Bits 2:3 - Select Low Frequency Oscillator"]
311    #[inline(always)]
312    pub fn oscsel(&self) -> OSCSEL_R {
313        OSCSEL_R::new(((self.bits >> 2) & 0x03) as u8)
314    }
315    #[doc = "Bits 5:7 - Prescaler Setting"]
316    #[inline(always)]
317    pub fn presc(&self) -> PRESC_R {
318        PRESC_R::new(((self.bits >> 5) & 0x07) as u8)
319    }
320}
321impl W {
322    #[doc = "Bit 0 - Enable CRYOTIMER"]
323    #[inline(always)]
324    pub fn en(&mut self) -> EN_W {
325        EN_W { w: self }
326    }
327    #[doc = "Bit 1 - Debug Mode Run Enable"]
328    #[inline(always)]
329    pub fn debugrun(&mut self) -> DEBUGRUN_W {
330        DEBUGRUN_W { w: self }
331    }
332    #[doc = "Bits 2:3 - Select Low Frequency Oscillator"]
333    #[inline(always)]
334    pub fn oscsel(&mut self) -> OSCSEL_W {
335        OSCSEL_W { w: self }
336    }
337    #[doc = "Bits 5:7 - Prescaler Setting"]
338    #[inline(always)]
339    pub fn presc(&mut self) -> PRESC_W {
340        PRESC_W { w: self }
341    }
342}