efm32gg_pac/efm32gg230/adc0/
ctrl.rs1#[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 `WARMUPMODE` reader - Warm-up Mode"]
38pub type WARMUPMODE_R = crate::FieldReader<u8, WARMUPMODE_A>;
39#[doc = "Warm-up Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum WARMUPMODE_A {
43 #[doc = "0: ADC is shut down after each conversion"]
44 NORMAL = 0,
45 #[doc = "1: Bandgap references do not need warm up, but have reduced accuracy."]
46 FASTBG = 1,
47 #[doc = "2: Reference selected for scan mode is kept warm."]
48 KEEPSCANREFWARM = 2,
49 #[doc = "3: ADC is kept warmed up and scan reference is kept warm"]
50 KEEPADCWARM = 3,
51}
52impl From<WARMUPMODE_A> for u8 {
53 #[inline(always)]
54 fn from(variant: WARMUPMODE_A) -> Self {
55 variant as _
56 }
57}
58impl WARMUPMODE_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> WARMUPMODE_A {
62 match self.bits {
63 0 => WARMUPMODE_A::NORMAL,
64 1 => WARMUPMODE_A::FASTBG,
65 2 => WARMUPMODE_A::KEEPSCANREFWARM,
66 3 => WARMUPMODE_A::KEEPADCWARM,
67 _ => unreachable!(),
68 }
69 }
70 #[doc = "Checks if the value of the field is `NORMAL`"]
71 #[inline(always)]
72 pub fn is_normal(&self) -> bool {
73 *self == WARMUPMODE_A::NORMAL
74 }
75 #[doc = "Checks if the value of the field is `FASTBG`"]
76 #[inline(always)]
77 pub fn is_fastbg(&self) -> bool {
78 *self == WARMUPMODE_A::FASTBG
79 }
80 #[doc = "Checks if the value of the field is `KEEPSCANREFWARM`"]
81 #[inline(always)]
82 pub fn is_keepscanrefwarm(&self) -> bool {
83 *self == WARMUPMODE_A::KEEPSCANREFWARM
84 }
85 #[doc = "Checks if the value of the field is `KEEPADCWARM`"]
86 #[inline(always)]
87 pub fn is_keepadcwarm(&self) -> bool {
88 *self == WARMUPMODE_A::KEEPADCWARM
89 }
90}
91#[doc = "Field `WARMUPMODE` writer - Warm-up Mode"]
92pub type WARMUPMODE_W<'a, const O: u8> =
93 crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, WARMUPMODE_A, 2, O>;
94impl<'a, const O: u8> WARMUPMODE_W<'a, O> {
95 #[doc = "ADC is shut down after each conversion"]
96 #[inline(always)]
97 pub fn normal(self) -> &'a mut W {
98 self.variant(WARMUPMODE_A::NORMAL)
99 }
100 #[doc = "Bandgap references do not need warm up, but have reduced accuracy."]
101 #[inline(always)]
102 pub fn fastbg(self) -> &'a mut W {
103 self.variant(WARMUPMODE_A::FASTBG)
104 }
105 #[doc = "Reference selected for scan mode is kept warm."]
106 #[inline(always)]
107 pub fn keepscanrefwarm(self) -> &'a mut W {
108 self.variant(WARMUPMODE_A::KEEPSCANREFWARM)
109 }
110 #[doc = "ADC is kept warmed up and scan reference is kept warm"]
111 #[inline(always)]
112 pub fn keepadcwarm(self) -> &'a mut W {
113 self.variant(WARMUPMODE_A::KEEPADCWARM)
114 }
115}
116#[doc = "Field `TAILGATE` reader - Conversion Tailgating"]
117pub type TAILGATE_R = crate::BitReader<bool>;
118#[doc = "Field `TAILGATE` writer - Conversion Tailgating"]
119pub type TAILGATE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
120#[doc = "Field `LPFMODE` reader - Low Pass Filter Mode"]
121pub type LPFMODE_R = crate::FieldReader<u8, LPFMODE_A>;
122#[doc = "Low Pass Filter Mode\n\nValue on reset: 0"]
123#[derive(Clone, Copy, Debug, PartialEq, Eq)]
124#[repr(u8)]
125pub enum LPFMODE_A {
126 #[doc = "0: No filter or decoupling capacitor"]
127 BYPASS = 0,
128 #[doc = "1: On chip decoupling capacitor selected"]
129 DECAP = 1,
130 #[doc = "2: On chip RC filter selected"]
131 RCFILT = 2,
132}
133impl From<LPFMODE_A> for u8 {
134 #[inline(always)]
135 fn from(variant: LPFMODE_A) -> Self {
136 variant as _
137 }
138}
139impl LPFMODE_R {
140 #[doc = "Get enumerated values variant"]
141 #[inline(always)]
142 pub fn variant(&self) -> Option<LPFMODE_A> {
143 match self.bits {
144 0 => Some(LPFMODE_A::BYPASS),
145 1 => Some(LPFMODE_A::DECAP),
146 2 => Some(LPFMODE_A::RCFILT),
147 _ => None,
148 }
149 }
150 #[doc = "Checks if the value of the field is `BYPASS`"]
151 #[inline(always)]
152 pub fn is_bypass(&self) -> bool {
153 *self == LPFMODE_A::BYPASS
154 }
155 #[doc = "Checks if the value of the field is `DECAP`"]
156 #[inline(always)]
157 pub fn is_decap(&self) -> bool {
158 *self == LPFMODE_A::DECAP
159 }
160 #[doc = "Checks if the value of the field is `RCFILT`"]
161 #[inline(always)]
162 pub fn is_rcfilt(&self) -> bool {
163 *self == LPFMODE_A::RCFILT
164 }
165}
166#[doc = "Field `LPFMODE` writer - Low Pass Filter Mode"]
167pub type LPFMODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, LPFMODE_A, 2, O>;
168impl<'a, const O: u8> LPFMODE_W<'a, O> {
169 #[doc = "No filter or decoupling capacitor"]
170 #[inline(always)]
171 pub fn bypass(self) -> &'a mut W {
172 self.variant(LPFMODE_A::BYPASS)
173 }
174 #[doc = "On chip decoupling capacitor selected"]
175 #[inline(always)]
176 pub fn decap(self) -> &'a mut W {
177 self.variant(LPFMODE_A::DECAP)
178 }
179 #[doc = "On chip RC filter selected"]
180 #[inline(always)]
181 pub fn rcfilt(self) -> &'a mut W {
182 self.variant(LPFMODE_A::RCFILT)
183 }
184}
185#[doc = "Field `PRESC` reader - Prescaler Setting"]
186pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
187#[doc = "Prescaler Setting\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq, Eq)]
189#[repr(u8)]
190pub enum PRESC_A {
191 #[doc = "0: `0`"]
192 NODIVISION = 0,
193}
194impl From<PRESC_A> for u8 {
195 #[inline(always)]
196 fn from(variant: PRESC_A) -> Self {
197 variant as _
198 }
199}
200impl PRESC_R {
201 #[doc = "Get enumerated values variant"]
202 #[inline(always)]
203 pub fn variant(&self) -> Option<PRESC_A> {
204 match self.bits {
205 0 => Some(PRESC_A::NODIVISION),
206 _ => None,
207 }
208 }
209 #[doc = "Checks if the value of the field is `NODIVISION`"]
210 #[inline(always)]
211 pub fn is_nodivision(&self) -> bool {
212 *self == PRESC_A::NODIVISION
213 }
214}
215#[doc = "Field `PRESC` writer - Prescaler Setting"]
216pub type PRESC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, PRESC_A, 7, O>;
217impl<'a, const O: u8> PRESC_W<'a, O> {
218 #[doc = "`0`"]
219 #[inline(always)]
220 pub fn nodivision(self) -> &'a mut W {
221 self.variant(PRESC_A::NODIVISION)
222 }
223}
224#[doc = "Field `TIMEBASE` reader - Time Base"]
225pub type TIMEBASE_R = crate::FieldReader<u8, u8>;
226#[doc = "Field `TIMEBASE` writer - Time Base"]
227pub type TIMEBASE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 5, O>;
228#[doc = "Field `OVSRSEL` reader - Oversample Rate Select"]
229pub type OVSRSEL_R = crate::FieldReader<u8, OVSRSEL_A>;
230#[doc = "Oversample Rate Select\n\nValue on reset: 0"]
231#[derive(Clone, Copy, Debug, PartialEq, Eq)]
232#[repr(u8)]
233pub enum OVSRSEL_A {
234 #[doc = "0: 2 samples for each conversion result"]
235 X2 = 0,
236 #[doc = "1: 4 samples for each conversion result"]
237 X4 = 1,
238 #[doc = "2: 8 samples for each conversion result"]
239 X8 = 2,
240 #[doc = "3: 16 samples for each conversion result"]
241 X16 = 3,
242 #[doc = "4: 32 samples for each conversion result"]
243 X32 = 4,
244 #[doc = "5: 64 samples for each conversion result"]
245 X64 = 5,
246 #[doc = "6: 128 samples for each conversion result"]
247 X128 = 6,
248 #[doc = "7: 256 samples for each conversion result"]
249 X256 = 7,
250 #[doc = "8: 512 samples for each conversion result"]
251 X512 = 8,
252 #[doc = "9: 1024 samples for each conversion result"]
253 X1024 = 9,
254 #[doc = "10: 2048 samples for each conversion result"]
255 X2048 = 10,
256 #[doc = "11: 4096 samples for each conversion result"]
257 X4096 = 11,
258}
259impl From<OVSRSEL_A> for u8 {
260 #[inline(always)]
261 fn from(variant: OVSRSEL_A) -> Self {
262 variant as _
263 }
264}
265impl OVSRSEL_R {
266 #[doc = "Get enumerated values variant"]
267 #[inline(always)]
268 pub fn variant(&self) -> Option<OVSRSEL_A> {
269 match self.bits {
270 0 => Some(OVSRSEL_A::X2),
271 1 => Some(OVSRSEL_A::X4),
272 2 => Some(OVSRSEL_A::X8),
273 3 => Some(OVSRSEL_A::X16),
274 4 => Some(OVSRSEL_A::X32),
275 5 => Some(OVSRSEL_A::X64),
276 6 => Some(OVSRSEL_A::X128),
277 7 => Some(OVSRSEL_A::X256),
278 8 => Some(OVSRSEL_A::X512),
279 9 => Some(OVSRSEL_A::X1024),
280 10 => Some(OVSRSEL_A::X2048),
281 11 => Some(OVSRSEL_A::X4096),
282 _ => None,
283 }
284 }
285 #[doc = "Checks if the value of the field is `X2`"]
286 #[inline(always)]
287 pub fn is_x2(&self) -> bool {
288 *self == OVSRSEL_A::X2
289 }
290 #[doc = "Checks if the value of the field is `X4`"]
291 #[inline(always)]
292 pub fn is_x4(&self) -> bool {
293 *self == OVSRSEL_A::X4
294 }
295 #[doc = "Checks if the value of the field is `X8`"]
296 #[inline(always)]
297 pub fn is_x8(&self) -> bool {
298 *self == OVSRSEL_A::X8
299 }
300 #[doc = "Checks if the value of the field is `X16`"]
301 #[inline(always)]
302 pub fn is_x16(&self) -> bool {
303 *self == OVSRSEL_A::X16
304 }
305 #[doc = "Checks if the value of the field is `X32`"]
306 #[inline(always)]
307 pub fn is_x32(&self) -> bool {
308 *self == OVSRSEL_A::X32
309 }
310 #[doc = "Checks if the value of the field is `X64`"]
311 #[inline(always)]
312 pub fn is_x64(&self) -> bool {
313 *self == OVSRSEL_A::X64
314 }
315 #[doc = "Checks if the value of the field is `X128`"]
316 #[inline(always)]
317 pub fn is_x128(&self) -> bool {
318 *self == OVSRSEL_A::X128
319 }
320 #[doc = "Checks if the value of the field is `X256`"]
321 #[inline(always)]
322 pub fn is_x256(&self) -> bool {
323 *self == OVSRSEL_A::X256
324 }
325 #[doc = "Checks if the value of the field is `X512`"]
326 #[inline(always)]
327 pub fn is_x512(&self) -> bool {
328 *self == OVSRSEL_A::X512
329 }
330 #[doc = "Checks if the value of the field is `X1024`"]
331 #[inline(always)]
332 pub fn is_x1024(&self) -> bool {
333 *self == OVSRSEL_A::X1024
334 }
335 #[doc = "Checks if the value of the field is `X2048`"]
336 #[inline(always)]
337 pub fn is_x2048(&self) -> bool {
338 *self == OVSRSEL_A::X2048
339 }
340 #[doc = "Checks if the value of the field is `X4096`"]
341 #[inline(always)]
342 pub fn is_x4096(&self) -> bool {
343 *self == OVSRSEL_A::X4096
344 }
345}
346#[doc = "Field `OVSRSEL` writer - Oversample Rate Select"]
347pub type OVSRSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, OVSRSEL_A, 4, O>;
348impl<'a, const O: u8> OVSRSEL_W<'a, O> {
349 #[doc = "2 samples for each conversion result"]
350 #[inline(always)]
351 pub fn x2(self) -> &'a mut W {
352 self.variant(OVSRSEL_A::X2)
353 }
354 #[doc = "4 samples for each conversion result"]
355 #[inline(always)]
356 pub fn x4(self) -> &'a mut W {
357 self.variant(OVSRSEL_A::X4)
358 }
359 #[doc = "8 samples for each conversion result"]
360 #[inline(always)]
361 pub fn x8(self) -> &'a mut W {
362 self.variant(OVSRSEL_A::X8)
363 }
364 #[doc = "16 samples for each conversion result"]
365 #[inline(always)]
366 pub fn x16(self) -> &'a mut W {
367 self.variant(OVSRSEL_A::X16)
368 }
369 #[doc = "32 samples for each conversion result"]
370 #[inline(always)]
371 pub fn x32(self) -> &'a mut W {
372 self.variant(OVSRSEL_A::X32)
373 }
374 #[doc = "64 samples for each conversion result"]
375 #[inline(always)]
376 pub fn x64(self) -> &'a mut W {
377 self.variant(OVSRSEL_A::X64)
378 }
379 #[doc = "128 samples for each conversion result"]
380 #[inline(always)]
381 pub fn x128(self) -> &'a mut W {
382 self.variant(OVSRSEL_A::X128)
383 }
384 #[doc = "256 samples for each conversion result"]
385 #[inline(always)]
386 pub fn x256(self) -> &'a mut W {
387 self.variant(OVSRSEL_A::X256)
388 }
389 #[doc = "512 samples for each conversion result"]
390 #[inline(always)]
391 pub fn x512(self) -> &'a mut W {
392 self.variant(OVSRSEL_A::X512)
393 }
394 #[doc = "1024 samples for each conversion result"]
395 #[inline(always)]
396 pub fn x1024(self) -> &'a mut W {
397 self.variant(OVSRSEL_A::X1024)
398 }
399 #[doc = "2048 samples for each conversion result"]
400 #[inline(always)]
401 pub fn x2048(self) -> &'a mut W {
402 self.variant(OVSRSEL_A::X2048)
403 }
404 #[doc = "4096 samples for each conversion result"]
405 #[inline(always)]
406 pub fn x4096(self) -> &'a mut W {
407 self.variant(OVSRSEL_A::X4096)
408 }
409}
410impl R {
411 #[doc = "Bits 0:1 - Warm-up Mode"]
412 #[inline(always)]
413 pub fn warmupmode(&self) -> WARMUPMODE_R {
414 WARMUPMODE_R::new((self.bits & 3) as u8)
415 }
416 #[doc = "Bit 3 - Conversion Tailgating"]
417 #[inline(always)]
418 pub fn tailgate(&self) -> TAILGATE_R {
419 TAILGATE_R::new(((self.bits >> 3) & 1) != 0)
420 }
421 #[doc = "Bits 4:5 - Low Pass Filter Mode"]
422 #[inline(always)]
423 pub fn lpfmode(&self) -> LPFMODE_R {
424 LPFMODE_R::new(((self.bits >> 4) & 3) as u8)
425 }
426 #[doc = "Bits 8:14 - Prescaler Setting"]
427 #[inline(always)]
428 pub fn presc(&self) -> PRESC_R {
429 PRESC_R::new(((self.bits >> 8) & 0x7f) as u8)
430 }
431 #[doc = "Bits 16:20 - Time Base"]
432 #[inline(always)]
433 pub fn timebase(&self) -> TIMEBASE_R {
434 TIMEBASE_R::new(((self.bits >> 16) & 0x1f) as u8)
435 }
436 #[doc = "Bits 24:27 - Oversample Rate Select"]
437 #[inline(always)]
438 pub fn ovsrsel(&self) -> OVSRSEL_R {
439 OVSRSEL_R::new(((self.bits >> 24) & 0x0f) as u8)
440 }
441}
442impl W {
443 #[doc = "Bits 0:1 - Warm-up Mode"]
444 #[inline(always)]
445 #[must_use]
446 pub fn warmupmode(&mut self) -> WARMUPMODE_W<0> {
447 WARMUPMODE_W::new(self)
448 }
449 #[doc = "Bit 3 - Conversion Tailgating"]
450 #[inline(always)]
451 #[must_use]
452 pub fn tailgate(&mut self) -> TAILGATE_W<3> {
453 TAILGATE_W::new(self)
454 }
455 #[doc = "Bits 4:5 - Low Pass Filter Mode"]
456 #[inline(always)]
457 #[must_use]
458 pub fn lpfmode(&mut self) -> LPFMODE_W<4> {
459 LPFMODE_W::new(self)
460 }
461 #[doc = "Bits 8:14 - Prescaler Setting"]
462 #[inline(always)]
463 #[must_use]
464 pub fn presc(&mut self) -> PRESC_W<8> {
465 PRESC_W::new(self)
466 }
467 #[doc = "Bits 16:20 - Time Base"]
468 #[inline(always)]
469 #[must_use]
470 pub fn timebase(&mut self) -> TIMEBASE_W<16> {
471 TIMEBASE_W::new(self)
472 }
473 #[doc = "Bits 24:27 - Oversample Rate Select"]
474 #[inline(always)]
475 #[must_use]
476 pub fn ovsrsel(&mut self) -> OVSRSEL_W<24> {
477 OVSRSEL_W::new(self)
478 }
479 #[doc = "Writes raw bits to the register."]
480 #[inline(always)]
481 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
482 self.0.bits(bits);
483 self
484 }
485}
486#[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"]
487pub struct CTRL_SPEC;
488impl crate::RegisterSpec for CTRL_SPEC {
489 type Ux = u32;
490}
491#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
492impl crate::Readable for CTRL_SPEC {
493 type Reader = R;
494}
495#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
496impl crate::Writable for CTRL_SPEC {
497 type Writer = W;
498 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
499 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
500}
501#[doc = "`reset()` method sets CTRL to value 0x001f_0000"]
502impl crate::Resettable for CTRL_SPEC {
503 const RESET_VALUE: Self::Ux = 0x001f_0000;
504}