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