efm32tg11b520_pac/cmu/
lfrcoctrl.rs

1#[doc = "Register `LFRCOCTRL` reader"]
2pub struct R(crate::R<LFRCOCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<LFRCOCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<LFRCOCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<LFRCOCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `LFRCOCTRL` writer"]
17pub struct W(crate::W<LFRCOCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<LFRCOCTRL_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<LFRCOCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<LFRCOCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TUNING` reader - LFRCO Tuning Value"]
38pub type TUNING_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `TUNING` writer - LFRCO Tuning Value"]
40pub type TUNING_W<'a> = crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u16, u16, 9, 0>;
41#[doc = "Field `ENVREF` reader - Enable Duty Cycling of Vref"]
42pub type ENVREF_R = crate::BitReader<bool>;
43#[doc = "Field `ENVREF` writer - Enable Duty Cycling of Vref"]
44pub type ENVREF_W<'a> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, 16>;
45#[doc = "Field `ENCHOP` reader - Enable Comparator Chopping"]
46pub type ENCHOP_R = crate::BitReader<bool>;
47#[doc = "Field `ENCHOP` writer - Enable Comparator Chopping"]
48pub type ENCHOP_W<'a> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, 17>;
49#[doc = "Field `ENDEM` reader - Enable Dynamic Element Matching"]
50pub type ENDEM_R = crate::BitReader<bool>;
51#[doc = "Field `ENDEM` writer - Enable Dynamic Element Matching"]
52pub type ENDEM_W<'a> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, 18>;
53#[doc = "Control Vref Update Rate\n\nValue on reset: 0"]
54#[derive(Clone, Copy, Debug, PartialEq)]
55#[repr(u8)]
56pub enum VREFUPDATE_A {
57    #[doc = "0: 32 clocks."]
58    _32CYCLES = 0,
59    #[doc = "1: 64 clocks."]
60    _64CYCLES = 1,
61    #[doc = "2: 128 clocks."]
62    _128CYCLES = 2,
63    #[doc = "3: 256 clocks."]
64    _256CYCLES = 3,
65}
66impl From<VREFUPDATE_A> for u8 {
67    #[inline(always)]
68    fn from(variant: VREFUPDATE_A) -> Self {
69        variant as _
70    }
71}
72#[doc = "Field `VREFUPDATE` reader - Control Vref Update Rate"]
73pub type VREFUPDATE_R = crate::FieldReader<u8, VREFUPDATE_A>;
74impl VREFUPDATE_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub fn variant(&self) -> VREFUPDATE_A {
78        match self.bits {
79            0 => VREFUPDATE_A::_32CYCLES,
80            1 => VREFUPDATE_A::_64CYCLES,
81            2 => VREFUPDATE_A::_128CYCLES,
82            3 => VREFUPDATE_A::_256CYCLES,
83            _ => unreachable!(),
84        }
85    }
86    #[doc = "Checks if the value of the field is `_32CYCLES`"]
87    #[inline(always)]
88    pub fn is_32cycles(&self) -> bool {
89        *self == VREFUPDATE_A::_32CYCLES
90    }
91    #[doc = "Checks if the value of the field is `_64CYCLES`"]
92    #[inline(always)]
93    pub fn is_64cycles(&self) -> bool {
94        *self == VREFUPDATE_A::_64CYCLES
95    }
96    #[doc = "Checks if the value of the field is `_128CYCLES`"]
97    #[inline(always)]
98    pub fn is_128cycles(&self) -> bool {
99        *self == VREFUPDATE_A::_128CYCLES
100    }
101    #[doc = "Checks if the value of the field is `_256CYCLES`"]
102    #[inline(always)]
103    pub fn is_256cycles(&self) -> bool {
104        *self == VREFUPDATE_A::_256CYCLES
105    }
106}
107#[doc = "Field `VREFUPDATE` writer - Control Vref Update Rate"]
108pub type VREFUPDATE_W<'a> =
109    crate::FieldWriterSafe<'a, u32, LFRCOCTRL_SPEC, u8, VREFUPDATE_A, 2, 20>;
110impl<'a> VREFUPDATE_W<'a> {
111    #[doc = "32 clocks."]
112    #[inline(always)]
113    pub fn _32cycles(self) -> &'a mut W {
114        self.variant(VREFUPDATE_A::_32CYCLES)
115    }
116    #[doc = "64 clocks."]
117    #[inline(always)]
118    pub fn _64cycles(self) -> &'a mut W {
119        self.variant(VREFUPDATE_A::_64CYCLES)
120    }
121    #[doc = "128 clocks."]
122    #[inline(always)]
123    pub fn _128cycles(self) -> &'a mut W {
124        self.variant(VREFUPDATE_A::_128CYCLES)
125    }
126    #[doc = "256 clocks."]
127    #[inline(always)]
128    pub fn _256cycles(self) -> &'a mut W {
129        self.variant(VREFUPDATE_A::_256CYCLES)
130    }
131}
132#[doc = "LFRCO Timeout\n\nValue on reset: 1"]
133#[derive(Clone, Copy, Debug, PartialEq)]
134#[repr(u8)]
135pub enum TIMEOUT_A {
136    #[doc = "0: Timeout period of 2 cycles"]
137    _2CYCLES = 0,
138    #[doc = "1: Timeout period of 16 cycles"]
139    _16CYCLES = 1,
140    #[doc = "2: Timeout period of 32 cycles"]
141    _32CYCLES = 2,
142}
143impl From<TIMEOUT_A> for u8 {
144    #[inline(always)]
145    fn from(variant: TIMEOUT_A) -> Self {
146        variant as _
147    }
148}
149#[doc = "Field `TIMEOUT` reader - LFRCO Timeout"]
150pub type TIMEOUT_R = crate::FieldReader<u8, TIMEOUT_A>;
151impl TIMEOUT_R {
152    #[doc = "Get enumerated values variant"]
153    #[inline(always)]
154    pub fn variant(&self) -> Option<TIMEOUT_A> {
155        match self.bits {
156            0 => Some(TIMEOUT_A::_2CYCLES),
157            1 => Some(TIMEOUT_A::_16CYCLES),
158            2 => Some(TIMEOUT_A::_32CYCLES),
159            _ => None,
160        }
161    }
162    #[doc = "Checks if the value of the field is `_2CYCLES`"]
163    #[inline(always)]
164    pub fn is_2cycles(&self) -> bool {
165        *self == TIMEOUT_A::_2CYCLES
166    }
167    #[doc = "Checks if the value of the field is `_16CYCLES`"]
168    #[inline(always)]
169    pub fn is_16cycles(&self) -> bool {
170        *self == TIMEOUT_A::_16CYCLES
171    }
172    #[doc = "Checks if the value of the field is `_32CYCLES`"]
173    #[inline(always)]
174    pub fn is_32cycles(&self) -> bool {
175        *self == TIMEOUT_A::_32CYCLES
176    }
177}
178#[doc = "Field `TIMEOUT` writer - LFRCO Timeout"]
179pub type TIMEOUT_W<'a> = crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u8, TIMEOUT_A, 2, 24>;
180impl<'a> TIMEOUT_W<'a> {
181    #[doc = "Timeout period of 2 cycles"]
182    #[inline(always)]
183    pub fn _2cycles(self) -> &'a mut W {
184        self.variant(TIMEOUT_A::_2CYCLES)
185    }
186    #[doc = "Timeout period of 16 cycles"]
187    #[inline(always)]
188    pub fn _16cycles(self) -> &'a mut W {
189        self.variant(TIMEOUT_A::_16CYCLES)
190    }
191    #[doc = "Timeout period of 32 cycles"]
192    #[inline(always)]
193    pub fn _32cycles(self) -> &'a mut W {
194        self.variant(TIMEOUT_A::_32CYCLES)
195    }
196}
197#[doc = "Field `GMCCURTUNE` reader - Tuning of Gmc Current"]
198pub type GMCCURTUNE_R = crate::FieldReader<u8, u8>;
199#[doc = "Field `GMCCURTUNE` writer - Tuning of Gmc Current"]
200pub type GMCCURTUNE_W<'a> = crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u8, u8, 4, 28>;
201impl R {
202    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
203    #[inline(always)]
204    pub fn tuning(&self) -> TUNING_R {
205        TUNING_R::new((self.bits & 0x01ff) as u16)
206    }
207    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
208    #[inline(always)]
209    pub fn envref(&self) -> ENVREF_R {
210        ENVREF_R::new(((self.bits >> 16) & 1) != 0)
211    }
212    #[doc = "Bit 17 - Enable Comparator Chopping"]
213    #[inline(always)]
214    pub fn enchop(&self) -> ENCHOP_R {
215        ENCHOP_R::new(((self.bits >> 17) & 1) != 0)
216    }
217    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
218    #[inline(always)]
219    pub fn endem(&self) -> ENDEM_R {
220        ENDEM_R::new(((self.bits >> 18) & 1) != 0)
221    }
222    #[doc = "Bits 20:21 - Control Vref Update Rate"]
223    #[inline(always)]
224    pub fn vrefupdate(&self) -> VREFUPDATE_R {
225        VREFUPDATE_R::new(((self.bits >> 20) & 3) as u8)
226    }
227    #[doc = "Bits 24:25 - LFRCO Timeout"]
228    #[inline(always)]
229    pub fn timeout(&self) -> TIMEOUT_R {
230        TIMEOUT_R::new(((self.bits >> 24) & 3) as u8)
231    }
232    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
233    #[inline(always)]
234    pub fn gmccurtune(&self) -> GMCCURTUNE_R {
235        GMCCURTUNE_R::new(((self.bits >> 28) & 0x0f) as u8)
236    }
237}
238impl W {
239    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
240    #[inline(always)]
241    pub fn tuning(&mut self) -> TUNING_W {
242        TUNING_W::new(self)
243    }
244    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
245    #[inline(always)]
246    pub fn envref(&mut self) -> ENVREF_W {
247        ENVREF_W::new(self)
248    }
249    #[doc = "Bit 17 - Enable Comparator Chopping"]
250    #[inline(always)]
251    pub fn enchop(&mut self) -> ENCHOP_W {
252        ENCHOP_W::new(self)
253    }
254    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
255    #[inline(always)]
256    pub fn endem(&mut self) -> ENDEM_W {
257        ENDEM_W::new(self)
258    }
259    #[doc = "Bits 20:21 - Control Vref Update Rate"]
260    #[inline(always)]
261    pub fn vrefupdate(&mut self) -> VREFUPDATE_W {
262        VREFUPDATE_W::new(self)
263    }
264    #[doc = "Bits 24:25 - LFRCO Timeout"]
265    #[inline(always)]
266    pub fn timeout(&mut self) -> TIMEOUT_W {
267        TIMEOUT_W::new(self)
268    }
269    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
270    #[inline(always)]
271    pub fn gmccurtune(&mut self) -> GMCCURTUNE_W {
272        GMCCURTUNE_W::new(self)
273    }
274    #[doc = "Writes raw bits to the register."]
275    #[inline(always)]
276    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
277        self.0.bits(bits);
278        self
279    }
280}
281#[doc = "LFRCO 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 [lfrcoctrl](index.html) module"]
282pub struct LFRCOCTRL_SPEC;
283impl crate::RegisterSpec for LFRCOCTRL_SPEC {
284    type Ux = u32;
285}
286#[doc = "`read()` method returns [lfrcoctrl::R](R) reader structure"]
287impl crate::Readable for LFRCOCTRL_SPEC {
288    type Reader = R;
289}
290#[doc = "`write(|w| ..)` method takes [lfrcoctrl::W](W) writer structure"]
291impl crate::Writable for LFRCOCTRL_SPEC {
292    type Writer = W;
293}
294#[doc = "`reset()` method sets LFRCOCTRL to value 0x8106_0100"]
295impl crate::Resettable for LFRCOCTRL_SPEC {
296    #[inline(always)]
297    fn reset_value() -> Self::Ux {
298        0x8106_0100
299    }
300}