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