efm32pg12_pac/cmu/
lfrcoctrl.rs

1#[doc = "Reader of register LFRCOCTRL"]
2pub type R = crate::R<u32, super::LFRCOCTRL>;
3#[doc = "Writer for register LFRCOCTRL"]
4pub type W = crate::W<u32, super::LFRCOCTRL>;
5#[doc = "Register LFRCOCTRL `reset()`'s with value 0x8106_0100"]
6impl crate::ResetValue for super::LFRCOCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x8106_0100
11    }
12}
13#[doc = "Reader of field `TUNING`"]
14pub type TUNING_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `TUNING`"]
16pub struct TUNING_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> TUNING_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x01ff) | ((value as u32) & 0x01ff);
24        self.w
25    }
26}
27#[doc = "Reader of field `ENVREF`"]
28pub type ENVREF_R = crate::R<bool, bool>;
29#[doc = "Write proxy for field `ENVREF`"]
30pub struct ENVREF_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> ENVREF_W<'a> {
34    #[doc = r"Sets the field bit"]
35    #[inline(always)]
36    pub fn set_bit(self) -> &'a mut W {
37        self.bit(true)
38    }
39    #[doc = r"Clears the field bit"]
40    #[inline(always)]
41    pub fn clear_bit(self) -> &'a mut W {
42        self.bit(false)
43    }
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub fn bit(self, value: bool) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
48        self.w
49    }
50}
51#[doc = "Reader of field `ENCHOP`"]
52pub type ENCHOP_R = crate::R<bool, bool>;
53#[doc = "Write proxy for field `ENCHOP`"]
54pub struct ENCHOP_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> ENCHOP_W<'a> {
58    #[doc = r"Sets the field bit"]
59    #[inline(always)]
60    pub fn set_bit(self) -> &'a mut W {
61        self.bit(true)
62    }
63    #[doc = r"Clears the field bit"]
64    #[inline(always)]
65    pub fn clear_bit(self) -> &'a mut W {
66        self.bit(false)
67    }
68    #[doc = r"Writes raw bits to the field"]
69    #[inline(always)]
70    pub fn bit(self, value: bool) -> &'a mut W {
71        self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17);
72        self.w
73    }
74}
75#[doc = "Reader of field `ENDEM`"]
76pub type ENDEM_R = crate::R<bool, bool>;
77#[doc = "Write proxy for field `ENDEM`"]
78pub struct ENDEM_W<'a> {
79    w: &'a mut W,
80}
81impl<'a> ENDEM_W<'a> {
82    #[doc = r"Sets the field bit"]
83    #[inline(always)]
84    pub fn set_bit(self) -> &'a mut W {
85        self.bit(true)
86    }
87    #[doc = r"Clears the field bit"]
88    #[inline(always)]
89    pub fn clear_bit(self) -> &'a mut W {
90        self.bit(false)
91    }
92    #[doc = r"Writes raw bits to the field"]
93    #[inline(always)]
94    pub fn bit(self, value: bool) -> &'a mut W {
95        self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18);
96        self.w
97    }
98}
99#[doc = "Control Vref Update Rate\n\nValue on reset: 0"]
100#[derive(Clone, Copy, Debug, PartialEq)]
101#[repr(u8)]
102pub enum VREFUPDATE_A {
103    #[doc = "0: 32 clocks."]
104    _32CYCLES = 0,
105    #[doc = "1: 64 clocks."]
106    _64CYCLES = 1,
107    #[doc = "2: 128 clocks."]
108    _128CYCLES = 2,
109    #[doc = "3: 256 clocks."]
110    _256CYCLES = 3,
111}
112impl From<VREFUPDATE_A> for u8 {
113    #[inline(always)]
114    fn from(variant: VREFUPDATE_A) -> Self {
115        variant as _
116    }
117}
118#[doc = "Reader of field `VREFUPDATE`"]
119pub type VREFUPDATE_R = crate::R<u8, VREFUPDATE_A>;
120impl VREFUPDATE_R {
121    #[doc = r"Get enumerated values variant"]
122    #[inline(always)]
123    pub fn variant(&self) -> VREFUPDATE_A {
124        match self.bits {
125            0 => VREFUPDATE_A::_32CYCLES,
126            1 => VREFUPDATE_A::_64CYCLES,
127            2 => VREFUPDATE_A::_128CYCLES,
128            3 => VREFUPDATE_A::_256CYCLES,
129            _ => unreachable!(),
130        }
131    }
132    #[doc = "Checks if the value of the field is `_32CYCLES`"]
133    #[inline(always)]
134    pub fn is_32cycles(&self) -> bool {
135        *self == VREFUPDATE_A::_32CYCLES
136    }
137    #[doc = "Checks if the value of the field is `_64CYCLES`"]
138    #[inline(always)]
139    pub fn is_64cycles(&self) -> bool {
140        *self == VREFUPDATE_A::_64CYCLES
141    }
142    #[doc = "Checks if the value of the field is `_128CYCLES`"]
143    #[inline(always)]
144    pub fn is_128cycles(&self) -> bool {
145        *self == VREFUPDATE_A::_128CYCLES
146    }
147    #[doc = "Checks if the value of the field is `_256CYCLES`"]
148    #[inline(always)]
149    pub fn is_256cycles(&self) -> bool {
150        *self == VREFUPDATE_A::_256CYCLES
151    }
152}
153#[doc = "Write proxy for field `VREFUPDATE`"]
154pub struct VREFUPDATE_W<'a> {
155    w: &'a mut W,
156}
157impl<'a> VREFUPDATE_W<'a> {
158    #[doc = r"Writes `variant` to the field"]
159    #[inline(always)]
160    pub fn variant(self, variant: VREFUPDATE_A) -> &'a mut W {
161        {
162            self.bits(variant.into())
163        }
164    }
165    #[doc = "32 clocks."]
166    #[inline(always)]
167    pub fn _32cycles(self) -> &'a mut W {
168        self.variant(VREFUPDATE_A::_32CYCLES)
169    }
170    #[doc = "64 clocks."]
171    #[inline(always)]
172    pub fn _64cycles(self) -> &'a mut W {
173        self.variant(VREFUPDATE_A::_64CYCLES)
174    }
175    #[doc = "128 clocks."]
176    #[inline(always)]
177    pub fn _128cycles(self) -> &'a mut W {
178        self.variant(VREFUPDATE_A::_128CYCLES)
179    }
180    #[doc = "256 clocks."]
181    #[inline(always)]
182    pub fn _256cycles(self) -> &'a mut W {
183        self.variant(VREFUPDATE_A::_256CYCLES)
184    }
185    #[doc = r"Writes raw bits to the field"]
186    #[inline(always)]
187    pub fn bits(self, value: u8) -> &'a mut W {
188        self.w.bits = (self.w.bits & !(0x03 << 20)) | (((value as u32) & 0x03) << 20);
189        self.w
190    }
191}
192#[doc = "LFRCO Timeout\n\nValue on reset: 1"]
193#[derive(Clone, Copy, Debug, PartialEq)]
194#[repr(u8)]
195pub enum TIMEOUT_A {
196    #[doc = "0: Timeout period of 2 cycles"]
197    _2CYCLES = 0,
198    #[doc = "1: Timeout period of 16 cycles"]
199    _16CYCLES = 1,
200    #[doc = "2: Timeout period of 32 cycles"]
201    _32CYCLES = 2,
202}
203impl From<TIMEOUT_A> for u8 {
204    #[inline(always)]
205    fn from(variant: TIMEOUT_A) -> Self {
206        variant as _
207    }
208}
209#[doc = "Reader of field `TIMEOUT`"]
210pub type TIMEOUT_R = crate::R<u8, TIMEOUT_A>;
211impl TIMEOUT_R {
212    #[doc = r"Get enumerated values variant"]
213    #[inline(always)]
214    pub fn variant(&self) -> crate::Variant<u8, TIMEOUT_A> {
215        use crate::Variant::*;
216        match self.bits {
217            0 => Val(TIMEOUT_A::_2CYCLES),
218            1 => Val(TIMEOUT_A::_16CYCLES),
219            2 => Val(TIMEOUT_A::_32CYCLES),
220            i => Res(i),
221        }
222    }
223    #[doc = "Checks if the value of the field is `_2CYCLES`"]
224    #[inline(always)]
225    pub fn is_2cycles(&self) -> bool {
226        *self == TIMEOUT_A::_2CYCLES
227    }
228    #[doc = "Checks if the value of the field is `_16CYCLES`"]
229    #[inline(always)]
230    pub fn is_16cycles(&self) -> bool {
231        *self == TIMEOUT_A::_16CYCLES
232    }
233    #[doc = "Checks if the value of the field is `_32CYCLES`"]
234    #[inline(always)]
235    pub fn is_32cycles(&self) -> bool {
236        *self == TIMEOUT_A::_32CYCLES
237    }
238}
239#[doc = "Write proxy for field `TIMEOUT`"]
240pub struct TIMEOUT_W<'a> {
241    w: &'a mut W,
242}
243impl<'a> TIMEOUT_W<'a> {
244    #[doc = r"Writes `variant` to the field"]
245    #[inline(always)]
246    pub fn variant(self, variant: TIMEOUT_A) -> &'a mut W {
247        unsafe { self.bits(variant.into()) }
248    }
249    #[doc = "Timeout period of 2 cycles"]
250    #[inline(always)]
251    pub fn _2cycles(self) -> &'a mut W {
252        self.variant(TIMEOUT_A::_2CYCLES)
253    }
254    #[doc = "Timeout period of 16 cycles"]
255    #[inline(always)]
256    pub fn _16cycles(self) -> &'a mut W {
257        self.variant(TIMEOUT_A::_16CYCLES)
258    }
259    #[doc = "Timeout period of 32 cycles"]
260    #[inline(always)]
261    pub fn _32cycles(self) -> &'a mut W {
262        self.variant(TIMEOUT_A::_32CYCLES)
263    }
264    #[doc = r"Writes raw bits to the field"]
265    #[inline(always)]
266    pub unsafe fn bits(self, value: u8) -> &'a mut W {
267        self.w.bits = (self.w.bits & !(0x03 << 24)) | (((value as u32) & 0x03) << 24);
268        self.w
269    }
270}
271#[doc = "Reader of field `GMCCURTUNE`"]
272pub type GMCCURTUNE_R = crate::R<u8, u8>;
273#[doc = "Write proxy for field `GMCCURTUNE`"]
274pub struct GMCCURTUNE_W<'a> {
275    w: &'a mut W,
276}
277impl<'a> GMCCURTUNE_W<'a> {
278    #[doc = r"Writes raw bits to the field"]
279    #[inline(always)]
280    pub unsafe fn bits(self, value: u8) -> &'a mut W {
281        self.w.bits = (self.w.bits & !(0x0f << 28)) | (((value as u32) & 0x0f) << 28);
282        self.w
283    }
284}
285impl R {
286    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
287    #[inline(always)]
288    pub fn tuning(&self) -> TUNING_R {
289        TUNING_R::new((self.bits & 0x01ff) as u16)
290    }
291    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
292    #[inline(always)]
293    pub fn envref(&self) -> ENVREF_R {
294        ENVREF_R::new(((self.bits >> 16) & 0x01) != 0)
295    }
296    #[doc = "Bit 17 - Enable Comparator Chopping"]
297    #[inline(always)]
298    pub fn enchop(&self) -> ENCHOP_R {
299        ENCHOP_R::new(((self.bits >> 17) & 0x01) != 0)
300    }
301    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
302    #[inline(always)]
303    pub fn endem(&self) -> ENDEM_R {
304        ENDEM_R::new(((self.bits >> 18) & 0x01) != 0)
305    }
306    #[doc = "Bits 20:21 - Control Vref Update Rate"]
307    #[inline(always)]
308    pub fn vrefupdate(&self) -> VREFUPDATE_R {
309        VREFUPDATE_R::new(((self.bits >> 20) & 0x03) as u8)
310    }
311    #[doc = "Bits 24:25 - LFRCO Timeout"]
312    #[inline(always)]
313    pub fn timeout(&self) -> TIMEOUT_R {
314        TIMEOUT_R::new(((self.bits >> 24) & 0x03) as u8)
315    }
316    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
317    #[inline(always)]
318    pub fn gmccurtune(&self) -> GMCCURTUNE_R {
319        GMCCURTUNE_R::new(((self.bits >> 28) & 0x0f) as u8)
320    }
321}
322impl W {
323    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
324    #[inline(always)]
325    pub fn tuning(&mut self) -> TUNING_W {
326        TUNING_W { w: self }
327    }
328    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
329    #[inline(always)]
330    pub fn envref(&mut self) -> ENVREF_W {
331        ENVREF_W { w: self }
332    }
333    #[doc = "Bit 17 - Enable Comparator Chopping"]
334    #[inline(always)]
335    pub fn enchop(&mut self) -> ENCHOP_W {
336        ENCHOP_W { w: self }
337    }
338    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
339    #[inline(always)]
340    pub fn endem(&mut self) -> ENDEM_W {
341        ENDEM_W { w: self }
342    }
343    #[doc = "Bits 20:21 - Control Vref Update Rate"]
344    #[inline(always)]
345    pub fn vrefupdate(&mut self) -> VREFUPDATE_W {
346        VREFUPDATE_W { w: self }
347    }
348    #[doc = "Bits 24:25 - LFRCO Timeout"]
349    #[inline(always)]
350    pub fn timeout(&mut self) -> TIMEOUT_W {
351        TIMEOUT_W { w: self }
352    }
353    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
354    #[inline(always)]
355    pub fn gmccurtune(&mut self) -> GMCCURTUNE_W {
356        GMCCURTUNE_W { w: self }
357    }
358}