Skip to main content

ke06z4_pac/ics/
c1.rs

1#[doc = "Reader of register C1"]
2pub type R = crate::R<u8, super::C1>;
3#[doc = "Writer for register C1"]
4pub type W = crate::W<u8, super::C1>;
5#[doc = "Register C1 `reset()`'s with value 0x04"]
6impl crate::ResetValue for super::C1 {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x04
11    }
12}
13#[doc = "Internal Reference Stop Enable\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum IREFSTEN_A {
16    #[doc = "0: Internal reference clock is disabled in Stop mode."]
17    _0 = 0,
18    #[doc = "1: Internal reference clock stays enabled in Stop mode if IRCLKEN is set, or if ICS is in FEI, FBI, or FBILP mode before entering Stop."]
19    _1 = 1,
20}
21impl From<IREFSTEN_A> for bool {
22    #[inline(always)]
23    fn from(variant: IREFSTEN_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `IREFSTEN`"]
28pub type IREFSTEN_R = crate::R<bool, IREFSTEN_A>;
29impl IREFSTEN_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> IREFSTEN_A {
33        match self.bits {
34            false => IREFSTEN_A::_0,
35            true => IREFSTEN_A::_1,
36        }
37    }
38    #[doc = "Checks if the value of the field is `_0`"]
39    #[inline(always)]
40    pub fn is_0(&self) -> bool {
41        *self == IREFSTEN_A::_0
42    }
43    #[doc = "Checks if the value of the field is `_1`"]
44    #[inline(always)]
45    pub fn is_1(&self) -> bool {
46        *self == IREFSTEN_A::_1
47    }
48}
49#[doc = "Write proxy for field `IREFSTEN`"]
50pub struct IREFSTEN_W<'a> {
51    w: &'a mut W,
52}
53impl<'a> IREFSTEN_W<'a> {
54    #[doc = r"Writes `variant` to the field"]
55    #[inline(always)]
56    pub fn variant(self, variant: IREFSTEN_A) -> &'a mut W {
57        {
58            self.bit(variant.into())
59        }
60    }
61    #[doc = "Internal reference clock is disabled in Stop mode."]
62    #[inline(always)]
63    pub fn _0(self) -> &'a mut W {
64        self.variant(IREFSTEN_A::_0)
65    }
66    #[doc = "Internal reference clock stays enabled in Stop mode if IRCLKEN is set, or if ICS is in FEI, FBI, or FBILP mode before entering Stop."]
67    #[inline(always)]
68    pub fn _1(self) -> &'a mut W {
69        self.variant(IREFSTEN_A::_1)
70    }
71    #[doc = r"Sets the field bit"]
72    #[inline(always)]
73    pub fn set_bit(self) -> &'a mut W {
74        self.bit(true)
75    }
76    #[doc = r"Clears the field bit"]
77    #[inline(always)]
78    pub fn clear_bit(self) -> &'a mut W {
79        self.bit(false)
80    }
81    #[doc = r"Writes raw bits to the field"]
82    #[inline(always)]
83    pub fn bit(self, value: bool) -> &'a mut W {
84        self.w.bits = (self.w.bits & !0x01) | ((value as u8) & 0x01);
85        self.w
86    }
87}
88#[doc = "Internal Reference Clock Enable\n\nValue on reset: 0"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90pub enum IRCLKEN_A {
91    #[doc = "0: ICSIRCLK is inactive."]
92    _0 = 0,
93    #[doc = "1: ICSIRCLK is active."]
94    _1 = 1,
95}
96impl From<IRCLKEN_A> for bool {
97    #[inline(always)]
98    fn from(variant: IRCLKEN_A) -> Self {
99        variant as u8 != 0
100    }
101}
102#[doc = "Reader of field `IRCLKEN`"]
103pub type IRCLKEN_R = crate::R<bool, IRCLKEN_A>;
104impl IRCLKEN_R {
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> IRCLKEN_A {
108        match self.bits {
109            false => IRCLKEN_A::_0,
110            true => IRCLKEN_A::_1,
111        }
112    }
113    #[doc = "Checks if the value of the field is `_0`"]
114    #[inline(always)]
115    pub fn is_0(&self) -> bool {
116        *self == IRCLKEN_A::_0
117    }
118    #[doc = "Checks if the value of the field is `_1`"]
119    #[inline(always)]
120    pub fn is_1(&self) -> bool {
121        *self == IRCLKEN_A::_1
122    }
123}
124#[doc = "Write proxy for field `IRCLKEN`"]
125pub struct IRCLKEN_W<'a> {
126    w: &'a mut W,
127}
128impl<'a> IRCLKEN_W<'a> {
129    #[doc = r"Writes `variant` to the field"]
130    #[inline(always)]
131    pub fn variant(self, variant: IRCLKEN_A) -> &'a mut W {
132        {
133            self.bit(variant.into())
134        }
135    }
136    #[doc = "ICSIRCLK is inactive."]
137    #[inline(always)]
138    pub fn _0(self) -> &'a mut W {
139        self.variant(IRCLKEN_A::_0)
140    }
141    #[doc = "ICSIRCLK is active."]
142    #[inline(always)]
143    pub fn _1(self) -> &'a mut W {
144        self.variant(IRCLKEN_A::_1)
145    }
146    #[doc = r"Sets the field bit"]
147    #[inline(always)]
148    pub fn set_bit(self) -> &'a mut W {
149        self.bit(true)
150    }
151    #[doc = r"Clears the field bit"]
152    #[inline(always)]
153    pub fn clear_bit(self) -> &'a mut W {
154        self.bit(false)
155    }
156    #[doc = r"Writes raw bits to the field"]
157    #[inline(always)]
158    pub fn bit(self, value: bool) -> &'a mut W {
159        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
160        self.w
161    }
162}
163#[doc = "Internal Reference Select\n\nValue on reset: 1"]
164#[derive(Clone, Copy, Debug, PartialEq)]
165pub enum IREFS_A {
166    #[doc = "0: External reference clock is selected."]
167    _0 = 0,
168    #[doc = "1: Internal reference clock is selected."]
169    _1 = 1,
170}
171impl From<IREFS_A> for bool {
172    #[inline(always)]
173    fn from(variant: IREFS_A) -> Self {
174        variant as u8 != 0
175    }
176}
177#[doc = "Reader of field `IREFS`"]
178pub type IREFS_R = crate::R<bool, IREFS_A>;
179impl IREFS_R {
180    #[doc = r"Get enumerated values variant"]
181    #[inline(always)]
182    pub fn variant(&self) -> IREFS_A {
183        match self.bits {
184            false => IREFS_A::_0,
185            true => IREFS_A::_1,
186        }
187    }
188    #[doc = "Checks if the value of the field is `_0`"]
189    #[inline(always)]
190    pub fn is_0(&self) -> bool {
191        *self == IREFS_A::_0
192    }
193    #[doc = "Checks if the value of the field is `_1`"]
194    #[inline(always)]
195    pub fn is_1(&self) -> bool {
196        *self == IREFS_A::_1
197    }
198}
199#[doc = "Write proxy for field `IREFS`"]
200pub struct IREFS_W<'a> {
201    w: &'a mut W,
202}
203impl<'a> IREFS_W<'a> {
204    #[doc = r"Writes `variant` to the field"]
205    #[inline(always)]
206    pub fn variant(self, variant: IREFS_A) -> &'a mut W {
207        {
208            self.bit(variant.into())
209        }
210    }
211    #[doc = "External reference clock is selected."]
212    #[inline(always)]
213    pub fn _0(self) -> &'a mut W {
214        self.variant(IREFS_A::_0)
215    }
216    #[doc = "Internal reference clock is selected."]
217    #[inline(always)]
218    pub fn _1(self) -> &'a mut W {
219        self.variant(IREFS_A::_1)
220    }
221    #[doc = r"Sets the field bit"]
222    #[inline(always)]
223    pub fn set_bit(self) -> &'a mut W {
224        self.bit(true)
225    }
226    #[doc = r"Clears the field bit"]
227    #[inline(always)]
228    pub fn clear_bit(self) -> &'a mut W {
229        self.bit(false)
230    }
231    #[doc = r"Writes raw bits to the field"]
232    #[inline(always)]
233    pub fn bit(self, value: bool) -> &'a mut W {
234        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u8) & 0x01) << 2);
235        self.w
236    }
237}
238#[doc = "Reader of field `RDIV`"]
239pub type RDIV_R = crate::R<u8, u8>;
240#[doc = "Write proxy for field `RDIV`"]
241pub struct RDIV_W<'a> {
242    w: &'a mut W,
243}
244impl<'a> RDIV_W<'a> {
245    #[doc = r"Writes raw bits to the field"]
246    #[inline(always)]
247    pub unsafe fn bits(self, value: u8) -> &'a mut W {
248        self.w.bits = (self.w.bits & !(0x07 << 3)) | (((value as u8) & 0x07) << 3);
249        self.w
250    }
251}
252#[doc = "Clock Source Select\n\nValue on reset: 0"]
253#[derive(Clone, Copy, Debug, PartialEq)]
254#[repr(u8)]
255pub enum CLKS_A {
256    #[doc = "0: Output of FLL is selected."]
257    _00 = 0,
258    #[doc = "1: Internal reference clock is selected."]
259    _01 = 1,
260    #[doc = "2: External reference clock is selected."]
261    _10 = 2,
262    #[doc = "3: Reserved, defaults to 00."]
263    _11 = 3,
264}
265impl From<CLKS_A> for u8 {
266    #[inline(always)]
267    fn from(variant: CLKS_A) -> Self {
268        variant as _
269    }
270}
271#[doc = "Reader of field `CLKS`"]
272pub type CLKS_R = crate::R<u8, CLKS_A>;
273impl CLKS_R {
274    #[doc = r"Get enumerated values variant"]
275    #[inline(always)]
276    pub fn variant(&self) -> CLKS_A {
277        match self.bits {
278            0 => CLKS_A::_00,
279            1 => CLKS_A::_01,
280            2 => CLKS_A::_10,
281            3 => CLKS_A::_11,
282            _ => unreachable!(),
283        }
284    }
285    #[doc = "Checks if the value of the field is `_00`"]
286    #[inline(always)]
287    pub fn is_00(&self) -> bool {
288        *self == CLKS_A::_00
289    }
290    #[doc = "Checks if the value of the field is `_01`"]
291    #[inline(always)]
292    pub fn is_01(&self) -> bool {
293        *self == CLKS_A::_01
294    }
295    #[doc = "Checks if the value of the field is `_10`"]
296    #[inline(always)]
297    pub fn is_10(&self) -> bool {
298        *self == CLKS_A::_10
299    }
300    #[doc = "Checks if the value of the field is `_11`"]
301    #[inline(always)]
302    pub fn is_11(&self) -> bool {
303        *self == CLKS_A::_11
304    }
305}
306#[doc = "Write proxy for field `CLKS`"]
307pub struct CLKS_W<'a> {
308    w: &'a mut W,
309}
310impl<'a> CLKS_W<'a> {
311    #[doc = r"Writes `variant` to the field"]
312    #[inline(always)]
313    pub fn variant(self, variant: CLKS_A) -> &'a mut W {
314        {
315            self.bits(variant.into())
316        }
317    }
318    #[doc = "Output of FLL is selected."]
319    #[inline(always)]
320    pub fn _00(self) -> &'a mut W {
321        self.variant(CLKS_A::_00)
322    }
323    #[doc = "Internal reference clock is selected."]
324    #[inline(always)]
325    pub fn _01(self) -> &'a mut W {
326        self.variant(CLKS_A::_01)
327    }
328    #[doc = "External reference clock is selected."]
329    #[inline(always)]
330    pub fn _10(self) -> &'a mut W {
331        self.variant(CLKS_A::_10)
332    }
333    #[doc = "Reserved, defaults to 00."]
334    #[inline(always)]
335    pub fn _11(self) -> &'a mut W {
336        self.variant(CLKS_A::_11)
337    }
338    #[doc = r"Writes raw bits to the field"]
339    #[inline(always)]
340    pub fn bits(self, value: u8) -> &'a mut W {
341        self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u8) & 0x03) << 6);
342        self.w
343    }
344}
345impl R {
346    #[doc = "Bit 0 - Internal Reference Stop Enable"]
347    #[inline(always)]
348    pub fn irefsten(&self) -> IREFSTEN_R {
349        IREFSTEN_R::new((self.bits & 0x01) != 0)
350    }
351    #[doc = "Bit 1 - Internal Reference Clock Enable"]
352    #[inline(always)]
353    pub fn irclken(&self) -> IRCLKEN_R {
354        IRCLKEN_R::new(((self.bits >> 1) & 0x01) != 0)
355    }
356    #[doc = "Bit 2 - Internal Reference Select"]
357    #[inline(always)]
358    pub fn irefs(&self) -> IREFS_R {
359        IREFS_R::new(((self.bits >> 2) & 0x01) != 0)
360    }
361    #[doc = "Bits 3:5 - Reference Divider"]
362    #[inline(always)]
363    pub fn rdiv(&self) -> RDIV_R {
364        RDIV_R::new(((self.bits >> 3) & 0x07) as u8)
365    }
366    #[doc = "Bits 6:7 - Clock Source Select"]
367    #[inline(always)]
368    pub fn clks(&self) -> CLKS_R {
369        CLKS_R::new(((self.bits >> 6) & 0x03) as u8)
370    }
371}
372impl W {
373    #[doc = "Bit 0 - Internal Reference Stop Enable"]
374    #[inline(always)]
375    pub fn irefsten(&mut self) -> IREFSTEN_W {
376        IREFSTEN_W { w: self }
377    }
378    #[doc = "Bit 1 - Internal Reference Clock Enable"]
379    #[inline(always)]
380    pub fn irclken(&mut self) -> IRCLKEN_W {
381        IRCLKEN_W { w: self }
382    }
383    #[doc = "Bit 2 - Internal Reference Select"]
384    #[inline(always)]
385    pub fn irefs(&mut self) -> IREFS_W {
386        IREFS_W { w: self }
387    }
388    #[doc = "Bits 3:5 - Reference Divider"]
389    #[inline(always)]
390    pub fn rdiv(&mut self) -> RDIV_W {
391        RDIV_W { w: self }
392    }
393    #[doc = "Bits 6:7 - Clock Source Select"]
394    #[inline(always)]
395    pub fn clks(&mut self) -> CLKS_W {
396        CLKS_W { w: self }
397    }
398}