efm32jg12b_pac/efm32jg12b500/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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
45#[doc = "Field `OSCSEL` reader - Select Low Frequency Oscillator"]
46pub type OSCSEL_R = crate::FieldReader<u8, OSCSEL_A>;
47#[doc = "Select Low Frequency Oscillator\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum OSCSEL_A {
51    #[doc = "0: Output is driven low"]
52    DISABLED = 0,
53    #[doc = "1: Select Low Frequency RC Oscillator"]
54    LFRCO = 1,
55    #[doc = "2: Select Low Frequency Crystal Oscillator"]
56    LFXO = 2,
57    #[doc = "3: Select Ultra Low Frequency RC Oscillator"]
58    ULFRCO = 3,
59}
60impl From<OSCSEL_A> for u8 {
61    #[inline(always)]
62    fn from(variant: OSCSEL_A) -> Self {
63        variant as _
64    }
65}
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, const O: u8> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, OSCSEL_A, 2, O>;
101impl<'a, const O: u8> OSCSEL_W<'a, O> {
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 = "Field `PRESC` reader - Prescaler Setting"]
124pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
125#[doc = "Prescaler Setting\n\nValue on reset: 0"]
126#[derive(Clone, Copy, Debug, PartialEq, Eq)]
127#[repr(u8)]
128pub enum PRESC_A {
129    #[doc = "0: LF Oscillator frequency undivided"]
130    DIV1 = 0,
131    #[doc = "1: LF Oscillator frequency divided by 2"]
132    DIV2 = 1,
133    #[doc = "2: LF Oscillator frequency divided by 4"]
134    DIV4 = 2,
135    #[doc = "3: LF Oscillator frequency divided by 8"]
136    DIV8 = 3,
137    #[doc = "4: LF Oscillator frequency divided by 16"]
138    DIV16 = 4,
139    #[doc = "5: LF Oscillator frequency divided by 32"]
140    DIV32 = 5,
141    #[doc = "6: LF Oscillator frequency divided by 64"]
142    DIV64 = 6,
143    #[doc = "7: LF Oscillator frequency divided by 128"]
144    DIV128 = 7,
145}
146impl From<PRESC_A> for u8 {
147    #[inline(always)]
148    fn from(variant: PRESC_A) -> Self {
149        variant as _
150    }
151}
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, const O: u8> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, PRESC_A, 3, O>;
211impl<'a, const O: u8> PRESC_W<'a, O> {
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    #[must_use]
279    pub fn en(&mut self) -> EN_W<0> {
280        EN_W::new(self)
281    }
282    #[doc = "Bit 1 - Debug Mode Run Enable"]
283    #[inline(always)]
284    #[must_use]
285    pub fn debugrun(&mut self) -> DEBUGRUN_W<1> {
286        DEBUGRUN_W::new(self)
287    }
288    #[doc = "Bits 2:3 - Select Low Frequency Oscillator"]
289    #[inline(always)]
290    #[must_use]
291    pub fn oscsel(&mut self) -> OSCSEL_W<2> {
292        OSCSEL_W::new(self)
293    }
294    #[doc = "Bits 5:7 - Prescaler Setting"]
295    #[inline(always)]
296    #[must_use]
297    pub fn presc(&mut self) -> PRESC_W<5> {
298        PRESC_W::new(self)
299    }
300    #[doc = "Writes raw bits to the register."]
301    #[inline(always)]
302    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
303        self.0.bits(bits);
304        self
305    }
306}
307#[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"]
308pub struct CTRL_SPEC;
309impl crate::RegisterSpec for CTRL_SPEC {
310    type Ux = u32;
311}
312#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
313impl crate::Readable for CTRL_SPEC {
314    type Reader = R;
315}
316#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
317impl crate::Writable for CTRL_SPEC {
318    type Writer = W;
319    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
320    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
321}
322#[doc = "`reset()` method sets CTRL to value 0"]
323impl crate::Resettable for CTRL_SPEC {
324    const RESET_VALUE: Self::Ux = 0;
325}