efm32pg12b500_pac/cryotimer/
ctrl.rs

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