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