py32f0/py32f040/comp1/
csr.rs

1///Register `CSR` reader
2pub struct R(crate::R<CSR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CSR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CSR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CSR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CSR` writer
17pub struct W(crate::W<CSR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CSR_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<CSR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CSR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `EN` reader - COMP enable bit
38pub type EN_R = crate::BitReader<EN_A>;
39/**COMP enable bit
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum EN_A {
44    ///0: Comparator 1 disabled
45    Disabled = 0,
46    ///1: Comparator 1 enabled
47    Enabled = 1,
48}
49impl From<EN_A> for bool {
50    #[inline(always)]
51    fn from(variant: EN_A) -> Self {
52        variant as u8 != 0
53    }
54}
55impl EN_R {
56    ///Get enumerated values variant
57    #[inline(always)]
58    pub fn variant(&self) -> EN_A {
59        match self.bits {
60            false => EN_A::Disabled,
61            true => EN_A::Enabled,
62        }
63    }
64    ///Checks if the value of the field is `Disabled`
65    #[inline(always)]
66    pub fn is_disabled(&self) -> bool {
67        *self == EN_A::Disabled
68    }
69    ///Checks if the value of the field is `Enabled`
70    #[inline(always)]
71    pub fn is_enabled(&self) -> bool {
72        *self == EN_A::Enabled
73    }
74}
75///Field `EN` writer - COMP enable bit
76pub type EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, EN_A, O>;
77impl<'a, const O: u8> EN_W<'a, O> {
78    ///Comparator 1 disabled
79    #[inline(always)]
80    pub fn disabled(self) -> &'a mut W {
81        self.variant(EN_A::Disabled)
82    }
83    ///Comparator 1 enabled
84    #[inline(always)]
85    pub fn enabled(self) -> &'a mut W {
86        self.variant(EN_A::Enabled)
87    }
88}
89///Field `INMSEL` reader - Comparator signal selector for inverting input INM
90pub type INMSEL_R = crate::FieldReader<u8, INMSEL_A>;
91/**Comparator signal selector for inverting input INM
92
93Value on reset: 0*/
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum INMSEL_A {
97    ///0: COMP1_INM0 from PA0
98    Inm0 = 0,
99    ///1: COMP1_INM1 from PA1
100    Inm1 = 1,
101    ///2: COMP1_INM2 from PA2
102    Inm2 = 2,
103    ///3: COMP1_INM3 from PA3
104    Inm3 = 3,
105    ///4: COMP1_INM4 from PA4
106    Inm4 = 4,
107    ///5: COMP1_INM5 from PA5
108    Inm5 = 5,
109    ///6: COMP1_INM6 from PA6
110    Inm6 = 6,
111    ///7: COMP1_INM7 from PA7
112    Inm7 = 7,
113    ///8: COMP1_INM8 from PC4
114    Inm8 = 8,
115    ///9: COMP1_INM9 from PC5
116    Inm9 = 9,
117    ///10: COMP1_INM11 from resistor voltage divider
118    Inm11 = 10,
119    ///11: COMP1_INM12 from TS_VIN
120    Inm12 = 11,
121    ///12: COMP1_INM13 from VREF1P2
122    Inm13 = 12,
123    ///13: COMP1_INM14 from VREFBUF
124    Inm14 = 13,
125    ///14: COMP1_INM15 from OPA1_VIN
126    Inm15 = 14,
127}
128impl From<INMSEL_A> for u8 {
129    #[inline(always)]
130    fn from(variant: INMSEL_A) -> Self {
131        variant as _
132    }
133}
134impl INMSEL_R {
135    ///Get enumerated values variant
136    #[inline(always)]
137    pub fn variant(&self) -> Option<INMSEL_A> {
138        match self.bits {
139            0 => Some(INMSEL_A::Inm0),
140            1 => Some(INMSEL_A::Inm1),
141            2 => Some(INMSEL_A::Inm2),
142            3 => Some(INMSEL_A::Inm3),
143            4 => Some(INMSEL_A::Inm4),
144            5 => Some(INMSEL_A::Inm5),
145            6 => Some(INMSEL_A::Inm6),
146            7 => Some(INMSEL_A::Inm7),
147            8 => Some(INMSEL_A::Inm8),
148            9 => Some(INMSEL_A::Inm9),
149            10 => Some(INMSEL_A::Inm11),
150            11 => Some(INMSEL_A::Inm12),
151            12 => Some(INMSEL_A::Inm13),
152            13 => Some(INMSEL_A::Inm14),
153            14 => Some(INMSEL_A::Inm15),
154            _ => None,
155        }
156    }
157    ///Checks if the value of the field is `Inm0`
158    #[inline(always)]
159    pub fn is_inm0(&self) -> bool {
160        *self == INMSEL_A::Inm0
161    }
162    ///Checks if the value of the field is `Inm1`
163    #[inline(always)]
164    pub fn is_inm1(&self) -> bool {
165        *self == INMSEL_A::Inm1
166    }
167    ///Checks if the value of the field is `Inm2`
168    #[inline(always)]
169    pub fn is_inm2(&self) -> bool {
170        *self == INMSEL_A::Inm2
171    }
172    ///Checks if the value of the field is `Inm3`
173    #[inline(always)]
174    pub fn is_inm3(&self) -> bool {
175        *self == INMSEL_A::Inm3
176    }
177    ///Checks if the value of the field is `Inm4`
178    #[inline(always)]
179    pub fn is_inm4(&self) -> bool {
180        *self == INMSEL_A::Inm4
181    }
182    ///Checks if the value of the field is `Inm5`
183    #[inline(always)]
184    pub fn is_inm5(&self) -> bool {
185        *self == INMSEL_A::Inm5
186    }
187    ///Checks if the value of the field is `Inm6`
188    #[inline(always)]
189    pub fn is_inm6(&self) -> bool {
190        *self == INMSEL_A::Inm6
191    }
192    ///Checks if the value of the field is `Inm7`
193    #[inline(always)]
194    pub fn is_inm7(&self) -> bool {
195        *self == INMSEL_A::Inm7
196    }
197    ///Checks if the value of the field is `Inm8`
198    #[inline(always)]
199    pub fn is_inm8(&self) -> bool {
200        *self == INMSEL_A::Inm8
201    }
202    ///Checks if the value of the field is `Inm9`
203    #[inline(always)]
204    pub fn is_inm9(&self) -> bool {
205        *self == INMSEL_A::Inm9
206    }
207    ///Checks if the value of the field is `Inm11`
208    #[inline(always)]
209    pub fn is_inm11(&self) -> bool {
210        *self == INMSEL_A::Inm11
211    }
212    ///Checks if the value of the field is `Inm12`
213    #[inline(always)]
214    pub fn is_inm12(&self) -> bool {
215        *self == INMSEL_A::Inm12
216    }
217    ///Checks if the value of the field is `Inm13`
218    #[inline(always)]
219    pub fn is_inm13(&self) -> bool {
220        *self == INMSEL_A::Inm13
221    }
222    ///Checks if the value of the field is `Inm14`
223    #[inline(always)]
224    pub fn is_inm14(&self) -> bool {
225        *self == INMSEL_A::Inm14
226    }
227    ///Checks if the value of the field is `Inm15`
228    #[inline(always)]
229    pub fn is_inm15(&self) -> bool {
230        *self == INMSEL_A::Inm15
231    }
232}
233///Field `INMSEL` writer - Comparator signal selector for inverting input INM
234pub type INMSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CSR_SPEC, u8, INMSEL_A, 4, O>;
235impl<'a, const O: u8> INMSEL_W<'a, O> {
236    ///COMP1_INM0 from PA0
237    #[inline(always)]
238    pub fn inm0(self) -> &'a mut W {
239        self.variant(INMSEL_A::Inm0)
240    }
241    ///COMP1_INM1 from PA1
242    #[inline(always)]
243    pub fn inm1(self) -> &'a mut W {
244        self.variant(INMSEL_A::Inm1)
245    }
246    ///COMP1_INM2 from PA2
247    #[inline(always)]
248    pub fn inm2(self) -> &'a mut W {
249        self.variant(INMSEL_A::Inm2)
250    }
251    ///COMP1_INM3 from PA3
252    #[inline(always)]
253    pub fn inm3(self) -> &'a mut W {
254        self.variant(INMSEL_A::Inm3)
255    }
256    ///COMP1_INM4 from PA4
257    #[inline(always)]
258    pub fn inm4(self) -> &'a mut W {
259        self.variant(INMSEL_A::Inm4)
260    }
261    ///COMP1_INM5 from PA5
262    #[inline(always)]
263    pub fn inm5(self) -> &'a mut W {
264        self.variant(INMSEL_A::Inm5)
265    }
266    ///COMP1_INM6 from PA6
267    #[inline(always)]
268    pub fn inm6(self) -> &'a mut W {
269        self.variant(INMSEL_A::Inm6)
270    }
271    ///COMP1_INM7 from PA7
272    #[inline(always)]
273    pub fn inm7(self) -> &'a mut W {
274        self.variant(INMSEL_A::Inm7)
275    }
276    ///COMP1_INM8 from PC4
277    #[inline(always)]
278    pub fn inm8(self) -> &'a mut W {
279        self.variant(INMSEL_A::Inm8)
280    }
281    ///COMP1_INM9 from PC5
282    #[inline(always)]
283    pub fn inm9(self) -> &'a mut W {
284        self.variant(INMSEL_A::Inm9)
285    }
286    ///COMP1_INM11 from resistor voltage divider
287    #[inline(always)]
288    pub fn inm11(self) -> &'a mut W {
289        self.variant(INMSEL_A::Inm11)
290    }
291    ///COMP1_INM12 from TS_VIN
292    #[inline(always)]
293    pub fn inm12(self) -> &'a mut W {
294        self.variant(INMSEL_A::Inm12)
295    }
296    ///COMP1_INM13 from VREF1P2
297    #[inline(always)]
298    pub fn inm13(self) -> &'a mut W {
299        self.variant(INMSEL_A::Inm13)
300    }
301    ///COMP1_INM14 from VREFBUF
302    #[inline(always)]
303    pub fn inm14(self) -> &'a mut W {
304        self.variant(INMSEL_A::Inm14)
305    }
306    ///COMP1_INM15 from OPA1_VIN
307    #[inline(always)]
308    pub fn inm15(self) -> &'a mut W {
309        self.variant(INMSEL_A::Inm15)
310    }
311}
312///Field `INPSEL` reader - Comparator signal selector for non-inverting input
313pub type INPSEL_R = crate::FieldReader<u8, INPSEL_A>;
314/**Comparator signal selector for non-inverting input
315
316Value on reset: 0*/
317#[derive(Clone, Copy, Debug, PartialEq, Eq)]
318#[repr(u8)]
319pub enum INPSEL_A {
320    ///0: COMP1_INP0 from PC0
321    Inp0 = 0,
322    ///1: COMP1_INP1 from PC1
323    Inp1 = 1,
324    ///2: COMP1_INP2 from PC2
325    Inp2 = 2,
326    ///3: COMP1_INP3 from PC3
327    Inp3 = 3,
328    ///4: COMP1_INP4 from PA0
329    Inp4 = 4,
330    ///5: COMP1_INP5 from PA1
331    Inp5 = 5,
332    ///6: COMP1_INP6 from PA2
333    Inp6 = 6,
334    ///7: COMP1_INP7 from PA3
335    Inp7 = 7,
336    ///8: COMP1_INP8 from PA4
337    Inp8 = 8,
338    ///9: COMP1_INP9 from PA5
339    Inp9 = 9,
340    ///10: COMP1_INP10 from PA6
341    Inp10 = 10,
342    ///11: COMP1_INP11 from PA7
343    Inp11 = 11,
344    ///12: COMP1_INP12 from PB4
345    Inp12 = 12,
346    ///13: COMP1_INP13 from PB5
347    Inp13 = 13,
348    ///14: COMP1_INP14 from PB6
349    Inp14 = 14,
350}
351impl From<INPSEL_A> for u8 {
352    #[inline(always)]
353    fn from(variant: INPSEL_A) -> Self {
354        variant as _
355    }
356}
357impl INPSEL_R {
358    ///Get enumerated values variant
359    #[inline(always)]
360    pub fn variant(&self) -> Option<INPSEL_A> {
361        match self.bits {
362            0 => Some(INPSEL_A::Inp0),
363            1 => Some(INPSEL_A::Inp1),
364            2 => Some(INPSEL_A::Inp2),
365            3 => Some(INPSEL_A::Inp3),
366            4 => Some(INPSEL_A::Inp4),
367            5 => Some(INPSEL_A::Inp5),
368            6 => Some(INPSEL_A::Inp6),
369            7 => Some(INPSEL_A::Inp7),
370            8 => Some(INPSEL_A::Inp8),
371            9 => Some(INPSEL_A::Inp9),
372            10 => Some(INPSEL_A::Inp10),
373            11 => Some(INPSEL_A::Inp11),
374            12 => Some(INPSEL_A::Inp12),
375            13 => Some(INPSEL_A::Inp13),
376            14 => Some(INPSEL_A::Inp14),
377            _ => None,
378        }
379    }
380    ///Checks if the value of the field is `Inp0`
381    #[inline(always)]
382    pub fn is_inp0(&self) -> bool {
383        *self == INPSEL_A::Inp0
384    }
385    ///Checks if the value of the field is `Inp1`
386    #[inline(always)]
387    pub fn is_inp1(&self) -> bool {
388        *self == INPSEL_A::Inp1
389    }
390    ///Checks if the value of the field is `Inp2`
391    #[inline(always)]
392    pub fn is_inp2(&self) -> bool {
393        *self == INPSEL_A::Inp2
394    }
395    ///Checks if the value of the field is `Inp3`
396    #[inline(always)]
397    pub fn is_inp3(&self) -> bool {
398        *self == INPSEL_A::Inp3
399    }
400    ///Checks if the value of the field is `Inp4`
401    #[inline(always)]
402    pub fn is_inp4(&self) -> bool {
403        *self == INPSEL_A::Inp4
404    }
405    ///Checks if the value of the field is `Inp5`
406    #[inline(always)]
407    pub fn is_inp5(&self) -> bool {
408        *self == INPSEL_A::Inp5
409    }
410    ///Checks if the value of the field is `Inp6`
411    #[inline(always)]
412    pub fn is_inp6(&self) -> bool {
413        *self == INPSEL_A::Inp6
414    }
415    ///Checks if the value of the field is `Inp7`
416    #[inline(always)]
417    pub fn is_inp7(&self) -> bool {
418        *self == INPSEL_A::Inp7
419    }
420    ///Checks if the value of the field is `Inp8`
421    #[inline(always)]
422    pub fn is_inp8(&self) -> bool {
423        *self == INPSEL_A::Inp8
424    }
425    ///Checks if the value of the field is `Inp9`
426    #[inline(always)]
427    pub fn is_inp9(&self) -> bool {
428        *self == INPSEL_A::Inp9
429    }
430    ///Checks if the value of the field is `Inp10`
431    #[inline(always)]
432    pub fn is_inp10(&self) -> bool {
433        *self == INPSEL_A::Inp10
434    }
435    ///Checks if the value of the field is `Inp11`
436    #[inline(always)]
437    pub fn is_inp11(&self) -> bool {
438        *self == INPSEL_A::Inp11
439    }
440    ///Checks if the value of the field is `Inp12`
441    #[inline(always)]
442    pub fn is_inp12(&self) -> bool {
443        *self == INPSEL_A::Inp12
444    }
445    ///Checks if the value of the field is `Inp13`
446    #[inline(always)]
447    pub fn is_inp13(&self) -> bool {
448        *self == INPSEL_A::Inp13
449    }
450    ///Checks if the value of the field is `Inp14`
451    #[inline(always)]
452    pub fn is_inp14(&self) -> bool {
453        *self == INPSEL_A::Inp14
454    }
455}
456///Field `INPSEL` writer - Comparator signal selector for non-inverting input
457pub type INPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CSR_SPEC, u8, INPSEL_A, 4, O>;
458impl<'a, const O: u8> INPSEL_W<'a, O> {
459    ///COMP1_INP0 from PC0
460    #[inline(always)]
461    pub fn inp0(self) -> &'a mut W {
462        self.variant(INPSEL_A::Inp0)
463    }
464    ///COMP1_INP1 from PC1
465    #[inline(always)]
466    pub fn inp1(self) -> &'a mut W {
467        self.variant(INPSEL_A::Inp1)
468    }
469    ///COMP1_INP2 from PC2
470    #[inline(always)]
471    pub fn inp2(self) -> &'a mut W {
472        self.variant(INPSEL_A::Inp2)
473    }
474    ///COMP1_INP3 from PC3
475    #[inline(always)]
476    pub fn inp3(self) -> &'a mut W {
477        self.variant(INPSEL_A::Inp3)
478    }
479    ///COMP1_INP4 from PA0
480    #[inline(always)]
481    pub fn inp4(self) -> &'a mut W {
482        self.variant(INPSEL_A::Inp4)
483    }
484    ///COMP1_INP5 from PA1
485    #[inline(always)]
486    pub fn inp5(self) -> &'a mut W {
487        self.variant(INPSEL_A::Inp5)
488    }
489    ///COMP1_INP6 from PA2
490    #[inline(always)]
491    pub fn inp6(self) -> &'a mut W {
492        self.variant(INPSEL_A::Inp6)
493    }
494    ///COMP1_INP7 from PA3
495    #[inline(always)]
496    pub fn inp7(self) -> &'a mut W {
497        self.variant(INPSEL_A::Inp7)
498    }
499    ///COMP1_INP8 from PA4
500    #[inline(always)]
501    pub fn inp8(self) -> &'a mut W {
502        self.variant(INPSEL_A::Inp8)
503    }
504    ///COMP1_INP9 from PA5
505    #[inline(always)]
506    pub fn inp9(self) -> &'a mut W {
507        self.variant(INPSEL_A::Inp9)
508    }
509    ///COMP1_INP10 from PA6
510    #[inline(always)]
511    pub fn inp10(self) -> &'a mut W {
512        self.variant(INPSEL_A::Inp10)
513    }
514    ///COMP1_INP11 from PA7
515    #[inline(always)]
516    pub fn inp11(self) -> &'a mut W {
517        self.variant(INPSEL_A::Inp11)
518    }
519    ///COMP1_INP12 from PB4
520    #[inline(always)]
521    pub fn inp12(self) -> &'a mut W {
522        self.variant(INPSEL_A::Inp12)
523    }
524    ///COMP1_INP13 from PB5
525    #[inline(always)]
526    pub fn inp13(self) -> &'a mut W {
527        self.variant(INPSEL_A::Inp13)
528    }
529    ///COMP1_INP14 from PB6
530    #[inline(always)]
531    pub fn inp14(self) -> &'a mut W {
532        self.variant(INPSEL_A::Inp14)
533    }
534}
535///Field `WINMODE` reader - Comparator non-inverting input selector for window mode
536pub type WINMODE_R = crate::BitReader<WINMODE_A>;
537/**Comparator non-inverting input selector for window mode
538
539Value on reset: 0*/
540#[derive(Clone, Copy, Debug, PartialEq, Eq)]
541pub enum WINMODE_A {
542    ///0: `0`
543    Disabled = 0,
544    ///1: `1`
545    Enabled = 1,
546}
547impl From<WINMODE_A> for bool {
548    #[inline(always)]
549    fn from(variant: WINMODE_A) -> Self {
550        variant as u8 != 0
551    }
552}
553impl WINMODE_R {
554    ///Get enumerated values variant
555    #[inline(always)]
556    pub fn variant(&self) -> WINMODE_A {
557        match self.bits {
558            false => WINMODE_A::Disabled,
559            true => WINMODE_A::Enabled,
560        }
561    }
562    ///Checks if the value of the field is `Disabled`
563    #[inline(always)]
564    pub fn is_disabled(&self) -> bool {
565        *self == WINMODE_A::Disabled
566    }
567    ///Checks if the value of the field is `Enabled`
568    #[inline(always)]
569    pub fn is_enabled(&self) -> bool {
570        *self == WINMODE_A::Enabled
571    }
572}
573///Field `WINMODE` writer - Comparator non-inverting input selector for window mode
574pub type WINMODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, WINMODE_A, O>;
575impl<'a, const O: u8> WINMODE_W<'a, O> {
576    ///`0`
577    #[inline(always)]
578    pub fn disabled(self) -> &'a mut W {
579        self.variant(WINMODE_A::Disabled)
580    }
581    ///`1`
582    #[inline(always)]
583    pub fn enabled(self) -> &'a mut W {
584        self.variant(WINMODE_A::Enabled)
585    }
586}
587///Field `POLARITY` reader - Comparator polarity selector
588pub type POLARITY_R = crate::BitReader<POLARITY_A>;
589/**Comparator polarity selector
590
591Value on reset: 0*/
592#[derive(Clone, Copy, Debug, PartialEq, Eq)]
593pub enum POLARITY_A {
594    ///0: Output is not inverted
595    NotInverted = 0,
596    ///1: Output is inverted
597    Inverted = 1,
598}
599impl From<POLARITY_A> for bool {
600    #[inline(always)]
601    fn from(variant: POLARITY_A) -> Self {
602        variant as u8 != 0
603    }
604}
605impl POLARITY_R {
606    ///Get enumerated values variant
607    #[inline(always)]
608    pub fn variant(&self) -> POLARITY_A {
609        match self.bits {
610            false => POLARITY_A::NotInverted,
611            true => POLARITY_A::Inverted,
612        }
613    }
614    ///Checks if the value of the field is `NotInverted`
615    #[inline(always)]
616    pub fn is_not_inverted(&self) -> bool {
617        *self == POLARITY_A::NotInverted
618    }
619    ///Checks if the value of the field is `Inverted`
620    #[inline(always)]
621    pub fn is_inverted(&self) -> bool {
622        *self == POLARITY_A::Inverted
623    }
624}
625///Field `POLARITY` writer - Comparator polarity selector
626pub type POLARITY_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, POLARITY_A, O>;
627impl<'a, const O: u8> POLARITY_W<'a, O> {
628    ///Output is not inverted
629    #[inline(always)]
630    pub fn not_inverted(self) -> &'a mut W {
631        self.variant(POLARITY_A::NotInverted)
632    }
633    ///Output is inverted
634    #[inline(always)]
635    pub fn inverted(self) -> &'a mut W {
636        self.variant(POLARITY_A::Inverted)
637    }
638}
639///Field `HYST` reader - Comparator hysteresis enable selector
640pub type HYST_R = crate::BitReader<HYST_A>;
641/**Comparator hysteresis enable selector
642
643Value on reset: 0*/
644#[derive(Clone, Copy, Debug, PartialEq, Eq)]
645pub enum HYST_A {
646    ///0: no Comp1 hysteresis
647    No = 0,
648    ///1: Comp1 hysteresis voltage approx 20mV
649    Yes = 1,
650}
651impl From<HYST_A> for bool {
652    #[inline(always)]
653    fn from(variant: HYST_A) -> Self {
654        variant as u8 != 0
655    }
656}
657impl HYST_R {
658    ///Get enumerated values variant
659    #[inline(always)]
660    pub fn variant(&self) -> HYST_A {
661        match self.bits {
662            false => HYST_A::No,
663            true => HYST_A::Yes,
664        }
665    }
666    ///Checks if the value of the field is `No`
667    #[inline(always)]
668    pub fn is_no(&self) -> bool {
669        *self == HYST_A::No
670    }
671    ///Checks if the value of the field is `Yes`
672    #[inline(always)]
673    pub fn is_yes(&self) -> bool {
674        *self == HYST_A::Yes
675    }
676}
677///Field `HYST` writer - Comparator hysteresis enable selector
678pub type HYST_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, HYST_A, O>;
679impl<'a, const O: u8> HYST_W<'a, O> {
680    ///no Comp1 hysteresis
681    #[inline(always)]
682    pub fn no(self) -> &'a mut W {
683        self.variant(HYST_A::No)
684    }
685    ///Comp1 hysteresis voltage approx 20mV
686    #[inline(always)]
687    pub fn yes(self) -> &'a mut W {
688        self.variant(HYST_A::Yes)
689    }
690}
691///Field `PWRMODE` reader - Comparator power mode selector
692pub type PWRMODE_R = crate::FieldReader<u8, PWRMODE_A>;
693/**Comparator power mode selector
694
695Value on reset: 0*/
696#[derive(Clone, Copy, Debug, PartialEq, Eq)]
697#[repr(u8)]
698pub enum PWRMODE_A {
699    ///0: High speed 250 ua
700    HighSpeed = 0,
701    ///1: Medium speed 5 ua
702    MediumSpeed = 1,
703}
704impl From<PWRMODE_A> for u8 {
705    #[inline(always)]
706    fn from(variant: PWRMODE_A) -> Self {
707        variant as _
708    }
709}
710impl PWRMODE_R {
711    ///Get enumerated values variant
712    #[inline(always)]
713    pub fn variant(&self) -> Option<PWRMODE_A> {
714        match self.bits {
715            0 => Some(PWRMODE_A::HighSpeed),
716            1 => Some(PWRMODE_A::MediumSpeed),
717            _ => None,
718        }
719    }
720    ///Checks if the value of the field is `HighSpeed`
721    #[inline(always)]
722    pub fn is_high_speed(&self) -> bool {
723        *self == PWRMODE_A::HighSpeed
724    }
725    ///Checks if the value of the field is `MediumSpeed`
726    #[inline(always)]
727    pub fn is_medium_speed(&self) -> bool {
728        *self == PWRMODE_A::MediumSpeed
729    }
730}
731///Field `PWRMODE` writer - Comparator power mode selector
732pub type PWRMODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CSR_SPEC, u8, PWRMODE_A, 2, O>;
733impl<'a, const O: u8> PWRMODE_W<'a, O> {
734    ///High speed 250 ua
735    #[inline(always)]
736    pub fn high_speed(self) -> &'a mut W {
737        self.variant(PWRMODE_A::HighSpeed)
738    }
739    ///Medium speed 5 ua
740    #[inline(always)]
741    pub fn medium_speed(self) -> &'a mut W {
742        self.variant(PWRMODE_A::MediumSpeed)
743    }
744}
745///Field `VCDIV` reader - VCDIV
746pub type VCDIV_R = crate::FieldReader<u8, u8>;
747///Field `VCDIV` writer - VCDIV
748pub type VCDIV_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CSR_SPEC, u8, u8, 6, O>;
749///Field `VCDIV_EN` reader - VCDIV_EN
750pub type VCDIV_EN_R = crate::BitReader<VCDIV_EN_A>;
751/**VCDIV_EN
752
753Value on reset: 0*/
754#[derive(Clone, Copy, Debug, PartialEq, Eq)]
755pub enum VCDIV_EN_A {
756    ///0: Voltage division not enabled
757    Disabled = 0,
758    ///1: Voltage division enabled
759    Enabled = 1,
760}
761impl From<VCDIV_EN_A> for bool {
762    #[inline(always)]
763    fn from(variant: VCDIV_EN_A) -> Self {
764        variant as u8 != 0
765    }
766}
767impl VCDIV_EN_R {
768    ///Get enumerated values variant
769    #[inline(always)]
770    pub fn variant(&self) -> VCDIV_EN_A {
771        match self.bits {
772            false => VCDIV_EN_A::Disabled,
773            true => VCDIV_EN_A::Enabled,
774        }
775    }
776    ///Checks if the value of the field is `Disabled`
777    #[inline(always)]
778    pub fn is_disabled(&self) -> bool {
779        *self == VCDIV_EN_A::Disabled
780    }
781    ///Checks if the value of the field is `Enabled`
782    #[inline(always)]
783    pub fn is_enabled(&self) -> bool {
784        *self == VCDIV_EN_A::Enabled
785    }
786}
787///Field `VCDIV_EN` writer - VCDIV_EN
788pub type VCDIV_EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, VCDIV_EN_A, O>;
789impl<'a, const O: u8> VCDIV_EN_W<'a, O> {
790    ///Voltage division not enabled
791    #[inline(always)]
792    pub fn disabled(self) -> &'a mut W {
793        self.variant(VCDIV_EN_A::Disabled)
794    }
795    ///Voltage division enabled
796    #[inline(always)]
797    pub fn enabled(self) -> &'a mut W {
798        self.variant(VCDIV_EN_A::Enabled)
799    }
800}
801///Field `VCSEL` reader - VCSEL
802pub type VCSEL_R = crate::BitReader<VCSEL_A>;
803/**VCSEL
804
805Value on reset: 0*/
806#[derive(Clone, Copy, Debug, PartialEq, Eq)]
807pub enum VCSEL_A {
808    ///0: VCC
809    Vcc = 0,
810    ///1: ADC reference voltage
811    AdcRef = 1,
812}
813impl From<VCSEL_A> for bool {
814    #[inline(always)]
815    fn from(variant: VCSEL_A) -> Self {
816        variant as u8 != 0
817    }
818}
819impl VCSEL_R {
820    ///Get enumerated values variant
821    #[inline(always)]
822    pub fn variant(&self) -> VCSEL_A {
823        match self.bits {
824            false => VCSEL_A::Vcc,
825            true => VCSEL_A::AdcRef,
826        }
827    }
828    ///Checks if the value of the field is `Vcc`
829    #[inline(always)]
830    pub fn is_vcc(&self) -> bool {
831        *self == VCSEL_A::Vcc
832    }
833    ///Checks if the value of the field is `AdcRef`
834    #[inline(always)]
835    pub fn is_adc_ref(&self) -> bool {
836        *self == VCSEL_A::AdcRef
837    }
838}
839///Field `VCSEL` writer - VCSEL
840pub type VCSEL_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, VCSEL_A, O>;
841impl<'a, const O: u8> VCSEL_W<'a, O> {
842    ///VCC
843    #[inline(always)]
844    pub fn vcc(self) -> &'a mut W {
845        self.variant(VCSEL_A::Vcc)
846    }
847    ///ADC reference voltage
848    #[inline(always)]
849    pub fn adc_ref(self) -> &'a mut W {
850        self.variant(VCSEL_A::AdcRef)
851    }
852}
853///Field `VALUE` reader - Comparator output status
854pub type VALUE_R = crate::BitReader<VALUER_A>;
855/**Comparator output status
856
857Value on reset: 0*/
858#[derive(Clone, Copy, Debug, PartialEq, Eq)]
859pub enum VALUER_A {
860    ///0: Comparator output is low
861    Low = 0,
862    ///1: Comparator output is high
863    High = 1,
864}
865impl From<VALUER_A> for bool {
866    #[inline(always)]
867    fn from(variant: VALUER_A) -> Self {
868        variant as u8 != 0
869    }
870}
871impl VALUE_R {
872    ///Get enumerated values variant
873    #[inline(always)]
874    pub fn variant(&self) -> VALUER_A {
875        match self.bits {
876            false => VALUER_A::Low,
877            true => VALUER_A::High,
878        }
879    }
880    ///Checks if the value of the field is `Low`
881    #[inline(always)]
882    pub fn is_low(&self) -> bool {
883        *self == VALUER_A::Low
884    }
885    ///Checks if the value of the field is `High`
886    #[inline(always)]
887    pub fn is_high(&self) -> bool {
888        *self == VALUER_A::High
889    }
890}
891///Field `VALUE` writer - Comparator output status
892pub type VALUE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CSR_SPEC, VALUER_A, O>;
893impl<'a, const O: u8> VALUE_W<'a, O> {
894    ///Comparator output is low
895    #[inline(always)]
896    pub fn low(self) -> &'a mut W {
897        self.variant(VALUER_A::Low)
898    }
899    ///Comparator output is high
900    #[inline(always)]
901    pub fn high(self) -> &'a mut W {
902        self.variant(VALUER_A::High)
903    }
904}
905impl R {
906    ///Bit 0 - COMP enable bit
907    #[inline(always)]
908    pub fn en(&self) -> EN_R {
909        EN_R::new((self.bits & 1) != 0)
910    }
911    ///Bits 2:5 - Comparator signal selector for inverting input INM
912    #[inline(always)]
913    pub fn inmsel(&self) -> INMSEL_R {
914        INMSEL_R::new(((self.bits >> 2) & 0x0f) as u8)
915    }
916    ///Bits 6:9 - Comparator signal selector for non-inverting input
917    #[inline(always)]
918    pub fn inpsel(&self) -> INPSEL_R {
919        INPSEL_R::new(((self.bits >> 6) & 0x0f) as u8)
920    }
921    ///Bit 11 - Comparator non-inverting input selector for window mode
922    #[inline(always)]
923    pub fn winmode(&self) -> WINMODE_R {
924        WINMODE_R::new(((self.bits >> 11) & 1) != 0)
925    }
926    ///Bit 15 - Comparator polarity selector
927    #[inline(always)]
928    pub fn polarity(&self) -> POLARITY_R {
929        POLARITY_R::new(((self.bits >> 15) & 1) != 0)
930    }
931    ///Bit 16 - Comparator hysteresis enable selector
932    #[inline(always)]
933    pub fn hyst(&self) -> HYST_R {
934        HYST_R::new(((self.bits >> 16) & 1) != 0)
935    }
936    ///Bits 18:19 - Comparator power mode selector
937    #[inline(always)]
938    pub fn pwrmode(&self) -> PWRMODE_R {
939        PWRMODE_R::new(((self.bits >> 18) & 3) as u8)
940    }
941    ///Bits 20:25 - VCDIV
942    #[inline(always)]
943    pub fn vcdiv(&self) -> VCDIV_R {
944        VCDIV_R::new(((self.bits >> 20) & 0x3f) as u8)
945    }
946    ///Bit 26 - VCDIV_EN
947    #[inline(always)]
948    pub fn vcdiv_en(&self) -> VCDIV_EN_R {
949        VCDIV_EN_R::new(((self.bits >> 26) & 1) != 0)
950    }
951    ///Bit 27 - VCSEL
952    #[inline(always)]
953    pub fn vcsel(&self) -> VCSEL_R {
954        VCSEL_R::new(((self.bits >> 27) & 1) != 0)
955    }
956    ///Bit 30 - Comparator output status
957    #[inline(always)]
958    pub fn value(&self) -> VALUE_R {
959        VALUE_R::new(((self.bits >> 30) & 1) != 0)
960    }
961}
962impl W {
963    ///Bit 0 - COMP enable bit
964    #[inline(always)]
965    #[must_use]
966    pub fn en(&mut self) -> EN_W<0> {
967        EN_W::new(self)
968    }
969    ///Bits 2:5 - Comparator signal selector for inverting input INM
970    #[inline(always)]
971    #[must_use]
972    pub fn inmsel(&mut self) -> INMSEL_W<2> {
973        INMSEL_W::new(self)
974    }
975    ///Bits 6:9 - Comparator signal selector for non-inverting input
976    #[inline(always)]
977    #[must_use]
978    pub fn inpsel(&mut self) -> INPSEL_W<6> {
979        INPSEL_W::new(self)
980    }
981    ///Bit 11 - Comparator non-inverting input selector for window mode
982    #[inline(always)]
983    #[must_use]
984    pub fn winmode(&mut self) -> WINMODE_W<11> {
985        WINMODE_W::new(self)
986    }
987    ///Bit 15 - Comparator polarity selector
988    #[inline(always)]
989    #[must_use]
990    pub fn polarity(&mut self) -> POLARITY_W<15> {
991        POLARITY_W::new(self)
992    }
993    ///Bit 16 - Comparator hysteresis enable selector
994    #[inline(always)]
995    #[must_use]
996    pub fn hyst(&mut self) -> HYST_W<16> {
997        HYST_W::new(self)
998    }
999    ///Bits 18:19 - Comparator power mode selector
1000    #[inline(always)]
1001    #[must_use]
1002    pub fn pwrmode(&mut self) -> PWRMODE_W<18> {
1003        PWRMODE_W::new(self)
1004    }
1005    ///Bits 20:25 - VCDIV
1006    #[inline(always)]
1007    #[must_use]
1008    pub fn vcdiv(&mut self) -> VCDIV_W<20> {
1009        VCDIV_W::new(self)
1010    }
1011    ///Bit 26 - VCDIV_EN
1012    #[inline(always)]
1013    #[must_use]
1014    pub fn vcdiv_en(&mut self) -> VCDIV_EN_W<26> {
1015        VCDIV_EN_W::new(self)
1016    }
1017    ///Bit 27 - VCSEL
1018    #[inline(always)]
1019    #[must_use]
1020    pub fn vcsel(&mut self) -> VCSEL_W<27> {
1021        VCSEL_W::new(self)
1022    }
1023    ///Bit 30 - Comparator output status
1024    #[inline(always)]
1025    #[must_use]
1026    pub fn value(&mut self) -> VALUE_W<30> {
1027        VALUE_W::new(self)
1028    }
1029    ///Writes raw bits to the register.
1030    #[inline(always)]
1031    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
1032        self.0.bits(bits);
1033        self
1034    }
1035}
1036/**COMP control and status register
1037
1038This 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).
1039
1040For information about available fields see [csr](index.html) module*/
1041pub struct CSR_SPEC;
1042impl crate::RegisterSpec for CSR_SPEC {
1043    type Ux = u32;
1044}
1045///`read()` method returns [csr::R](R) reader structure
1046impl crate::Readable for CSR_SPEC {
1047    type Reader = R;
1048}
1049///`write(|w| ..)` method takes [csr::W](W) writer structure
1050impl crate::Writable for CSR_SPEC {
1051    type Writer = W;
1052    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
1053    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
1054}
1055///`reset()` method sets CSR to value 0
1056impl crate::Resettable for CSR_SPEC {
1057    const RESET_VALUE: Self::Ux = 0;
1058}