d1_pac/pwm/
cer.rs

1#[doc = "Register `cer` reader"]
2pub type R = crate::R<CER_SPEC>;
3#[doc = "Register `cer` writer"]
4pub type W = crate::W<CER_SPEC>;
5#[doc = "Field `cap_en[0-7]` reader - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
6pub type CAP_EN_R = crate::BitReader<CAP_EN_A>;
7#[doc = "When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge.\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum CAP_EN_A {
10    #[doc = "0: Capture disable"]
11    DISABLE = 0,
12    #[doc = "1: Capture enable"]
13    ENABLE = 1,
14}
15impl From<CAP_EN_A> for bool {
16    #[inline(always)]
17    fn from(variant: CAP_EN_A) -> Self {
18        variant as u8 != 0
19    }
20}
21impl CAP_EN_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> CAP_EN_A {
25        match self.bits {
26            false => CAP_EN_A::DISABLE,
27            true => CAP_EN_A::ENABLE,
28        }
29    }
30    #[doc = "Capture disable"]
31    #[inline(always)]
32    pub fn is_disable(&self) -> bool {
33        *self == CAP_EN_A::DISABLE
34    }
35    #[doc = "Capture enable"]
36    #[inline(always)]
37    pub fn is_enable(&self) -> bool {
38        *self == CAP_EN_A::ENABLE
39    }
40}
41#[doc = "Field `cap_en[0-7]` writer - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
42pub type CAP_EN_W<'a, REG> = crate::BitWriter<'a, REG, CAP_EN_A>;
43impl<'a, REG> CAP_EN_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "Capture disable"]
48    #[inline(always)]
49    pub fn disable(self) -> &'a mut crate::W<REG> {
50        self.variant(CAP_EN_A::DISABLE)
51    }
52    #[doc = "Capture enable"]
53    #[inline(always)]
54    pub fn enable(self) -> &'a mut crate::W<REG> {
55        self.variant(CAP_EN_A::ENABLE)
56    }
57}
58impl R {
59    #[doc = "When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge.\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `cap0_en` field"]
60    #[inline(always)]
61    pub fn cap_en(&self, n: u8) -> CAP_EN_R {
62        #[allow(clippy::no_effect)]
63        [(); 8][n as usize];
64        CAP_EN_R::new(((self.bits >> n) & 1) != 0)
65    }
66    #[doc = "Bit 0 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
67    #[inline(always)]
68    pub fn cap0_en(&self) -> CAP_EN_R {
69        CAP_EN_R::new((self.bits & 1) != 0)
70    }
71    #[doc = "Bit 1 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
72    #[inline(always)]
73    pub fn cap1_en(&self) -> CAP_EN_R {
74        CAP_EN_R::new(((self.bits >> 1) & 1) != 0)
75    }
76    #[doc = "Bit 2 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
77    #[inline(always)]
78    pub fn cap2_en(&self) -> CAP_EN_R {
79        CAP_EN_R::new(((self.bits >> 2) & 1) != 0)
80    }
81    #[doc = "Bit 3 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
82    #[inline(always)]
83    pub fn cap3_en(&self) -> CAP_EN_R {
84        CAP_EN_R::new(((self.bits >> 3) & 1) != 0)
85    }
86    #[doc = "Bit 4 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
87    #[inline(always)]
88    pub fn cap4_en(&self) -> CAP_EN_R {
89        CAP_EN_R::new(((self.bits >> 4) & 1) != 0)
90    }
91    #[doc = "Bit 5 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
92    #[inline(always)]
93    pub fn cap5_en(&self) -> CAP_EN_R {
94        CAP_EN_R::new(((self.bits >> 5) & 1) != 0)
95    }
96    #[doc = "Bit 6 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
97    #[inline(always)]
98    pub fn cap6_en(&self) -> CAP_EN_R {
99        CAP_EN_R::new(((self.bits >> 6) & 1) != 0)
100    }
101    #[doc = "Bit 7 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
102    #[inline(always)]
103    pub fn cap7_en(&self) -> CAP_EN_R {
104        CAP_EN_R::new(((self.bits >> 7) & 1) != 0)
105    }
106}
107impl W {
108    #[doc = "When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge.\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `cap0_en` field"]
109    #[inline(always)]
110    #[must_use]
111    pub fn cap_en(&mut self, n: u8) -> CAP_EN_W<CER_SPEC> {
112        #[allow(clippy::no_effect)]
113        [(); 8][n as usize];
114        CAP_EN_W::new(self, n)
115    }
116    #[doc = "Bit 0 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
117    #[inline(always)]
118    #[must_use]
119    pub fn cap0_en(&mut self) -> CAP_EN_W<CER_SPEC> {
120        CAP_EN_W::new(self, 0)
121    }
122    #[doc = "Bit 1 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
123    #[inline(always)]
124    #[must_use]
125    pub fn cap1_en(&mut self) -> CAP_EN_W<CER_SPEC> {
126        CAP_EN_W::new(self, 1)
127    }
128    #[doc = "Bit 2 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
129    #[inline(always)]
130    #[must_use]
131    pub fn cap2_en(&mut self) -> CAP_EN_W<CER_SPEC> {
132        CAP_EN_W::new(self, 2)
133    }
134    #[doc = "Bit 3 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
135    #[inline(always)]
136    #[must_use]
137    pub fn cap3_en(&mut self) -> CAP_EN_W<CER_SPEC> {
138        CAP_EN_W::new(self, 3)
139    }
140    #[doc = "Bit 4 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
141    #[inline(always)]
142    #[must_use]
143    pub fn cap4_en(&mut self) -> CAP_EN_W<CER_SPEC> {
144        CAP_EN_W::new(self, 4)
145    }
146    #[doc = "Bit 5 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
147    #[inline(always)]
148    #[must_use]
149    pub fn cap5_en(&mut self) -> CAP_EN_W<CER_SPEC> {
150        CAP_EN_W::new(self, 5)
151    }
152    #[doc = "Bit 6 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
153    #[inline(always)]
154    #[must_use]
155    pub fn cap6_en(&mut self) -> CAP_EN_W<CER_SPEC> {
156        CAP_EN_W::new(self, 6)
157    }
158    #[doc = "Bit 7 - When enabling the capture function, the 16-bit up-counter starts working, and the capture channel is permitted to capture external falling edge or rising edge."]
159    #[inline(always)]
160    #[must_use]
161    pub fn cap7_en(&mut self) -> CAP_EN_W<CER_SPEC> {
162        CAP_EN_W::new(self, 7)
163    }
164    #[doc = r" Writes raw bits to the register."]
165    #[doc = r""]
166    #[doc = r" # Safety"]
167    #[doc = r""]
168    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
169    #[inline(always)]
170    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
171        self.bits = bits;
172        self
173    }
174}
175#[doc = "Capture Enable Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`cer::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`cer::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
176pub struct CER_SPEC;
177impl crate::RegisterSpec for CER_SPEC {
178    type Ux = u32;
179}
180#[doc = "`read()` method returns [`cer::R`](R) reader structure"]
181impl crate::Readable for CER_SPEC {}
182#[doc = "`write(|w| ..)` method takes [`cer::W`](W) writer structure"]
183impl crate::Writable for CER_SPEC {
184    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
185    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
186}
187#[doc = "`reset()` method sets cer to value 0"]
188impl crate::Resettable for CER_SPEC {
189    const RESET_VALUE: Self::Ux = 0;
190}