ra4m3/cac/
cacr2.rs

1#[doc = "Register `CACR2` reader"]
2pub struct R(crate::R<CACR2_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CACR2_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CACR2_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CACR2_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CACR2` writer"]
17pub struct W(crate::W<CACR2_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CACR2_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<CACR2_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CACR2_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `RPS` reader - Reference Signal Select"]
38pub type RPS_R = crate::BitReader<RPS_A>;
39#[doc = "Reference Signal Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum RPS_A {
42    #[doc = "0: CACREF pin input"]
43    _0 = 0,
44    #[doc = "1: Internal clock (internally generated signal)"]
45    _1 = 1,
46}
47impl From<RPS_A> for bool {
48    #[inline(always)]
49    fn from(variant: RPS_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl RPS_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> RPS_A {
57        match self.bits {
58            false => RPS_A::_0,
59            true => RPS_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 == RPS_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 == RPS_A::_1
71    }
72}
73#[doc = "Field `RPS` writer - Reference Signal Select"]
74pub type RPS_W<'a, const O: u8> = crate::BitWriter<'a, u8, CACR2_SPEC, RPS_A, O>;
75impl<'a, const O: u8> RPS_W<'a, O> {
76    #[doc = "CACREF pin input"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(RPS_A::_0)
80    }
81    #[doc = "Internal clock (internally generated signal)"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(RPS_A::_1)
85    }
86}
87#[doc = "Field `RSCS` reader - Measurement Reference Clock Select"]
88pub type RSCS_R = crate::FieldReader<u8, RSCS_A>;
89#[doc = "Measurement Reference Clock Select\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum RSCS_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<RSCS_A> for u8 {
111    #[inline(always)]
112    fn from(variant: RSCS_A) -> Self {
113        variant as _
114    }
115}
116impl RSCS_R {
117    #[doc = "Get enumerated values variant"]
118    #[inline(always)]
119    pub fn variant(&self) -> RSCS_A {
120        match self.bits {
121            0 => RSCS_A::_000,
122            1 => RSCS_A::_001,
123            2 => RSCS_A::_010,
124            3 => RSCS_A::_011,
125            4 => RSCS_A::_100,
126            5 => RSCS_A::_101,
127            6 => RSCS_A::_110,
128            7 => RSCS_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 == RSCS_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 == RSCS_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 == RSCS_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 == RSCS_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 == RSCS_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 == RSCS_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 == RSCS_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 == RSCS_A::_111
171    }
172}
173#[doc = "Field `RSCS` writer - Measurement Reference Clock Select"]
174pub type RSCS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR2_SPEC, u8, RSCS_A, 3, O>;
175impl<'a, const O: u8> RSCS_W<'a, O> {
176    #[doc = "Main clock oscillator"]
177    #[inline(always)]
178    pub fn _000(self) -> &'a mut W {
179        self.variant(RSCS_A::_000)
180    }
181    #[doc = "Sub-clock oscillator"]
182    #[inline(always)]
183    pub fn _001(self) -> &'a mut W {
184        self.variant(RSCS_A::_001)
185    }
186    #[doc = "HOCO clock"]
187    #[inline(always)]
188    pub fn _010(self) -> &'a mut W {
189        self.variant(RSCS_A::_010)
190    }
191    #[doc = "MOCO clock"]
192    #[inline(always)]
193    pub fn _011(self) -> &'a mut W {
194        self.variant(RSCS_A::_011)
195    }
196    #[doc = "LOCO clock"]
197    #[inline(always)]
198    pub fn _100(self) -> &'a mut W {
199        self.variant(RSCS_A::_100)
200    }
201    #[doc = "Peripheral module clock B (PCLKB)"]
202    #[inline(always)]
203    pub fn _101(self) -> &'a mut W {
204        self.variant(RSCS_A::_101)
205    }
206    #[doc = "IWDT-dedicated clock"]
207    #[inline(always)]
208    pub fn _110(self) -> &'a mut W {
209        self.variant(RSCS_A::_110)
210    }
211    #[doc = "Setting prohibited"]
212    #[inline(always)]
213    pub fn _111(self) -> &'a mut W {
214        self.variant(RSCS_A::_111)
215    }
216}
217#[doc = "Field `RCDS` reader - Measurement Reference Clock Frequency Division Ratio Select"]
218pub type RCDS_R = crate::FieldReader<u8, RCDS_A>;
219#[doc = "Measurement Reference Clock Frequency Division Ratio Select\n\nValue on reset: 0"]
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221#[repr(u8)]
222pub enum RCDS_A {
223    #[doc = "0: x 1/32 clock"]
224    _00 = 0,
225    #[doc = "1: x 1/128 clock"]
226    _01 = 1,
227    #[doc = "2: x 1/1024 clock"]
228    _10 = 2,
229    #[doc = "3: x 1/8192 clock"]
230    _11 = 3,
231}
232impl From<RCDS_A> for u8 {
233    #[inline(always)]
234    fn from(variant: RCDS_A) -> Self {
235        variant as _
236    }
237}
238impl RCDS_R {
239    #[doc = "Get enumerated values variant"]
240    #[inline(always)]
241    pub fn variant(&self) -> RCDS_A {
242        match self.bits {
243            0 => RCDS_A::_00,
244            1 => RCDS_A::_01,
245            2 => RCDS_A::_10,
246            3 => RCDS_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 == RCDS_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 == RCDS_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 == RCDS_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 == RCDS_A::_11
269    }
270}
271#[doc = "Field `RCDS` writer - Measurement Reference Clock Frequency Division Ratio Select"]
272pub type RCDS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR2_SPEC, u8, RCDS_A, 2, O>;
273impl<'a, const O: u8> RCDS_W<'a, O> {
274    #[doc = "x 1/32 clock"]
275    #[inline(always)]
276    pub fn _00(self) -> &'a mut W {
277        self.variant(RCDS_A::_00)
278    }
279    #[doc = "x 1/128 clock"]
280    #[inline(always)]
281    pub fn _01(self) -> &'a mut W {
282        self.variant(RCDS_A::_01)
283    }
284    #[doc = "x 1/1024 clock"]
285    #[inline(always)]
286    pub fn _10(self) -> &'a mut W {
287        self.variant(RCDS_A::_10)
288    }
289    #[doc = "x 1/8192 clock"]
290    #[inline(always)]
291    pub fn _11(self) -> &'a mut W {
292        self.variant(RCDS_A::_11)
293    }
294}
295#[doc = "Field `DFS` reader - Digital Filter Select"]
296pub type DFS_R = crate::FieldReader<u8, DFS_A>;
297#[doc = "Digital Filter Select\n\nValue on reset: 0"]
298#[derive(Clone, Copy, Debug, PartialEq, Eq)]
299#[repr(u8)]
300pub enum DFS_A {
301    #[doc = "0: Disable digital filtering"]
302    _00 = 0,
303    #[doc = "1: Use sampling clock for the digital filter as the frequency measuring clock"]
304    _01 = 1,
305    #[doc = "2: Use sampling clock for the digital filter as the frequency measuring clock divided by 4"]
306    _10 = 2,
307    #[doc = "3: Use sampling clock for the digital filter as the frequency measuring clock divided by 16."]
308    _11 = 3,
309}
310impl From<DFS_A> for u8 {
311    #[inline(always)]
312    fn from(variant: DFS_A) -> Self {
313        variant as _
314    }
315}
316impl DFS_R {
317    #[doc = "Get enumerated values variant"]
318    #[inline(always)]
319    pub fn variant(&self) -> DFS_A {
320        match self.bits {
321            0 => DFS_A::_00,
322            1 => DFS_A::_01,
323            2 => DFS_A::_10,
324            3 => DFS_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 == DFS_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 == DFS_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 == DFS_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 == DFS_A::_11
347    }
348}
349#[doc = "Field `DFS` writer - Digital Filter Select"]
350pub type DFS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CACR2_SPEC, u8, DFS_A, 2, O>;
351impl<'a, const O: u8> DFS_W<'a, O> {
352    #[doc = "Disable digital filtering"]
353    #[inline(always)]
354    pub fn _00(self) -> &'a mut W {
355        self.variant(DFS_A::_00)
356    }
357    #[doc = "Use sampling clock for the digital filter as the frequency measuring clock"]
358    #[inline(always)]
359    pub fn _01(self) -> &'a mut W {
360        self.variant(DFS_A::_01)
361    }
362    #[doc = "Use sampling clock for the digital filter as the frequency measuring clock divided by 4"]
363    #[inline(always)]
364    pub fn _10(self) -> &'a mut W {
365        self.variant(DFS_A::_10)
366    }
367    #[doc = "Use sampling clock for the digital filter as the frequency measuring clock divided by 16."]
368    #[inline(always)]
369    pub fn _11(self) -> &'a mut W {
370        self.variant(DFS_A::_11)
371    }
372}
373impl R {
374    #[doc = "Bit 0 - Reference Signal Select"]
375    #[inline(always)]
376    pub fn rps(&self) -> RPS_R {
377        RPS_R::new((self.bits & 1) != 0)
378    }
379    #[doc = "Bits 1:3 - Measurement Reference Clock Select"]
380    #[inline(always)]
381    pub fn rscs(&self) -> RSCS_R {
382        RSCS_R::new((self.bits >> 1) & 7)
383    }
384    #[doc = "Bits 4:5 - Measurement Reference Clock Frequency Division Ratio Select"]
385    #[inline(always)]
386    pub fn rcds(&self) -> RCDS_R {
387        RCDS_R::new((self.bits >> 4) & 3)
388    }
389    #[doc = "Bits 6:7 - Digital Filter Select"]
390    #[inline(always)]
391    pub fn dfs(&self) -> DFS_R {
392        DFS_R::new((self.bits >> 6) & 3)
393    }
394}
395impl W {
396    #[doc = "Bit 0 - Reference Signal Select"]
397    #[inline(always)]
398    #[must_use]
399    pub fn rps(&mut self) -> RPS_W<0> {
400        RPS_W::new(self)
401    }
402    #[doc = "Bits 1:3 - Measurement Reference Clock Select"]
403    #[inline(always)]
404    #[must_use]
405    pub fn rscs(&mut self) -> RSCS_W<1> {
406        RSCS_W::new(self)
407    }
408    #[doc = "Bits 4:5 - Measurement Reference Clock Frequency Division Ratio Select"]
409    #[inline(always)]
410    #[must_use]
411    pub fn rcds(&mut self) -> RCDS_W<4> {
412        RCDS_W::new(self)
413    }
414    #[doc = "Bits 6:7 - Digital Filter Select"]
415    #[inline(always)]
416    #[must_use]
417    pub fn dfs(&mut self) -> DFS_W<6> {
418        DFS_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 2\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 [cacr2](index.html) module"]
428pub struct CACR2_SPEC;
429impl crate::RegisterSpec for CACR2_SPEC {
430    type Ux = u8;
431}
432#[doc = "`read()` method returns [cacr2::R](R) reader structure"]
433impl crate::Readable for CACR2_SPEC {
434    type Reader = R;
435}
436#[doc = "`write(|w| ..)` method takes [cacr2::W](W) writer structure"]
437impl crate::Writable for CACR2_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 CACR2 to value 0"]
443impl crate::Resettable for CACR2_SPEC {
444    const RESET_VALUE: Self::Ux = 0;
445}