wip_s32k144/scg/
soscdiv.rs

1#[doc = "Reader of register SOSCDIV"]
2pub type R = crate::R<u32, super::SOSCDIV>;
3#[doc = "Writer for register SOSCDIV"]
4pub type W = crate::W<u32, super::SOSCDIV>;
5#[doc = "Register SOSCDIV `reset()`'s with value 0"]
6impl crate::ResetValue for super::SOSCDIV {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "System OSC Clock Divide 1\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum SOSCDIV1_A {
17    #[doc = "0: Output disabled"]
18    _000 = 0,
19    #[doc = "1: Divide by 1"]
20    _001 = 1,
21    #[doc = "2: Divide by 2"]
22    _010 = 2,
23    #[doc = "3: Divide by 4"]
24    _011 = 3,
25    #[doc = "4: Divide by 8"]
26    _100 = 4,
27    #[doc = "5: Divide by 16"]
28    _101 = 5,
29    #[doc = "6: Divide by 32"]
30    _110 = 6,
31    #[doc = "7: Divide by 64"]
32    _111 = 7,
33}
34impl From<SOSCDIV1_A> for u8 {
35    #[inline(always)]
36    fn from(variant: SOSCDIV1_A) -> Self {
37        variant as _
38    }
39}
40#[doc = "Reader of field `SOSCDIV1`"]
41pub type SOSCDIV1_R = crate::R<u8, SOSCDIV1_A>;
42impl SOSCDIV1_R {
43    #[doc = r"Get enumerated values variant"]
44    #[inline(always)]
45    pub fn variant(&self) -> SOSCDIV1_A {
46        match self.bits {
47            0 => SOSCDIV1_A::_000,
48            1 => SOSCDIV1_A::_001,
49            2 => SOSCDIV1_A::_010,
50            3 => SOSCDIV1_A::_011,
51            4 => SOSCDIV1_A::_100,
52            5 => SOSCDIV1_A::_101,
53            6 => SOSCDIV1_A::_110,
54            7 => SOSCDIV1_A::_111,
55            _ => unreachable!(),
56        }
57    }
58    #[doc = "Checks if the value of the field is `_000`"]
59    #[inline(always)]
60    pub fn is_000(&self) -> bool {
61        *self == SOSCDIV1_A::_000
62    }
63    #[doc = "Checks if the value of the field is `_001`"]
64    #[inline(always)]
65    pub fn is_001(&self) -> bool {
66        *self == SOSCDIV1_A::_001
67    }
68    #[doc = "Checks if the value of the field is `_010`"]
69    #[inline(always)]
70    pub fn is_010(&self) -> bool {
71        *self == SOSCDIV1_A::_010
72    }
73    #[doc = "Checks if the value of the field is `_011`"]
74    #[inline(always)]
75    pub fn is_011(&self) -> bool {
76        *self == SOSCDIV1_A::_011
77    }
78    #[doc = "Checks if the value of the field is `_100`"]
79    #[inline(always)]
80    pub fn is_100(&self) -> bool {
81        *self == SOSCDIV1_A::_100
82    }
83    #[doc = "Checks if the value of the field is `_101`"]
84    #[inline(always)]
85    pub fn is_101(&self) -> bool {
86        *self == SOSCDIV1_A::_101
87    }
88    #[doc = "Checks if the value of the field is `_110`"]
89    #[inline(always)]
90    pub fn is_110(&self) -> bool {
91        *self == SOSCDIV1_A::_110
92    }
93    #[doc = "Checks if the value of the field is `_111`"]
94    #[inline(always)]
95    pub fn is_111(&self) -> bool {
96        *self == SOSCDIV1_A::_111
97    }
98}
99#[doc = "Write proxy for field `SOSCDIV1`"]
100pub struct SOSCDIV1_W<'a> {
101    w: &'a mut W,
102}
103impl<'a> SOSCDIV1_W<'a> {
104    #[doc = r"Writes `variant` to the field"]
105    #[inline(always)]
106    pub fn variant(self, variant: SOSCDIV1_A) -> &'a mut W {
107        {
108            self.bits(variant.into())
109        }
110    }
111    #[doc = "Output disabled"]
112    #[inline(always)]
113    pub fn _000(self) -> &'a mut W {
114        self.variant(SOSCDIV1_A::_000)
115    }
116    #[doc = "Divide by 1"]
117    #[inline(always)]
118    pub fn _001(self) -> &'a mut W {
119        self.variant(SOSCDIV1_A::_001)
120    }
121    #[doc = "Divide by 2"]
122    #[inline(always)]
123    pub fn _010(self) -> &'a mut W {
124        self.variant(SOSCDIV1_A::_010)
125    }
126    #[doc = "Divide by 4"]
127    #[inline(always)]
128    pub fn _011(self) -> &'a mut W {
129        self.variant(SOSCDIV1_A::_011)
130    }
131    #[doc = "Divide by 8"]
132    #[inline(always)]
133    pub fn _100(self) -> &'a mut W {
134        self.variant(SOSCDIV1_A::_100)
135    }
136    #[doc = "Divide by 16"]
137    #[inline(always)]
138    pub fn _101(self) -> &'a mut W {
139        self.variant(SOSCDIV1_A::_101)
140    }
141    #[doc = "Divide by 32"]
142    #[inline(always)]
143    pub fn _110(self) -> &'a mut W {
144        self.variant(SOSCDIV1_A::_110)
145    }
146    #[doc = "Divide by 64"]
147    #[inline(always)]
148    pub fn _111(self) -> &'a mut W {
149        self.variant(SOSCDIV1_A::_111)
150    }
151    #[doc = r"Writes raw bits to the field"]
152    #[inline(always)]
153    pub fn bits(self, value: u8) -> &'a mut W {
154        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
155        self.w
156    }
157}
158#[doc = "System OSC Clock Divide 2\n\nValue on reset: 0"]
159#[derive(Clone, Copy, Debug, PartialEq)]
160#[repr(u8)]
161pub enum SOSCDIV2_A {
162    #[doc = "0: Output disabled"]
163    _000 = 0,
164    #[doc = "1: Divide by 1"]
165    _001 = 1,
166    #[doc = "2: Divide by 2"]
167    _010 = 2,
168    #[doc = "3: Divide by 4"]
169    _011 = 3,
170    #[doc = "4: Divide by 8"]
171    _100 = 4,
172    #[doc = "5: Divide by 16"]
173    _101 = 5,
174    #[doc = "6: Divide by 32"]
175    _110 = 6,
176    #[doc = "7: Divide by 64"]
177    _111 = 7,
178}
179impl From<SOSCDIV2_A> for u8 {
180    #[inline(always)]
181    fn from(variant: SOSCDIV2_A) -> Self {
182        variant as _
183    }
184}
185#[doc = "Reader of field `SOSCDIV2`"]
186pub type SOSCDIV2_R = crate::R<u8, SOSCDIV2_A>;
187impl SOSCDIV2_R {
188    #[doc = r"Get enumerated values variant"]
189    #[inline(always)]
190    pub fn variant(&self) -> SOSCDIV2_A {
191        match self.bits {
192            0 => SOSCDIV2_A::_000,
193            1 => SOSCDIV2_A::_001,
194            2 => SOSCDIV2_A::_010,
195            3 => SOSCDIV2_A::_011,
196            4 => SOSCDIV2_A::_100,
197            5 => SOSCDIV2_A::_101,
198            6 => SOSCDIV2_A::_110,
199            7 => SOSCDIV2_A::_111,
200            _ => unreachable!(),
201        }
202    }
203    #[doc = "Checks if the value of the field is `_000`"]
204    #[inline(always)]
205    pub fn is_000(&self) -> bool {
206        *self == SOSCDIV2_A::_000
207    }
208    #[doc = "Checks if the value of the field is `_001`"]
209    #[inline(always)]
210    pub fn is_001(&self) -> bool {
211        *self == SOSCDIV2_A::_001
212    }
213    #[doc = "Checks if the value of the field is `_010`"]
214    #[inline(always)]
215    pub fn is_010(&self) -> bool {
216        *self == SOSCDIV2_A::_010
217    }
218    #[doc = "Checks if the value of the field is `_011`"]
219    #[inline(always)]
220    pub fn is_011(&self) -> bool {
221        *self == SOSCDIV2_A::_011
222    }
223    #[doc = "Checks if the value of the field is `_100`"]
224    #[inline(always)]
225    pub fn is_100(&self) -> bool {
226        *self == SOSCDIV2_A::_100
227    }
228    #[doc = "Checks if the value of the field is `_101`"]
229    #[inline(always)]
230    pub fn is_101(&self) -> bool {
231        *self == SOSCDIV2_A::_101
232    }
233    #[doc = "Checks if the value of the field is `_110`"]
234    #[inline(always)]
235    pub fn is_110(&self) -> bool {
236        *self == SOSCDIV2_A::_110
237    }
238    #[doc = "Checks if the value of the field is `_111`"]
239    #[inline(always)]
240    pub fn is_111(&self) -> bool {
241        *self == SOSCDIV2_A::_111
242    }
243}
244#[doc = "Write proxy for field `SOSCDIV2`"]
245pub struct SOSCDIV2_W<'a> {
246    w: &'a mut W,
247}
248impl<'a> SOSCDIV2_W<'a> {
249    #[doc = r"Writes `variant` to the field"]
250    #[inline(always)]
251    pub fn variant(self, variant: SOSCDIV2_A) -> &'a mut W {
252        {
253            self.bits(variant.into())
254        }
255    }
256    #[doc = "Output disabled"]
257    #[inline(always)]
258    pub fn _000(self) -> &'a mut W {
259        self.variant(SOSCDIV2_A::_000)
260    }
261    #[doc = "Divide by 1"]
262    #[inline(always)]
263    pub fn _001(self) -> &'a mut W {
264        self.variant(SOSCDIV2_A::_001)
265    }
266    #[doc = "Divide by 2"]
267    #[inline(always)]
268    pub fn _010(self) -> &'a mut W {
269        self.variant(SOSCDIV2_A::_010)
270    }
271    #[doc = "Divide by 4"]
272    #[inline(always)]
273    pub fn _011(self) -> &'a mut W {
274        self.variant(SOSCDIV2_A::_011)
275    }
276    #[doc = "Divide by 8"]
277    #[inline(always)]
278    pub fn _100(self) -> &'a mut W {
279        self.variant(SOSCDIV2_A::_100)
280    }
281    #[doc = "Divide by 16"]
282    #[inline(always)]
283    pub fn _101(self) -> &'a mut W {
284        self.variant(SOSCDIV2_A::_101)
285    }
286    #[doc = "Divide by 32"]
287    #[inline(always)]
288    pub fn _110(self) -> &'a mut W {
289        self.variant(SOSCDIV2_A::_110)
290    }
291    #[doc = "Divide by 64"]
292    #[inline(always)]
293    pub fn _111(self) -> &'a mut W {
294        self.variant(SOSCDIV2_A::_111)
295    }
296    #[doc = r"Writes raw bits to the field"]
297    #[inline(always)]
298    pub fn bits(self, value: u8) -> &'a mut W {
299        self.w.bits = (self.w.bits & !(0x07 << 8)) | (((value as u32) & 0x07) << 8);
300        self.w
301    }
302}
303impl R {
304    #[doc = "Bits 0:2 - System OSC Clock Divide 1"]
305    #[inline(always)]
306    pub fn soscdiv1(&self) -> SOSCDIV1_R {
307        SOSCDIV1_R::new((self.bits & 0x07) as u8)
308    }
309    #[doc = "Bits 8:10 - System OSC Clock Divide 2"]
310    #[inline(always)]
311    pub fn soscdiv2(&self) -> SOSCDIV2_R {
312        SOSCDIV2_R::new(((self.bits >> 8) & 0x07) as u8)
313    }
314}
315impl W {
316    #[doc = "Bits 0:2 - System OSC Clock Divide 1"]
317    #[inline(always)]
318    pub fn soscdiv1(&mut self) -> SOSCDIV1_W {
319        SOSCDIV1_W { w: self }
320    }
321    #[doc = "Bits 8:10 - System OSC Clock Divide 2"]
322    #[inline(always)]
323    pub fn soscdiv2(&mut self) -> SOSCDIV2_W {
324        SOSCDIV2_W { w: self }
325    }
326}