mcxa_pac/cmp0/
ccr0.rs

1#[doc = "Register `CCR0` reader"]
2pub type R = crate::R<Ccr0Spec>;
3#[doc = "Register `CCR0` writer"]
4pub type W = crate::W<Ccr0Spec>;
5#[doc = "Comparator Enable\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum CmpEn {
9    #[doc = "0: Disable (The analog logic remains off and consumes no power.)"]
10    Disable = 0,
11    #[doc = "1: Enable"]
12    Enable = 1,
13}
14impl From<CmpEn> for bool {
15    #[inline(always)]
16    fn from(variant: CmpEn) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `CMP_EN` reader - Comparator Enable"]
21pub type CmpEnR = crate::BitReader<CmpEn>;
22impl CmpEnR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> CmpEn {
26        match self.bits {
27            false => CmpEn::Disable,
28            true => CmpEn::Enable,
29        }
30    }
31    #[doc = "Disable (The analog logic remains off and consumes no power.)"]
32    #[inline(always)]
33    pub fn is_disable(&self) -> bool {
34        *self == CmpEn::Disable
35    }
36    #[doc = "Enable"]
37    #[inline(always)]
38    pub fn is_enable(&self) -> bool {
39        *self == CmpEn::Enable
40    }
41}
42#[doc = "Field `CMP_EN` writer - Comparator Enable"]
43pub type CmpEnW<'a, REG> = crate::BitWriter<'a, REG, CmpEn>;
44impl<'a, REG> CmpEnW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "Disable (The analog logic remains off and consumes no power.)"]
49    #[inline(always)]
50    pub fn disable(self) -> &'a mut crate::W<REG> {
51        self.variant(CmpEn::Disable)
52    }
53    #[doc = "Enable"]
54    #[inline(always)]
55    pub fn enable(self) -> &'a mut crate::W<REG> {
56        self.variant(CmpEn::Enable)
57    }
58}
59#[doc = "Comparator Deep Sleep Mode Enable\n\nValue on reset: 1"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum CmpStopEn {
63    #[doc = "0: Disables the analog comparator regardless of CMP_EN."]
64    Disable = 0,
65    #[doc = "1: Allows CMP_EN to enable the analog comparator."]
66    Enable = 1,
67}
68impl From<CmpStopEn> for bool {
69    #[inline(always)]
70    fn from(variant: CmpStopEn) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `CMP_STOP_EN` reader - Comparator Deep Sleep Mode Enable"]
75pub type CmpStopEnR = crate::BitReader<CmpStopEn>;
76impl CmpStopEnR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> CmpStopEn {
80        match self.bits {
81            false => CmpStopEn::Disable,
82            true => CmpStopEn::Enable,
83        }
84    }
85    #[doc = "Disables the analog comparator regardless of CMP_EN."]
86    #[inline(always)]
87    pub fn is_disable(&self) -> bool {
88        *self == CmpStopEn::Disable
89    }
90    #[doc = "Allows CMP_EN to enable the analog comparator."]
91    #[inline(always)]
92    pub fn is_enable(&self) -> bool {
93        *self == CmpStopEn::Enable
94    }
95}
96#[doc = "Field `CMP_STOP_EN` writer - Comparator Deep Sleep Mode Enable"]
97pub type CmpStopEnW<'a, REG> = crate::BitWriter<'a, REG, CmpStopEn>;
98impl<'a, REG> CmpStopEnW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "Disables the analog comparator regardless of CMP_EN."]
103    #[inline(always)]
104    pub fn disable(self) -> &'a mut crate::W<REG> {
105        self.variant(CmpStopEn::Disable)
106    }
107    #[doc = "Allows CMP_EN to enable the analog comparator."]
108    #[inline(always)]
109    pub fn enable(self) -> &'a mut crate::W<REG> {
110        self.variant(CmpStopEn::Enable)
111    }
112}
113impl R {
114    #[doc = "Bit 0 - Comparator Enable"]
115    #[inline(always)]
116    pub fn cmp_en(&self) -> CmpEnR {
117        CmpEnR::new((self.bits & 1) != 0)
118    }
119    #[doc = "Bit 1 - Comparator Deep Sleep Mode Enable"]
120    #[inline(always)]
121    pub fn cmp_stop_en(&self) -> CmpStopEnR {
122        CmpStopEnR::new(((self.bits >> 1) & 1) != 0)
123    }
124}
125#[cfg(feature = "debug")]
126impl core::fmt::Debug for R {
127    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
128        f.debug_struct("CCR0")
129            .field("cmp_en", &self.cmp_en())
130            .field("cmp_stop_en", &self.cmp_stop_en())
131            .finish()
132    }
133}
134impl W {
135    #[doc = "Bit 0 - Comparator Enable"]
136    #[inline(always)]
137    pub fn cmp_en(&mut self) -> CmpEnW<'_, Ccr0Spec> {
138        CmpEnW::new(self, 0)
139    }
140    #[doc = "Bit 1 - Comparator Deep Sleep Mode Enable"]
141    #[inline(always)]
142    pub fn cmp_stop_en(&mut self) -> CmpStopEnW<'_, Ccr0Spec> {
143        CmpStopEnW::new(self, 1)
144    }
145}
146#[doc = "Comparator Control Register 0\n\nYou can [`read`](crate::Reg::read) this register and get [`ccr0::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ccr0::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
147pub struct Ccr0Spec;
148impl crate::RegisterSpec for Ccr0Spec {
149    type Ux = u32;
150}
151#[doc = "`read()` method returns [`ccr0::R`](R) reader structure"]
152impl crate::Readable for Ccr0Spec {}
153#[doc = "`write(|w| ..)` method takes [`ccr0::W`](W) writer structure"]
154impl crate::Writable for Ccr0Spec {
155    type Safety = crate::Unsafe;
156}
157#[doc = "`reset()` method sets CCR0 to value 0x02"]
158impl crate::Resettable for Ccr0Spec {
159    const RESET_VALUE: u32 = 0x02;
160}