1#[doc = "Register `EMR` reader"]
2pub struct R(crate::R<EMR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<EMR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<EMR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<EMR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `EMR` writer"]
17pub struct W(crate::W<EMR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<EMR_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<EMR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<EMR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CMPMODE` reader - Comparison Mode"]
38pub type CMPMODE_R = crate::FieldReader<u8, CMPMODE_A>;
39#[doc = "Comparison Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMPMODE_A {
43 #[doc = "0: Generates an event when the converted data is lower than the low threshold of the window."]
44 LOW = 0,
45 #[doc = "1: Generates an event when the converted data is higher than the high threshold of the window."]
46 HIGH = 1,
47 #[doc = "2: Generates an event when the converted data is in the comparison window."]
48 IN = 2,
49 #[doc = "3: Generates an event when the converted data is out of the comparison window."]
50 OUT = 3,
51}
52impl From<CMPMODE_A> for u8 {
53 #[inline(always)]
54 fn from(variant: CMPMODE_A) -> Self {
55 variant as _
56 }
57}
58impl CMPMODE_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> CMPMODE_A {
62 match self.bits {
63 0 => CMPMODE_A::LOW,
64 1 => CMPMODE_A::HIGH,
65 2 => CMPMODE_A::IN,
66 3 => CMPMODE_A::OUT,
67 _ => unreachable!(),
68 }
69 }
70 #[doc = "Checks if the value of the field is `LOW`"]
71 #[inline(always)]
72 pub fn is_low(&self) -> bool {
73 *self == CMPMODE_A::LOW
74 }
75 #[doc = "Checks if the value of the field is `HIGH`"]
76 #[inline(always)]
77 pub fn is_high(&self) -> bool {
78 *self == CMPMODE_A::HIGH
79 }
80 #[doc = "Checks if the value of the field is `IN`"]
81 #[inline(always)]
82 pub fn is_in(&self) -> bool {
83 *self == CMPMODE_A::IN
84 }
85 #[doc = "Checks if the value of the field is `OUT`"]
86 #[inline(always)]
87 pub fn is_out(&self) -> bool {
88 *self == CMPMODE_A::OUT
89 }
90}
91#[doc = "Field `CMPMODE` writer - Comparison Mode"]
92pub type CMPMODE_W<'a, const O: u8> =
93 crate::FieldWriterSafe<'a, u32, EMR_SPEC, u8, CMPMODE_A, 2, O>;
94impl<'a, const O: u8> CMPMODE_W<'a, O> {
95 #[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
96 #[inline(always)]
97 pub fn low(self) -> &'a mut W {
98 self.variant(CMPMODE_A::LOW)
99 }
100 #[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
101 #[inline(always)]
102 pub fn high(self) -> &'a mut W {
103 self.variant(CMPMODE_A::HIGH)
104 }
105 #[doc = "Generates an event when the converted data is in the comparison window."]
106 #[inline(always)]
107 pub fn in_(self) -> &'a mut W {
108 self.variant(CMPMODE_A::IN)
109 }
110 #[doc = "Generates an event when the converted data is out of the comparison window."]
111 #[inline(always)]
112 pub fn out(self) -> &'a mut W {
113 self.variant(CMPMODE_A::OUT)
114 }
115}
116#[doc = "Field `CMPSEL` reader - Comparison Selected Channel"]
117pub type CMPSEL_R = crate::FieldReader<u8, u8>;
118#[doc = "Field `CMPSEL` writer - Comparison Selected Channel"]
119pub type CMPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EMR_SPEC, u8, u8, 5, O>;
120#[doc = "Field `CMPALL` reader - Compare All Channels"]
121pub type CMPALL_R = crate::BitReader<bool>;
122#[doc = "Field `CMPALL` writer - Compare All Channels"]
123pub type CMPALL_W<'a, const O: u8> = crate::BitWriter<'a, u32, EMR_SPEC, bool, O>;
124#[doc = "Field `CMPFILTER` reader - Compare Event Filtering"]
125pub type CMPFILTER_R = crate::FieldReader<u8, u8>;
126#[doc = "Field `CMPFILTER` writer - Compare Event Filtering"]
127pub type CMPFILTER_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EMR_SPEC, u8, u8, 2, O>;
128#[doc = "Field `RES` reader - Resolution"]
129pub type RES_R = crate::FieldReader<u8, RES_A>;
130#[doc = "Resolution\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132#[repr(u8)]
133pub enum RES_A {
134 #[doc = "0: 12-bit resolution, AFEC sample rate is maximum (no averaging)."]
135 NO_AVERAGE = 0,
136 #[doc = "1: 10-bit resolution, AFEC sample rate is maximum (no averaging)."]
137 LOW_RES = 1,
138 #[doc = "2: 13-bit resolution, AFEC sample rate divided by 4 (averaging)."]
139 OSR4 = 2,
140 #[doc = "3: 14-bit resolution, AFEC sample rate divided by 16 (averaging)."]
141 OSR16 = 3,
142 #[doc = "4: 15-bit resolution, AFEC sample rate divided by 64 (averaging)."]
143 OSR64 = 4,
144 #[doc = "5: 16-bit resolution, AFEC sample rate divided by 256 (averaging)."]
145 OSR256 = 5,
146}
147impl From<RES_A> for u8 {
148 #[inline(always)]
149 fn from(variant: RES_A) -> Self {
150 variant as _
151 }
152}
153impl RES_R {
154 #[doc = "Get enumerated values variant"]
155 #[inline(always)]
156 pub fn variant(&self) -> Option<RES_A> {
157 match self.bits {
158 0 => Some(RES_A::NO_AVERAGE),
159 1 => Some(RES_A::LOW_RES),
160 2 => Some(RES_A::OSR4),
161 3 => Some(RES_A::OSR16),
162 4 => Some(RES_A::OSR64),
163 5 => Some(RES_A::OSR256),
164 _ => None,
165 }
166 }
167 #[doc = "Checks if the value of the field is `NO_AVERAGE`"]
168 #[inline(always)]
169 pub fn is_no_average(&self) -> bool {
170 *self == RES_A::NO_AVERAGE
171 }
172 #[doc = "Checks if the value of the field is `LOW_RES`"]
173 #[inline(always)]
174 pub fn is_low_res(&self) -> bool {
175 *self == RES_A::LOW_RES
176 }
177 #[doc = "Checks if the value of the field is `OSR4`"]
178 #[inline(always)]
179 pub fn is_osr4(&self) -> bool {
180 *self == RES_A::OSR4
181 }
182 #[doc = "Checks if the value of the field is `OSR16`"]
183 #[inline(always)]
184 pub fn is_osr16(&self) -> bool {
185 *self == RES_A::OSR16
186 }
187 #[doc = "Checks if the value of the field is `OSR64`"]
188 #[inline(always)]
189 pub fn is_osr64(&self) -> bool {
190 *self == RES_A::OSR64
191 }
192 #[doc = "Checks if the value of the field is `OSR256`"]
193 #[inline(always)]
194 pub fn is_osr256(&self) -> bool {
195 *self == RES_A::OSR256
196 }
197}
198#[doc = "Field `RES` writer - Resolution"]
199pub type RES_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EMR_SPEC, u8, RES_A, 3, O>;
200impl<'a, const O: u8> RES_W<'a, O> {
201 #[doc = "12-bit resolution, AFEC sample rate is maximum (no averaging)."]
202 #[inline(always)]
203 pub fn no_average(self) -> &'a mut W {
204 self.variant(RES_A::NO_AVERAGE)
205 }
206 #[doc = "10-bit resolution, AFEC sample rate is maximum (no averaging)."]
207 #[inline(always)]
208 pub fn low_res(self) -> &'a mut W {
209 self.variant(RES_A::LOW_RES)
210 }
211 #[doc = "13-bit resolution, AFEC sample rate divided by 4 (averaging)."]
212 #[inline(always)]
213 pub fn osr4(self) -> &'a mut W {
214 self.variant(RES_A::OSR4)
215 }
216 #[doc = "14-bit resolution, AFEC sample rate divided by 16 (averaging)."]
217 #[inline(always)]
218 pub fn osr16(self) -> &'a mut W {
219 self.variant(RES_A::OSR16)
220 }
221 #[doc = "15-bit resolution, AFEC sample rate divided by 64 (averaging)."]
222 #[inline(always)]
223 pub fn osr64(self) -> &'a mut W {
224 self.variant(RES_A::OSR64)
225 }
226 #[doc = "16-bit resolution, AFEC sample rate divided by 256 (averaging)."]
227 #[inline(always)]
228 pub fn osr256(self) -> &'a mut W {
229 self.variant(RES_A::OSR256)
230 }
231}
232#[doc = "Field `AFEMODE` reader - AFE Running Mode"]
233pub type AFEMODE_R = crate::FieldReader<u8, AFEMODE_A>;
234#[doc = "AFE Running Mode\n\nValue on reset: 0"]
235#[derive(Clone, Copy, Debug, PartialEq, Eq)]
236#[repr(u8)]
237pub enum AFEMODE_A {
238 #[doc = "0: Normal mode of operation."]
239 NORMAL = 0,
240 #[doc = "1: Offset Error mode to measure the offset error."]
241 OFFSET_ERROR = 1,
242 #[doc = "2: Gain Error mode to measure the gain error."]
243 GAIN_ERROR_HIGH = 2,
244 #[doc = "3:"]
245 GAIN_ERROR_LOW = 3,
246}
247impl From<AFEMODE_A> for u8 {
248 #[inline(always)]
249 fn from(variant: AFEMODE_A) -> Self {
250 variant as _
251 }
252}
253impl AFEMODE_R {
254 #[doc = "Get enumerated values variant"]
255 #[inline(always)]
256 pub fn variant(&self) -> AFEMODE_A {
257 match self.bits {
258 0 => AFEMODE_A::NORMAL,
259 1 => AFEMODE_A::OFFSET_ERROR,
260 2 => AFEMODE_A::GAIN_ERROR_HIGH,
261 3 => AFEMODE_A::GAIN_ERROR_LOW,
262 _ => unreachable!(),
263 }
264 }
265 #[doc = "Checks if the value of the field is `NORMAL`"]
266 #[inline(always)]
267 pub fn is_normal(&self) -> bool {
268 *self == AFEMODE_A::NORMAL
269 }
270 #[doc = "Checks if the value of the field is `OFFSET_ERROR`"]
271 #[inline(always)]
272 pub fn is_offset_error(&self) -> bool {
273 *self == AFEMODE_A::OFFSET_ERROR
274 }
275 #[doc = "Checks if the value of the field is `GAIN_ERROR_HIGH`"]
276 #[inline(always)]
277 pub fn is_gain_error_high(&self) -> bool {
278 *self == AFEMODE_A::GAIN_ERROR_HIGH
279 }
280 #[doc = "Checks if the value of the field is `GAIN_ERROR_LOW`"]
281 #[inline(always)]
282 pub fn is_gain_error_low(&self) -> bool {
283 *self == AFEMODE_A::GAIN_ERROR_LOW
284 }
285}
286#[doc = "Field `AFEMODE` writer - AFE Running Mode"]
287pub type AFEMODE_W<'a, const O: u8> =
288 crate::FieldWriterSafe<'a, u32, EMR_SPEC, u8, AFEMODE_A, 2, O>;
289impl<'a, const O: u8> AFEMODE_W<'a, O> {
290 #[doc = "Normal mode of operation."]
291 #[inline(always)]
292 pub fn normal(self) -> &'a mut W {
293 self.variant(AFEMODE_A::NORMAL)
294 }
295 #[doc = "Offset Error mode to measure the offset error."]
296 #[inline(always)]
297 pub fn offset_error(self) -> &'a mut W {
298 self.variant(AFEMODE_A::OFFSET_ERROR)
299 }
300 #[doc = "Gain Error mode to measure the gain error."]
301 #[inline(always)]
302 pub fn gain_error_high(self) -> &'a mut W {
303 self.variant(AFEMODE_A::GAIN_ERROR_HIGH)
304 }
305 #[doc = ""]
306 #[inline(always)]
307 pub fn gain_error_low(self) -> &'a mut W {
308 self.variant(AFEMODE_A::GAIN_ERROR_LOW)
309 }
310}
311#[doc = "Field `TAG` reader - TAG of the AFEC_LDCR"]
312pub type TAG_R = crate::BitReader<bool>;
313#[doc = "Field `TAG` writer - TAG of the AFEC_LDCR"]
314pub type TAG_W<'a, const O: u8> = crate::BitWriter<'a, u32, EMR_SPEC, bool, O>;
315#[doc = "Field `STM` reader - Single Trigger Mode"]
316pub type STM_R = crate::BitReader<bool>;
317#[doc = "Field `STM` writer - Single Trigger Mode"]
318pub type STM_W<'a, const O: u8> = crate::BitWriter<'a, u32, EMR_SPEC, bool, O>;
319#[doc = "Field `SIGNMODE` reader - Sign Mode"]
320pub type SIGNMODE_R = crate::FieldReader<u8, SIGNMODE_A>;
321#[doc = "Sign Mode\n\nValue on reset: 0"]
322#[derive(Clone, Copy, Debug, PartialEq, Eq)]
323#[repr(u8)]
324pub enum SIGNMODE_A {
325 #[doc = "0: Single-Ended Channels: Unsigned conversions.Differential Channels: Signed conversions."]
326 SE_UNSG_DF_SIGN = 0,
327 #[doc = "1: Single-Ended Channels: Signed conversions.Differential Channels: Unsigned conversions."]
328 SE_SIGN_DF_UNSG = 1,
329 #[doc = "2: All Channels: Unsigned conversions."]
330 ALL_UNSIGNED = 2,
331 #[doc = "3: All Channels: Signed conversions."]
332 ALL_SIGNED = 3,
333}
334impl From<SIGNMODE_A> for u8 {
335 #[inline(always)]
336 fn from(variant: SIGNMODE_A) -> Self {
337 variant as _
338 }
339}
340impl SIGNMODE_R {
341 #[doc = "Get enumerated values variant"]
342 #[inline(always)]
343 pub fn variant(&self) -> SIGNMODE_A {
344 match self.bits {
345 0 => SIGNMODE_A::SE_UNSG_DF_SIGN,
346 1 => SIGNMODE_A::SE_SIGN_DF_UNSG,
347 2 => SIGNMODE_A::ALL_UNSIGNED,
348 3 => SIGNMODE_A::ALL_SIGNED,
349 _ => unreachable!(),
350 }
351 }
352 #[doc = "Checks if the value of the field is `SE_UNSG_DF_SIGN`"]
353 #[inline(always)]
354 pub fn is_se_unsg_df_sign(&self) -> bool {
355 *self == SIGNMODE_A::SE_UNSG_DF_SIGN
356 }
357 #[doc = "Checks if the value of the field is `SE_SIGN_DF_UNSG`"]
358 #[inline(always)]
359 pub fn is_se_sign_df_unsg(&self) -> bool {
360 *self == SIGNMODE_A::SE_SIGN_DF_UNSG
361 }
362 #[doc = "Checks if the value of the field is `ALL_UNSIGNED`"]
363 #[inline(always)]
364 pub fn is_all_unsigned(&self) -> bool {
365 *self == SIGNMODE_A::ALL_UNSIGNED
366 }
367 #[doc = "Checks if the value of the field is `ALL_SIGNED`"]
368 #[inline(always)]
369 pub fn is_all_signed(&self) -> bool {
370 *self == SIGNMODE_A::ALL_SIGNED
371 }
372}
373#[doc = "Field `SIGNMODE` writer - Sign Mode"]
374pub type SIGNMODE_W<'a, const O: u8> =
375 crate::FieldWriterSafe<'a, u32, EMR_SPEC, u8, SIGNMODE_A, 2, O>;
376impl<'a, const O: u8> SIGNMODE_W<'a, O> {
377 #[doc = "Single-Ended Channels: Unsigned conversions.Differential Channels: Signed conversions."]
378 #[inline(always)]
379 pub fn se_unsg_df_sign(self) -> &'a mut W {
380 self.variant(SIGNMODE_A::SE_UNSG_DF_SIGN)
381 }
382 #[doc = "Single-Ended Channels: Signed conversions.Differential Channels: Unsigned conversions."]
383 #[inline(always)]
384 pub fn se_sign_df_unsg(self) -> &'a mut W {
385 self.variant(SIGNMODE_A::SE_SIGN_DF_UNSG)
386 }
387 #[doc = "All Channels: Unsigned conversions."]
388 #[inline(always)]
389 pub fn all_unsigned(self) -> &'a mut W {
390 self.variant(SIGNMODE_A::ALL_UNSIGNED)
391 }
392 #[doc = "All Channels: Signed conversions."]
393 #[inline(always)]
394 pub fn all_signed(self) -> &'a mut W {
395 self.variant(SIGNMODE_A::ALL_SIGNED)
396 }
397}
398impl R {
399 #[doc = "Bits 0:1 - Comparison Mode"]
400 #[inline(always)]
401 pub fn cmpmode(&self) -> CMPMODE_R {
402 CMPMODE_R::new((self.bits & 3) as u8)
403 }
404 #[doc = "Bits 3:7 - Comparison Selected Channel"]
405 #[inline(always)]
406 pub fn cmpsel(&self) -> CMPSEL_R {
407 CMPSEL_R::new(((self.bits >> 3) & 0x1f) as u8)
408 }
409 #[doc = "Bit 9 - Compare All Channels"]
410 #[inline(always)]
411 pub fn cmpall(&self) -> CMPALL_R {
412 CMPALL_R::new(((self.bits >> 9) & 1) != 0)
413 }
414 #[doc = "Bits 12:13 - Compare Event Filtering"]
415 #[inline(always)]
416 pub fn cmpfilter(&self) -> CMPFILTER_R {
417 CMPFILTER_R::new(((self.bits >> 12) & 3) as u8)
418 }
419 #[doc = "Bits 16:18 - Resolution"]
420 #[inline(always)]
421 pub fn res(&self) -> RES_R {
422 RES_R::new(((self.bits >> 16) & 7) as u8)
423 }
424 #[doc = "Bits 20:21 - AFE Running Mode"]
425 #[inline(always)]
426 pub fn afemode(&self) -> AFEMODE_R {
427 AFEMODE_R::new(((self.bits >> 20) & 3) as u8)
428 }
429 #[doc = "Bit 24 - TAG of the AFEC_LDCR"]
430 #[inline(always)]
431 pub fn tag(&self) -> TAG_R {
432 TAG_R::new(((self.bits >> 24) & 1) != 0)
433 }
434 #[doc = "Bit 25 - Single Trigger Mode"]
435 #[inline(always)]
436 pub fn stm(&self) -> STM_R {
437 STM_R::new(((self.bits >> 25) & 1) != 0)
438 }
439 #[doc = "Bits 28:29 - Sign Mode"]
440 #[inline(always)]
441 pub fn signmode(&self) -> SIGNMODE_R {
442 SIGNMODE_R::new(((self.bits >> 28) & 3) as u8)
443 }
444}
445impl W {
446 #[doc = "Bits 0:1 - Comparison Mode"]
447 #[inline(always)]
448 #[must_use]
449 pub fn cmpmode(&mut self) -> CMPMODE_W<0> {
450 CMPMODE_W::new(self)
451 }
452 #[doc = "Bits 3:7 - Comparison Selected Channel"]
453 #[inline(always)]
454 #[must_use]
455 pub fn cmpsel(&mut self) -> CMPSEL_W<3> {
456 CMPSEL_W::new(self)
457 }
458 #[doc = "Bit 9 - Compare All Channels"]
459 #[inline(always)]
460 #[must_use]
461 pub fn cmpall(&mut self) -> CMPALL_W<9> {
462 CMPALL_W::new(self)
463 }
464 #[doc = "Bits 12:13 - Compare Event Filtering"]
465 #[inline(always)]
466 #[must_use]
467 pub fn cmpfilter(&mut self) -> CMPFILTER_W<12> {
468 CMPFILTER_W::new(self)
469 }
470 #[doc = "Bits 16:18 - Resolution"]
471 #[inline(always)]
472 #[must_use]
473 pub fn res(&mut self) -> RES_W<16> {
474 RES_W::new(self)
475 }
476 #[doc = "Bits 20:21 - AFE Running Mode"]
477 #[inline(always)]
478 #[must_use]
479 pub fn afemode(&mut self) -> AFEMODE_W<20> {
480 AFEMODE_W::new(self)
481 }
482 #[doc = "Bit 24 - TAG of the AFEC_LDCR"]
483 #[inline(always)]
484 #[must_use]
485 pub fn tag(&mut self) -> TAG_W<24> {
486 TAG_W::new(self)
487 }
488 #[doc = "Bit 25 - Single Trigger Mode"]
489 #[inline(always)]
490 #[must_use]
491 pub fn stm(&mut self) -> STM_W<25> {
492 STM_W::new(self)
493 }
494 #[doc = "Bits 28:29 - Sign Mode"]
495 #[inline(always)]
496 #[must_use]
497 pub fn signmode(&mut self) -> SIGNMODE_W<28> {
498 SIGNMODE_W::new(self)
499 }
500 #[doc = "Writes raw bits to the register."]
501 #[inline(always)]
502 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
503 self.0.bits(bits);
504 self
505 }
506}
507#[doc = "AFEC Extended Mode 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 [emr](index.html) module"]
508pub struct EMR_SPEC;
509impl crate::RegisterSpec for EMR_SPEC {
510 type Ux = u32;
511}
512#[doc = "`read()` method returns [emr::R](R) reader structure"]
513impl crate::Readable for EMR_SPEC {
514 type Reader = R;
515}
516#[doc = "`write(|w| ..)` method takes [emr::W](W) writer structure"]
517impl crate::Writable for EMR_SPEC {
518 type Writer = W;
519 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
520 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
521}
522#[doc = "`reset()` method sets EMR to value 0"]
523impl crate::Resettable for EMR_SPEC {
524 const RESET_VALUE: Self::Ux = 0;
525}