SKEAZN642/acmp1/
cs.rs

1#[doc = "Register `CS` reader"]
2pub struct R(crate::R<CS_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CS_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl core::convert::From<crate::R<CS_SPEC>> for R {
11    fn from(reader: crate::R<CS_SPEC>) -> Self {
12        R(reader)
13    }
14}
15#[doc = "Register `CS` writer"]
16pub struct W(crate::W<CS_SPEC>);
17impl core::ops::Deref for W {
18    type Target = crate::W<CS_SPEC>;
19    #[inline(always)]
20    fn deref(&self) -> &Self::Target {
21        &self.0
22    }
23}
24impl core::ops::DerefMut for W {
25    #[inline(always)]
26    fn deref_mut(&mut self) -> &mut Self::Target {
27        &mut self.0
28    }
29}
30impl core::convert::From<crate::W<CS_SPEC>> for W {
31    fn from(writer: crate::W<CS_SPEC>) -> Self {
32        W(writer)
33    }
34}
35#[doc = "ACMP MOD\n\nValue on reset: 0"]
36#[derive(Clone, Copy, Debug, PartialEq)]
37#[repr(u8)]
38pub enum ACMOD_A {
39    #[doc = "0: ACMP interrupt on output falling edge."]
40    _00 = 0,
41    #[doc = "1: ACMP interrupt on output rising edge."]
42    _01 = 1,
43    #[doc = "2: ACMP interrupt on output falling edge."]
44    _10 = 2,
45    #[doc = "3: ACMP interrupt on output falling or rising edge."]
46    _11 = 3,
47}
48impl From<ACMOD_A> for u8 {
49    #[inline(always)]
50    fn from(variant: ACMOD_A) -> Self {
51        variant as _
52    }
53}
54#[doc = "Field `ACMOD` reader - ACMP MOD"]
55pub struct ACMOD_R(crate::FieldReader<u8, ACMOD_A>);
56impl ACMOD_R {
57    pub(crate) fn new(bits: u8) -> Self {
58        ACMOD_R(crate::FieldReader::new(bits))
59    }
60    #[doc = r"Get enumerated values variant"]
61    #[inline(always)]
62    pub fn variant(&self) -> ACMOD_A {
63        match self.bits {
64            0 => ACMOD_A::_00,
65            1 => ACMOD_A::_01,
66            2 => ACMOD_A::_10,
67            3 => ACMOD_A::_11,
68            _ => unreachable!(),
69        }
70    }
71    #[doc = "Checks if the value of the field is `_00`"]
72    #[inline(always)]
73    pub fn is_00(&self) -> bool {
74        **self == ACMOD_A::_00
75    }
76    #[doc = "Checks if the value of the field is `_01`"]
77    #[inline(always)]
78    pub fn is_01(&self) -> bool {
79        **self == ACMOD_A::_01
80    }
81    #[doc = "Checks if the value of the field is `_10`"]
82    #[inline(always)]
83    pub fn is_10(&self) -> bool {
84        **self == ACMOD_A::_10
85    }
86    #[doc = "Checks if the value of the field is `_11`"]
87    #[inline(always)]
88    pub fn is_11(&self) -> bool {
89        **self == ACMOD_A::_11
90    }
91}
92impl core::ops::Deref for ACMOD_R {
93    type Target = crate::FieldReader<u8, ACMOD_A>;
94    #[inline(always)]
95    fn deref(&self) -> &Self::Target {
96        &self.0
97    }
98}
99#[doc = "Field `ACMOD` writer - ACMP MOD"]
100pub struct ACMOD_W<'a> {
101    w: &'a mut W,
102}
103impl<'a> ACMOD_W<'a> {
104    #[doc = r"Writes `variant` to the field"]
105    #[inline(always)]
106    pub fn variant(self, variant: ACMOD_A) -> &'a mut W {
107        self.bits(variant.into())
108    }
109    #[doc = "ACMP interrupt on output falling edge."]
110    #[inline(always)]
111    pub fn _00(self) -> &'a mut W {
112        self.variant(ACMOD_A::_00)
113    }
114    #[doc = "ACMP interrupt on output rising edge."]
115    #[inline(always)]
116    pub fn _01(self) -> &'a mut W {
117        self.variant(ACMOD_A::_01)
118    }
119    #[doc = "ACMP interrupt on output falling edge."]
120    #[inline(always)]
121    pub fn _10(self) -> &'a mut W {
122        self.variant(ACMOD_A::_10)
123    }
124    #[doc = "ACMP interrupt on output falling or rising edge."]
125    #[inline(always)]
126    pub fn _11(self) -> &'a mut W {
127        self.variant(ACMOD_A::_11)
128    }
129    #[doc = r"Writes raw bits to the field"]
130    #[inline(always)]
131    pub fn bits(self, value: u8) -> &'a mut W {
132        self.w.bits = (self.w.bits & !0x03) | (value as u8 & 0x03);
133        self.w
134    }
135}
136#[doc = "ACMP Output Pin Enable\n\nValue on reset: 0"]
137#[derive(Clone, Copy, Debug, PartialEq)]
138pub enum ACOPE_A {
139    #[doc = "0: ACMP output cannot be placed onto external pin."]
140    _0 = 0,
141    #[doc = "1: ACMP output can be placed onto external pin."]
142    _1 = 1,
143}
144impl From<ACOPE_A> for bool {
145    #[inline(always)]
146    fn from(variant: ACOPE_A) -> Self {
147        variant as u8 != 0
148    }
149}
150#[doc = "Field `ACOPE` reader - ACMP Output Pin Enable"]
151pub struct ACOPE_R(crate::FieldReader<bool, ACOPE_A>);
152impl ACOPE_R {
153    pub(crate) fn new(bits: bool) -> Self {
154        ACOPE_R(crate::FieldReader::new(bits))
155    }
156    #[doc = r"Get enumerated values variant"]
157    #[inline(always)]
158    pub fn variant(&self) -> ACOPE_A {
159        match self.bits {
160            false => ACOPE_A::_0,
161            true => ACOPE_A::_1,
162        }
163    }
164    #[doc = "Checks if the value of the field is `_0`"]
165    #[inline(always)]
166    pub fn is_0(&self) -> bool {
167        **self == ACOPE_A::_0
168    }
169    #[doc = "Checks if the value of the field is `_1`"]
170    #[inline(always)]
171    pub fn is_1(&self) -> bool {
172        **self == ACOPE_A::_1
173    }
174}
175impl core::ops::Deref for ACOPE_R {
176    type Target = crate::FieldReader<bool, ACOPE_A>;
177    #[inline(always)]
178    fn deref(&self) -> &Self::Target {
179        &self.0
180    }
181}
182#[doc = "Field `ACOPE` writer - ACMP Output Pin Enable"]
183pub struct ACOPE_W<'a> {
184    w: &'a mut W,
185}
186impl<'a> ACOPE_W<'a> {
187    #[doc = r"Writes `variant` to the field"]
188    #[inline(always)]
189    pub fn variant(self, variant: ACOPE_A) -> &'a mut W {
190        self.bit(variant.into())
191    }
192    #[doc = "ACMP output cannot be placed onto external pin."]
193    #[inline(always)]
194    pub fn _0(self) -> &'a mut W {
195        self.variant(ACOPE_A::_0)
196    }
197    #[doc = "ACMP output can be placed onto external pin."]
198    #[inline(always)]
199    pub fn _1(self) -> &'a mut W {
200        self.variant(ACOPE_A::_1)
201    }
202    #[doc = r"Sets the field bit"]
203    #[inline(always)]
204    pub fn set_bit(self) -> &'a mut W {
205        self.bit(true)
206    }
207    #[doc = r"Clears the field bit"]
208    #[inline(always)]
209    pub fn clear_bit(self) -> &'a mut W {
210        self.bit(false)
211    }
212    #[doc = r"Writes raw bits to the field"]
213    #[inline(always)]
214    pub fn bit(self, value: bool) -> &'a mut W {
215        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u8 & 0x01) << 2);
216        self.w
217    }
218}
219#[doc = "Field `ACO` reader - ACMP Output"]
220pub struct ACO_R(crate::FieldReader<bool, bool>);
221impl ACO_R {
222    pub(crate) fn new(bits: bool) -> Self {
223        ACO_R(crate::FieldReader::new(bits))
224    }
225}
226impl core::ops::Deref for ACO_R {
227    type Target = crate::FieldReader<bool, bool>;
228    #[inline(always)]
229    fn deref(&self) -> &Self::Target {
230        &self.0
231    }
232}
233#[doc = "ACMP Interrupt Enable\n\nValue on reset: 0"]
234#[derive(Clone, Copy, Debug, PartialEq)]
235pub enum ACIE_A {
236    #[doc = "0: Disable the ACMP Interrupt."]
237    _0 = 0,
238    #[doc = "1: Enable the ACMP Interrupt."]
239    _1 = 1,
240}
241impl From<ACIE_A> for bool {
242    #[inline(always)]
243    fn from(variant: ACIE_A) -> Self {
244        variant as u8 != 0
245    }
246}
247#[doc = "Field `ACIE` reader - ACMP Interrupt Enable"]
248pub struct ACIE_R(crate::FieldReader<bool, ACIE_A>);
249impl ACIE_R {
250    pub(crate) fn new(bits: bool) -> Self {
251        ACIE_R(crate::FieldReader::new(bits))
252    }
253    #[doc = r"Get enumerated values variant"]
254    #[inline(always)]
255    pub fn variant(&self) -> ACIE_A {
256        match self.bits {
257            false => ACIE_A::_0,
258            true => ACIE_A::_1,
259        }
260    }
261    #[doc = "Checks if the value of the field is `_0`"]
262    #[inline(always)]
263    pub fn is_0(&self) -> bool {
264        **self == ACIE_A::_0
265    }
266    #[doc = "Checks if the value of the field is `_1`"]
267    #[inline(always)]
268    pub fn is_1(&self) -> bool {
269        **self == ACIE_A::_1
270    }
271}
272impl core::ops::Deref for ACIE_R {
273    type Target = crate::FieldReader<bool, ACIE_A>;
274    #[inline(always)]
275    fn deref(&self) -> &Self::Target {
276        &self.0
277    }
278}
279#[doc = "Field `ACIE` writer - ACMP Interrupt Enable"]
280pub struct ACIE_W<'a> {
281    w: &'a mut W,
282}
283impl<'a> ACIE_W<'a> {
284    #[doc = r"Writes `variant` to the field"]
285    #[inline(always)]
286    pub fn variant(self, variant: ACIE_A) -> &'a mut W {
287        self.bit(variant.into())
288    }
289    #[doc = "Disable the ACMP Interrupt."]
290    #[inline(always)]
291    pub fn _0(self) -> &'a mut W {
292        self.variant(ACIE_A::_0)
293    }
294    #[doc = "Enable the ACMP Interrupt."]
295    #[inline(always)]
296    pub fn _1(self) -> &'a mut W {
297        self.variant(ACIE_A::_1)
298    }
299    #[doc = r"Sets the field bit"]
300    #[inline(always)]
301    pub fn set_bit(self) -> &'a mut W {
302        self.bit(true)
303    }
304    #[doc = r"Clears the field bit"]
305    #[inline(always)]
306    pub fn clear_bit(self) -> &'a mut W {
307        self.bit(false)
308    }
309    #[doc = r"Writes raw bits to the field"]
310    #[inline(always)]
311    pub fn bit(self, value: bool) -> &'a mut W {
312        self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u8 & 0x01) << 4);
313        self.w
314    }
315}
316#[doc = "Field `ACF` reader - ACMP Interrupt Flag Bit"]
317pub struct ACF_R(crate::FieldReader<bool, bool>);
318impl ACF_R {
319    pub(crate) fn new(bits: bool) -> Self {
320        ACF_R(crate::FieldReader::new(bits))
321    }
322}
323impl core::ops::Deref for ACF_R {
324    type Target = crate::FieldReader<bool, bool>;
325    #[inline(always)]
326    fn deref(&self) -> &Self::Target {
327        &self.0
328    }
329}
330#[doc = "Field `ACF` writer - ACMP Interrupt Flag Bit"]
331pub struct ACF_W<'a> {
332    w: &'a mut W,
333}
334impl<'a> ACF_W<'a> {
335    #[doc = r"Sets the field bit"]
336    #[inline(always)]
337    pub fn set_bit(self) -> &'a mut W {
338        self.bit(true)
339    }
340    #[doc = r"Clears the field bit"]
341    #[inline(always)]
342    pub fn clear_bit(self) -> &'a mut W {
343        self.bit(false)
344    }
345    #[doc = r"Writes raw bits to the field"]
346    #[inline(always)]
347    pub fn bit(self, value: bool) -> &'a mut W {
348        self.w.bits = (self.w.bits & !(0x01 << 5)) | ((value as u8 & 0x01) << 5);
349        self.w
350    }
351}
352#[doc = "Analog Comparator Hysterisis Selection\n\nValue on reset: 0"]
353#[derive(Clone, Copy, Debug, PartialEq)]
354pub enum HYST_A {
355    #[doc = "0: 20 mV."]
356    _0 = 0,
357    #[doc = "1: 30 mV."]
358    _1 = 1,
359}
360impl From<HYST_A> for bool {
361    #[inline(always)]
362    fn from(variant: HYST_A) -> Self {
363        variant as u8 != 0
364    }
365}
366#[doc = "Field `HYST` reader - Analog Comparator Hysterisis Selection"]
367pub struct HYST_R(crate::FieldReader<bool, HYST_A>);
368impl HYST_R {
369    pub(crate) fn new(bits: bool) -> Self {
370        HYST_R(crate::FieldReader::new(bits))
371    }
372    #[doc = r"Get enumerated values variant"]
373    #[inline(always)]
374    pub fn variant(&self) -> HYST_A {
375        match self.bits {
376            false => HYST_A::_0,
377            true => HYST_A::_1,
378        }
379    }
380    #[doc = "Checks if the value of the field is `_0`"]
381    #[inline(always)]
382    pub fn is_0(&self) -> bool {
383        **self == HYST_A::_0
384    }
385    #[doc = "Checks if the value of the field is `_1`"]
386    #[inline(always)]
387    pub fn is_1(&self) -> bool {
388        **self == HYST_A::_1
389    }
390}
391impl core::ops::Deref for HYST_R {
392    type Target = crate::FieldReader<bool, HYST_A>;
393    #[inline(always)]
394    fn deref(&self) -> &Self::Target {
395        &self.0
396    }
397}
398#[doc = "Field `HYST` writer - Analog Comparator Hysterisis Selection"]
399pub struct HYST_W<'a> {
400    w: &'a mut W,
401}
402impl<'a> HYST_W<'a> {
403    #[doc = r"Writes `variant` to the field"]
404    #[inline(always)]
405    pub fn variant(self, variant: HYST_A) -> &'a mut W {
406        self.bit(variant.into())
407    }
408    #[doc = "20 mV."]
409    #[inline(always)]
410    pub fn _0(self) -> &'a mut W {
411        self.variant(HYST_A::_0)
412    }
413    #[doc = "30 mV."]
414    #[inline(always)]
415    pub fn _1(self) -> &'a mut W {
416        self.variant(HYST_A::_1)
417    }
418    #[doc = r"Sets the field bit"]
419    #[inline(always)]
420    pub fn set_bit(self) -> &'a mut W {
421        self.bit(true)
422    }
423    #[doc = r"Clears the field bit"]
424    #[inline(always)]
425    pub fn clear_bit(self) -> &'a mut W {
426        self.bit(false)
427    }
428    #[doc = r"Writes raw bits to the field"]
429    #[inline(always)]
430    pub fn bit(self, value: bool) -> &'a mut W {
431        self.w.bits = (self.w.bits & !(0x01 << 6)) | ((value as u8 & 0x01) << 6);
432        self.w
433    }
434}
435#[doc = "Analog Comparator Enable\n\nValue on reset: 0"]
436#[derive(Clone, Copy, Debug, PartialEq)]
437pub enum ACE_A {
438    #[doc = "0: The ACMP is disabled."]
439    _0 = 0,
440    #[doc = "1: The ACMP is enabled."]
441    _1 = 1,
442}
443impl From<ACE_A> for bool {
444    #[inline(always)]
445    fn from(variant: ACE_A) -> Self {
446        variant as u8 != 0
447    }
448}
449#[doc = "Field `ACE` reader - Analog Comparator Enable"]
450pub struct ACE_R(crate::FieldReader<bool, ACE_A>);
451impl ACE_R {
452    pub(crate) fn new(bits: bool) -> Self {
453        ACE_R(crate::FieldReader::new(bits))
454    }
455    #[doc = r"Get enumerated values variant"]
456    #[inline(always)]
457    pub fn variant(&self) -> ACE_A {
458        match self.bits {
459            false => ACE_A::_0,
460            true => ACE_A::_1,
461        }
462    }
463    #[doc = "Checks if the value of the field is `_0`"]
464    #[inline(always)]
465    pub fn is_0(&self) -> bool {
466        **self == ACE_A::_0
467    }
468    #[doc = "Checks if the value of the field is `_1`"]
469    #[inline(always)]
470    pub fn is_1(&self) -> bool {
471        **self == ACE_A::_1
472    }
473}
474impl core::ops::Deref for ACE_R {
475    type Target = crate::FieldReader<bool, ACE_A>;
476    #[inline(always)]
477    fn deref(&self) -> &Self::Target {
478        &self.0
479    }
480}
481#[doc = "Field `ACE` writer - Analog Comparator Enable"]
482pub struct ACE_W<'a> {
483    w: &'a mut W,
484}
485impl<'a> ACE_W<'a> {
486    #[doc = r"Writes `variant` to the field"]
487    #[inline(always)]
488    pub fn variant(self, variant: ACE_A) -> &'a mut W {
489        self.bit(variant.into())
490    }
491    #[doc = "The ACMP is disabled."]
492    #[inline(always)]
493    pub fn _0(self) -> &'a mut W {
494        self.variant(ACE_A::_0)
495    }
496    #[doc = "The ACMP is enabled."]
497    #[inline(always)]
498    pub fn _1(self) -> &'a mut W {
499        self.variant(ACE_A::_1)
500    }
501    #[doc = r"Sets the field bit"]
502    #[inline(always)]
503    pub fn set_bit(self) -> &'a mut W {
504        self.bit(true)
505    }
506    #[doc = r"Clears the field bit"]
507    #[inline(always)]
508    pub fn clear_bit(self) -> &'a mut W {
509        self.bit(false)
510    }
511    #[doc = r"Writes raw bits to the field"]
512    #[inline(always)]
513    pub fn bit(self, value: bool) -> &'a mut W {
514        self.w.bits = (self.w.bits & !(0x01 << 7)) | ((value as u8 & 0x01) << 7);
515        self.w
516    }
517}
518impl R {
519    #[doc = "Bits 0:1 - ACMP MOD"]
520    #[inline(always)]
521    pub fn acmod(&self) -> ACMOD_R {
522        ACMOD_R::new((self.bits & 0x03) as u8)
523    }
524    #[doc = "Bit 2 - ACMP Output Pin Enable"]
525    #[inline(always)]
526    pub fn acope(&self) -> ACOPE_R {
527        ACOPE_R::new(((self.bits >> 2) & 0x01) != 0)
528    }
529    #[doc = "Bit 3 - ACMP Output"]
530    #[inline(always)]
531    pub fn aco(&self) -> ACO_R {
532        ACO_R::new(((self.bits >> 3) & 0x01) != 0)
533    }
534    #[doc = "Bit 4 - ACMP Interrupt Enable"]
535    #[inline(always)]
536    pub fn acie(&self) -> ACIE_R {
537        ACIE_R::new(((self.bits >> 4) & 0x01) != 0)
538    }
539    #[doc = "Bit 5 - ACMP Interrupt Flag Bit"]
540    #[inline(always)]
541    pub fn acf(&self) -> ACF_R {
542        ACF_R::new(((self.bits >> 5) & 0x01) != 0)
543    }
544    #[doc = "Bit 6 - Analog Comparator Hysterisis Selection"]
545    #[inline(always)]
546    pub fn hyst(&self) -> HYST_R {
547        HYST_R::new(((self.bits >> 6) & 0x01) != 0)
548    }
549    #[doc = "Bit 7 - Analog Comparator Enable"]
550    #[inline(always)]
551    pub fn ace(&self) -> ACE_R {
552        ACE_R::new(((self.bits >> 7) & 0x01) != 0)
553    }
554}
555impl W {
556    #[doc = "Bits 0:1 - ACMP MOD"]
557    #[inline(always)]
558    pub fn acmod(&mut self) -> ACMOD_W {
559        ACMOD_W { w: self }
560    }
561    #[doc = "Bit 2 - ACMP Output Pin Enable"]
562    #[inline(always)]
563    pub fn acope(&mut self) -> ACOPE_W {
564        ACOPE_W { w: self }
565    }
566    #[doc = "Bit 4 - ACMP Interrupt Enable"]
567    #[inline(always)]
568    pub fn acie(&mut self) -> ACIE_W {
569        ACIE_W { w: self }
570    }
571    #[doc = "Bit 5 - ACMP Interrupt Flag Bit"]
572    #[inline(always)]
573    pub fn acf(&mut self) -> ACF_W {
574        ACF_W { w: self }
575    }
576    #[doc = "Bit 6 - Analog Comparator Hysterisis Selection"]
577    #[inline(always)]
578    pub fn hyst(&mut self) -> HYST_W {
579        HYST_W { w: self }
580    }
581    #[doc = "Bit 7 - Analog Comparator Enable"]
582    #[inline(always)]
583    pub fn ace(&mut self) -> ACE_W {
584        ACE_W { w: self }
585    }
586    #[doc = "Writes raw bits to the register."]
587    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
588        self.0.bits(bits);
589        self
590    }
591}
592#[doc = "ACMP Control and Status 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 [cs](index.html) module"]
593pub struct CS_SPEC;
594impl crate::RegisterSpec for CS_SPEC {
595    type Ux = u8;
596}
597#[doc = "`read()` method returns [cs::R](R) reader structure"]
598impl crate::Readable for CS_SPEC {
599    type Reader = R;
600}
601#[doc = "`write(|w| ..)` method takes [cs::W](W) writer structure"]
602impl crate::Writable for CS_SPEC {
603    type Writer = W;
604}
605#[doc = "`reset()` method sets CS to value 0"]
606impl crate::Resettable for CS_SPEC {
607    #[inline(always)]
608    fn reset_value() -> Self::Ux {
609        0
610    }
611}