efm32wg_pac/efm32wg230/cmu/
calctrl.rs

1#[doc = "Register `CALCTRL` reader"]
2pub struct R(crate::R<CALCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CALCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CALCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CALCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CALCTRL` writer"]
17pub struct W(crate::W<CALCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CALCTRL_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<CALCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CALCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `UPSEL` reader - Calibration Up-counter Select"]
38pub type UPSEL_R = crate::FieldReader<u8, UPSEL_A>;
39#[doc = "Calibration Up-counter Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum UPSEL_A {
43    #[doc = "0: Select HFXO as up-counter."]
44    HFXO = 0,
45    #[doc = "1: Select LFXO as up-counter."]
46    LFXO = 1,
47    #[doc = "2: Select HFRCO as up-counter."]
48    HFRCO = 2,
49    #[doc = "3: Select LFRCO as up-counter."]
50    LFRCO = 3,
51    #[doc = "4: Select AUXHFRCO as up-counter."]
52    AUXHFRCO = 4,
53}
54impl From<UPSEL_A> for u8 {
55    #[inline(always)]
56    fn from(variant: UPSEL_A) -> Self {
57        variant as _
58    }
59}
60impl UPSEL_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<UPSEL_A> {
64        match self.bits {
65            0 => Some(UPSEL_A::HFXO),
66            1 => Some(UPSEL_A::LFXO),
67            2 => Some(UPSEL_A::HFRCO),
68            3 => Some(UPSEL_A::LFRCO),
69            4 => Some(UPSEL_A::AUXHFRCO),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `HFXO`"]
74    #[inline(always)]
75    pub fn is_hfxo(&self) -> bool {
76        *self == UPSEL_A::HFXO
77    }
78    #[doc = "Checks if the value of the field is `LFXO`"]
79    #[inline(always)]
80    pub fn is_lfxo(&self) -> bool {
81        *self == UPSEL_A::LFXO
82    }
83    #[doc = "Checks if the value of the field is `HFRCO`"]
84    #[inline(always)]
85    pub fn is_hfrco(&self) -> bool {
86        *self == UPSEL_A::HFRCO
87    }
88    #[doc = "Checks if the value of the field is `LFRCO`"]
89    #[inline(always)]
90    pub fn is_lfrco(&self) -> bool {
91        *self == UPSEL_A::LFRCO
92    }
93    #[doc = "Checks if the value of the field is `AUXHFRCO`"]
94    #[inline(always)]
95    pub fn is_auxhfrco(&self) -> bool {
96        *self == UPSEL_A::AUXHFRCO
97    }
98}
99#[doc = "Field `UPSEL` writer - Calibration Up-counter Select"]
100pub type UPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, UPSEL_A, 3, O>;
101impl<'a, const O: u8> UPSEL_W<'a, O> {
102    #[doc = "Select HFXO as up-counter."]
103    #[inline(always)]
104    pub fn hfxo(self) -> &'a mut W {
105        self.variant(UPSEL_A::HFXO)
106    }
107    #[doc = "Select LFXO as up-counter."]
108    #[inline(always)]
109    pub fn lfxo(self) -> &'a mut W {
110        self.variant(UPSEL_A::LFXO)
111    }
112    #[doc = "Select HFRCO as up-counter."]
113    #[inline(always)]
114    pub fn hfrco(self) -> &'a mut W {
115        self.variant(UPSEL_A::HFRCO)
116    }
117    #[doc = "Select LFRCO as up-counter."]
118    #[inline(always)]
119    pub fn lfrco(self) -> &'a mut W {
120        self.variant(UPSEL_A::LFRCO)
121    }
122    #[doc = "Select AUXHFRCO as up-counter."]
123    #[inline(always)]
124    pub fn auxhfrco(self) -> &'a mut W {
125        self.variant(UPSEL_A::AUXHFRCO)
126    }
127}
128#[doc = "Field `DOWNSEL` reader - Calibration Down-counter Select"]
129pub type DOWNSEL_R = crate::FieldReader<u8, DOWNSEL_A>;
130#[doc = "Calibration Down-counter Select\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132#[repr(u8)]
133pub enum DOWNSEL_A {
134    #[doc = "0: Select HFCLK for down-counter."]
135    HFCLK = 0,
136    #[doc = "1: Select HFXO for down-counter."]
137    HFXO = 1,
138    #[doc = "2: Select LFXO for down-counter."]
139    LFXO = 2,
140    #[doc = "3: Select HFRCO for down-counter."]
141    HFRCO = 3,
142    #[doc = "4: Select LFRCO for down-counter."]
143    LFRCO = 4,
144    #[doc = "5: Select AUXHFRCO for down-counter."]
145    AUXHFRCO = 5,
146}
147impl From<DOWNSEL_A> for u8 {
148    #[inline(always)]
149    fn from(variant: DOWNSEL_A) -> Self {
150        variant as _
151    }
152}
153impl DOWNSEL_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> Option<DOWNSEL_A> {
157        match self.bits {
158            0 => Some(DOWNSEL_A::HFCLK),
159            1 => Some(DOWNSEL_A::HFXO),
160            2 => Some(DOWNSEL_A::LFXO),
161            3 => Some(DOWNSEL_A::HFRCO),
162            4 => Some(DOWNSEL_A::LFRCO),
163            5 => Some(DOWNSEL_A::AUXHFRCO),
164            _ => None,
165        }
166    }
167    #[doc = "Checks if the value of the field is `HFCLK`"]
168    #[inline(always)]
169    pub fn is_hfclk(&self) -> bool {
170        *self == DOWNSEL_A::HFCLK
171    }
172    #[doc = "Checks if the value of the field is `HFXO`"]
173    #[inline(always)]
174    pub fn is_hfxo(&self) -> bool {
175        *self == DOWNSEL_A::HFXO
176    }
177    #[doc = "Checks if the value of the field is `LFXO`"]
178    #[inline(always)]
179    pub fn is_lfxo(&self) -> bool {
180        *self == DOWNSEL_A::LFXO
181    }
182    #[doc = "Checks if the value of the field is `HFRCO`"]
183    #[inline(always)]
184    pub fn is_hfrco(&self) -> bool {
185        *self == DOWNSEL_A::HFRCO
186    }
187    #[doc = "Checks if the value of the field is `LFRCO`"]
188    #[inline(always)]
189    pub fn is_lfrco(&self) -> bool {
190        *self == DOWNSEL_A::LFRCO
191    }
192    #[doc = "Checks if the value of the field is `AUXHFRCO`"]
193    #[inline(always)]
194    pub fn is_auxhfrco(&self) -> bool {
195        *self == DOWNSEL_A::AUXHFRCO
196    }
197}
198#[doc = "Field `DOWNSEL` writer - Calibration Down-counter Select"]
199pub type DOWNSEL_W<'a, const O: u8> =
200    crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, DOWNSEL_A, 3, O>;
201impl<'a, const O: u8> DOWNSEL_W<'a, O> {
202    #[doc = "Select HFCLK for down-counter."]
203    #[inline(always)]
204    pub fn hfclk(self) -> &'a mut W {
205        self.variant(DOWNSEL_A::HFCLK)
206    }
207    #[doc = "Select HFXO for down-counter."]
208    #[inline(always)]
209    pub fn hfxo(self) -> &'a mut W {
210        self.variant(DOWNSEL_A::HFXO)
211    }
212    #[doc = "Select LFXO for down-counter."]
213    #[inline(always)]
214    pub fn lfxo(self) -> &'a mut W {
215        self.variant(DOWNSEL_A::LFXO)
216    }
217    #[doc = "Select HFRCO for down-counter."]
218    #[inline(always)]
219    pub fn hfrco(self) -> &'a mut W {
220        self.variant(DOWNSEL_A::HFRCO)
221    }
222    #[doc = "Select LFRCO for down-counter."]
223    #[inline(always)]
224    pub fn lfrco(self) -> &'a mut W {
225        self.variant(DOWNSEL_A::LFRCO)
226    }
227    #[doc = "Select AUXHFRCO for down-counter."]
228    #[inline(always)]
229    pub fn auxhfrco(self) -> &'a mut W {
230        self.variant(DOWNSEL_A::AUXHFRCO)
231    }
232}
233#[doc = "Field `CONT` reader - Continuous Calibration"]
234pub type CONT_R = crate::BitReader<bool>;
235#[doc = "Field `CONT` writer - Continuous Calibration"]
236pub type CONT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CALCTRL_SPEC, bool, O>;
237impl R {
238    #[doc = "Bits 0:2 - Calibration Up-counter Select"]
239    #[inline(always)]
240    pub fn upsel(&self) -> UPSEL_R {
241        UPSEL_R::new((self.bits & 7) as u8)
242    }
243    #[doc = "Bits 3:5 - Calibration Down-counter Select"]
244    #[inline(always)]
245    pub fn downsel(&self) -> DOWNSEL_R {
246        DOWNSEL_R::new(((self.bits >> 3) & 7) as u8)
247    }
248    #[doc = "Bit 6 - Continuous Calibration"]
249    #[inline(always)]
250    pub fn cont(&self) -> CONT_R {
251        CONT_R::new(((self.bits >> 6) & 1) != 0)
252    }
253}
254impl W {
255    #[doc = "Bits 0:2 - Calibration Up-counter Select"]
256    #[inline(always)]
257    #[must_use]
258    pub fn upsel(&mut self) -> UPSEL_W<0> {
259        UPSEL_W::new(self)
260    }
261    #[doc = "Bits 3:5 - Calibration Down-counter Select"]
262    #[inline(always)]
263    #[must_use]
264    pub fn downsel(&mut self) -> DOWNSEL_W<3> {
265        DOWNSEL_W::new(self)
266    }
267    #[doc = "Bit 6 - Continuous Calibration"]
268    #[inline(always)]
269    #[must_use]
270    pub fn cont(&mut self) -> CONT_W<6> {
271        CONT_W::new(self)
272    }
273    #[doc = "Writes raw bits to the register."]
274    #[inline(always)]
275    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
276        self.0.bits(bits);
277        self
278    }
279}
280#[doc = "Calibration 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 [calctrl](index.html) module"]
281pub struct CALCTRL_SPEC;
282impl crate::RegisterSpec for CALCTRL_SPEC {
283    type Ux = u32;
284}
285#[doc = "`read()` method returns [calctrl::R](R) reader structure"]
286impl crate::Readable for CALCTRL_SPEC {
287    type Reader = R;
288}
289#[doc = "`write(|w| ..)` method takes [calctrl::W](W) writer structure"]
290impl crate::Writable for CALCTRL_SPEC {
291    type Writer = W;
292    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
293    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
294}
295#[doc = "`reset()` method sets CALCTRL to value 0"]
296impl crate::Resettable for CALCTRL_SPEC {
297    const RESET_VALUE: Self::Ux = 0;
298}