ra4e1/cac/
cacr1.rs

1#[doc = "Register `CACR1` reader"]
2pub struct R(crate::R<CACR1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CACR1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CACR1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CACR1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CACR1` writer"]
17pub struct W(crate::W<CACR1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CACR1_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<CACR1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CACR1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CACREFE` reader - CACREF Pin Input Enable"]
38pub type CACREFE_R = crate::BitReader<CACREFE_A>;
39#[doc = "CACREF Pin Input Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum CACREFE_A {
42    #[doc = "0: Disable"]
43    _0 = 0,
44    #[doc = "1: Enable"]
45    _1 = 1,
46}
47impl From<CACREFE_A> for bool {
48    #[inline(always)]
49    fn from(variant: CACREFE_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl CACREFE_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> CACREFE_A {
57        match self.bits {
58            false => CACREFE_A::_0,
59            true => CACREFE_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == CACREFE_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == CACREFE_A::_1
71    }
72}
73#[doc = "Field `CACREFE` writer - CACREF Pin Input Enable"]
74pub type CACREFE_W<'a, const O: u8> = crate::BitWriter<'a, u8, CACR1_SPEC, CACREFE_A, O>;
75impl<'a, const O: u8> CACREFE_W<'a, O> {
76    #[doc = "Disable"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(CACREFE_A::_0)
80    }
81    #[doc = "Enable"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(CACREFE_A::_1)
85    }
86}
87#[doc = "Field `FMCS` reader - Measurement Target Clock Select"]
88pub type FMCS_R = crate::FieldReader<u8, FMCS_A>;
89#[doc = "Measurement Target Clock Select\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum FMCS_A {
93    #[doc = "0: Main clock oscillator"]
94    _000 = 0,
95    #[doc = "1: Sub-clock oscillator"]
96    _001 = 1,
97    #[doc = "2: HOCO clock"]
98    _010 = 2,
99    #[doc = "3: MOCO clock"]
100    _011 = 3,
101    #[doc = "4: LOCO clock"]
102    _100 = 4,
103    #[doc = "5: Peripheral module clock B (PCLKB)"]
104    _101 = 5,
105    #[doc = "6: IWDT-dedicated clock"]
106    _110 = 6,
107    #[doc = "7: Setting prohibited"]
108    _111 = 7,
109}
110impl From<FMCS_A> for u8 {
111    #[inline(always)]
112    fn from(variant: FMCS_A) -> Self {
113        variant as _
114    }
115}
116impl FMCS_R {
117    #[doc = "Get enumerated values variant"]
118    #[inline(always)]
119    pub fn variant(&self) -> FMCS_A {
120        match self.bits {
121            0 => FMCS_A::_000,
122            1 => FMCS_A::_001,
123            2 => FMCS_A::_010,
124            3 => FMCS_A::_011,
125            4 => FMCS_A::_100,
126            5 => FMCS_A::_101,
127            6 => FMCS_A::_110,
128            7 => FMCS_A::_111,
129            _ => unreachable!(),
130        }
131    }
132    #[doc = "Checks if the value of the field is `_000`"]
133    #[inline(always)]
134    pub fn is_000(&self) -> bool {
135        *self == FMCS_A::_000
136    }
137    #[doc = "Checks if the value of the field is `_001`"]
138    #[inline(always)]
139    pub fn is_001(&self) -> bool {
140        *self == FMCS_A::_001
141    }
142    #[doc = "Checks if the value of the field is `_010`"]
143    #[inline(always)]
144    pub fn is_010(&self) -> bool {
145        *self == FMCS_A::_010
146    }
147    #[doc = "Checks if the value of the field is `_011`"]
148    #[inline(always)]
149    pub fn is_011(&self) -> bool {
150        *self == FMCS_A::_011
151    }
152    #[doc = "Checks if the value of the field is `_100`"]
153    #[inline(always)]
154    pub fn is_100(&self) -> bool {
155        *self == FMCS_A::_100
156    }
157    #[doc = "Checks if the value of the field is `_101`"]
158    #[inline(always)]
159    pub fn is_101(&self) -> bool {
160        *self == FMCS_A::_101
161    }
162    #[doc = "Checks if the value of the field is `_110`"]
163    #[inline(always)]
164    pub fn is_110(&self) -> bool {
165        *self == FMCS_A::_110
166    }
167    #[doc = "Checks if the value of the field is `_111`"]
168    #[inline(always)]
169    pub fn is_111(&self) -> bool {
170        *self == FMCS_A::_111
171    }
172}
173#[doc = "Field `FMCS` writer - Measurement Target Clock Select"]
174pub type FMCS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR1_SPEC, u8, FMCS_A, 3, O>;
175impl<'a, const O: u8> FMCS_W<'a, O> {
176    #[doc = "Main clock oscillator"]
177    #[inline(always)]
178    pub fn _000(self) -> &'a mut W {
179        self.variant(FMCS_A::_000)
180    }
181    #[doc = "Sub-clock oscillator"]
182    #[inline(always)]
183    pub fn _001(self) -> &'a mut W {
184        self.variant(FMCS_A::_001)
185    }
186    #[doc = "HOCO clock"]
187    #[inline(always)]
188    pub fn _010(self) -> &'a mut W {
189        self.variant(FMCS_A::_010)
190    }
191    #[doc = "MOCO clock"]
192    #[inline(always)]
193    pub fn _011(self) -> &'a mut W {
194        self.variant(FMCS_A::_011)
195    }
196    #[doc = "LOCO clock"]
197    #[inline(always)]
198    pub fn _100(self) -> &'a mut W {
199        self.variant(FMCS_A::_100)
200    }
201    #[doc = "Peripheral module clock B (PCLKB)"]
202    #[inline(always)]
203    pub fn _101(self) -> &'a mut W {
204        self.variant(FMCS_A::_101)
205    }
206    #[doc = "IWDT-dedicated clock"]
207    #[inline(always)]
208    pub fn _110(self) -> &'a mut W {
209        self.variant(FMCS_A::_110)
210    }
211    #[doc = "Setting prohibited"]
212    #[inline(always)]
213    pub fn _111(self) -> &'a mut W {
214        self.variant(FMCS_A::_111)
215    }
216}
217#[doc = "Field `TCSS` reader - Timer Count Clock Source Select"]
218pub type TCSS_R = crate::FieldReader<u8, TCSS_A>;
219#[doc = "Timer Count Clock Source Select\n\nValue on reset: 0"]
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221#[repr(u8)]
222pub enum TCSS_A {
223    #[doc = "0: No division"]
224    _00 = 0,
225    #[doc = "1: x 1/4 clock"]
226    _01 = 1,
227    #[doc = "2: x 1/8 clock"]
228    _10 = 2,
229    #[doc = "3: x 1/32 clock"]
230    _11 = 3,
231}
232impl From<TCSS_A> for u8 {
233    #[inline(always)]
234    fn from(variant: TCSS_A) -> Self {
235        variant as _
236    }
237}
238impl TCSS_R {
239    #[doc = "Get enumerated values variant"]
240    #[inline(always)]
241    pub fn variant(&self) -> TCSS_A {
242        match self.bits {
243            0 => TCSS_A::_00,
244            1 => TCSS_A::_01,
245            2 => TCSS_A::_10,
246            3 => TCSS_A::_11,
247            _ => unreachable!(),
248        }
249    }
250    #[doc = "Checks if the value of the field is `_00`"]
251    #[inline(always)]
252    pub fn is_00(&self) -> bool {
253        *self == TCSS_A::_00
254    }
255    #[doc = "Checks if the value of the field is `_01`"]
256    #[inline(always)]
257    pub fn is_01(&self) -> bool {
258        *self == TCSS_A::_01
259    }
260    #[doc = "Checks if the value of the field is `_10`"]
261    #[inline(always)]
262    pub fn is_10(&self) -> bool {
263        *self == TCSS_A::_10
264    }
265    #[doc = "Checks if the value of the field is `_11`"]
266    #[inline(always)]
267    pub fn is_11(&self) -> bool {
268        *self == TCSS_A::_11
269    }
270}
271#[doc = "Field `TCSS` writer - Timer Count Clock Source Select"]
272pub type TCSS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR1_SPEC, u8, TCSS_A, 2, O>;
273impl<'a, const O: u8> TCSS_W<'a, O> {
274    #[doc = "No division"]
275    #[inline(always)]
276    pub fn _00(self) -> &'a mut W {
277        self.variant(TCSS_A::_00)
278    }
279    #[doc = "x 1/4 clock"]
280    #[inline(always)]
281    pub fn _01(self) -> &'a mut W {
282        self.variant(TCSS_A::_01)
283    }
284    #[doc = "x 1/8 clock"]
285    #[inline(always)]
286    pub fn _10(self) -> &'a mut W {
287        self.variant(TCSS_A::_10)
288    }
289    #[doc = "x 1/32 clock"]
290    #[inline(always)]
291    pub fn _11(self) -> &'a mut W {
292        self.variant(TCSS_A::_11)
293    }
294}
295#[doc = "Field `EDGES` reader - Valid Edge Select"]
296pub type EDGES_R = crate::FieldReader<u8, EDGES_A>;
297#[doc = "Valid Edge Select\n\nValue on reset: 0"]
298#[derive(Clone, Copy, Debug, PartialEq, Eq)]
299#[repr(u8)]
300pub enum EDGES_A {
301    #[doc = "0: Rising edge"]
302    _00 = 0,
303    #[doc = "1: Falling edge"]
304    _01 = 1,
305    #[doc = "2: Both rising and falling edges"]
306    _10 = 2,
307    #[doc = "3: Setting prohibited"]
308    _11 = 3,
309}
310impl From<EDGES_A> for u8 {
311    #[inline(always)]
312    fn from(variant: EDGES_A) -> Self {
313        variant as _
314    }
315}
316impl EDGES_R {
317    #[doc = "Get enumerated values variant"]
318    #[inline(always)]
319    pub fn variant(&self) -> EDGES_A {
320        match self.bits {
321            0 => EDGES_A::_00,
322            1 => EDGES_A::_01,
323            2 => EDGES_A::_10,
324            3 => EDGES_A::_11,
325            _ => unreachable!(),
326        }
327    }
328    #[doc = "Checks if the value of the field is `_00`"]
329    #[inline(always)]
330    pub fn is_00(&self) -> bool {
331        *self == EDGES_A::_00
332    }
333    #[doc = "Checks if the value of the field is `_01`"]
334    #[inline(always)]
335    pub fn is_01(&self) -> bool {
336        *self == EDGES_A::_01
337    }
338    #[doc = "Checks if the value of the field is `_10`"]
339    #[inline(always)]
340    pub fn is_10(&self) -> bool {
341        *self == EDGES_A::_10
342    }
343    #[doc = "Checks if the value of the field is `_11`"]
344    #[inline(always)]
345    pub fn is_11(&self) -> bool {
346        *self == EDGES_A::_11
347    }
348}
349#[doc = "Field `EDGES` writer - Valid Edge Select"]
350pub type EDGES_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR1_SPEC, u8, EDGES_A, 2, O>;
351impl<'a, const O: u8> EDGES_W<'a, O> {
352    #[doc = "Rising edge"]
353    #[inline(always)]
354    pub fn _00(self) -> &'a mut W {
355        self.variant(EDGES_A::_00)
356    }
357    #[doc = "Falling edge"]
358    #[inline(always)]
359    pub fn _01(self) -> &'a mut W {
360        self.variant(EDGES_A::_01)
361    }
362    #[doc = "Both rising and falling edges"]
363    #[inline(always)]
364    pub fn _10(self) -> &'a mut W {
365        self.variant(EDGES_A::_10)
366    }
367    #[doc = "Setting prohibited"]
368    #[inline(always)]
369    pub fn _11(self) -> &'a mut W {
370        self.variant(EDGES_A::_11)
371    }
372}
373impl R {
374    #[doc = "Bit 0 - CACREF Pin Input Enable"]
375    #[inline(always)]
376    pub fn cacrefe(&self) -> CACREFE_R {
377        CACREFE_R::new((self.bits & 1) != 0)
378    }
379    #[doc = "Bits 1:3 - Measurement Target Clock Select"]
380    #[inline(always)]
381    pub fn fmcs(&self) -> FMCS_R {
382        FMCS_R::new((self.bits >> 1) & 7)
383    }
384    #[doc = "Bits 4:5 - Timer Count Clock Source Select"]
385    #[inline(always)]
386    pub fn tcss(&self) -> TCSS_R {
387        TCSS_R::new((self.bits >> 4) & 3)
388    }
389    #[doc = "Bits 6:7 - Valid Edge Select"]
390    #[inline(always)]
391    pub fn edges(&self) -> EDGES_R {
392        EDGES_R::new((self.bits >> 6) & 3)
393    }
394}
395impl W {
396    #[doc = "Bit 0 - CACREF Pin Input Enable"]
397    #[inline(always)]
398    #[must_use]
399    pub fn cacrefe(&mut self) -> CACREFE_W<0> {
400        CACREFE_W::new(self)
401    }
402    #[doc = "Bits 1:3 - Measurement Target Clock Select"]
403    #[inline(always)]
404    #[must_use]
405    pub fn fmcs(&mut self) -> FMCS_W<1> {
406        FMCS_W::new(self)
407    }
408    #[doc = "Bits 4:5 - Timer Count Clock Source Select"]
409    #[inline(always)]
410    #[must_use]
411    pub fn tcss(&mut self) -> TCSS_W<4> {
412        TCSS_W::new(self)
413    }
414    #[doc = "Bits 6:7 - Valid Edge Select"]
415    #[inline(always)]
416    #[must_use]
417    pub fn edges(&mut self) -> EDGES_W<6> {
418        EDGES_W::new(self)
419    }
420    #[doc = "Writes raw bits to the register."]
421    #[inline(always)]
422    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
423        self.0.bits(bits);
424        self
425    }
426}
427#[doc = "CAC Control Register 1\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 [cacr1](index.html) module"]
428pub struct CACR1_SPEC;
429impl crate::RegisterSpec for CACR1_SPEC {
430    type Ux = u8;
431}
432#[doc = "`read()` method returns [cacr1::R](R) reader structure"]
433impl crate::Readable for CACR1_SPEC {
434    type Reader = R;
435}
436#[doc = "`write(|w| ..)` method takes [cacr1::W](W) writer structure"]
437impl crate::Writable for CACR1_SPEC {
438    type Writer = W;
439    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
440    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
441}
442#[doc = "`reset()` method sets CACR1 to value 0"]
443impl crate::Resettable for CACR1_SPEC {
444    const RESET_VALUE: Self::Ux = 0;
445}