s32k116_pac/scg/
soscdiv.rs1#[doc = "Register `SOSCDIV` reader"]
2pub struct R(crate::R<SOSCDIV_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SOSCDIV_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SOSCDIV_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SOSCDIV_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SOSCDIV` writer"]
17pub struct W(crate::W<SOSCDIV_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SOSCDIV_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<SOSCDIV_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SOSCDIV_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "System OSC Clock Divide 1\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum SOSCDIV1_A {
41 #[doc = "0: Output disabled"]
42 _000 = 0,
43 #[doc = "1: Divide by 1"]
44 _001 = 1,
45 #[doc = "2: Divide by 2"]
46 _010 = 2,
47 #[doc = "3: Divide by 4"]
48 _011 = 3,
49 #[doc = "4: Divide by 8"]
50 _100 = 4,
51 #[doc = "5: Divide by 16"]
52 _101 = 5,
53 #[doc = "6: Divide by 32"]
54 _110 = 6,
55 #[doc = "7: Divide by 64"]
56 _111 = 7,
57}
58impl From<SOSCDIV1_A> for u8 {
59 #[inline(always)]
60 fn from(variant: SOSCDIV1_A) -> Self {
61 variant as _
62 }
63}
64#[doc = "Field `SOSCDIV1` reader - System OSC Clock Divide 1"]
65pub struct SOSCDIV1_R(crate::FieldReader<u8, SOSCDIV1_A>);
66impl SOSCDIV1_R {
67 #[inline(always)]
68 pub(crate) fn new(bits: u8) -> Self {
69 SOSCDIV1_R(crate::FieldReader::new(bits))
70 }
71 #[doc = r"Get enumerated values variant"]
72 #[inline(always)]
73 pub fn variant(&self) -> SOSCDIV1_A {
74 match self.bits {
75 0 => SOSCDIV1_A::_000,
76 1 => SOSCDIV1_A::_001,
77 2 => SOSCDIV1_A::_010,
78 3 => SOSCDIV1_A::_011,
79 4 => SOSCDIV1_A::_100,
80 5 => SOSCDIV1_A::_101,
81 6 => SOSCDIV1_A::_110,
82 7 => SOSCDIV1_A::_111,
83 _ => unreachable!(),
84 }
85 }
86 #[doc = "Checks if the value of the field is `_000`"]
87 #[inline(always)]
88 pub fn is_000(&self) -> bool {
89 **self == SOSCDIV1_A::_000
90 }
91 #[doc = "Checks if the value of the field is `_001`"]
92 #[inline(always)]
93 pub fn is_001(&self) -> bool {
94 **self == SOSCDIV1_A::_001
95 }
96 #[doc = "Checks if the value of the field is `_010`"]
97 #[inline(always)]
98 pub fn is_010(&self) -> bool {
99 **self == SOSCDIV1_A::_010
100 }
101 #[doc = "Checks if the value of the field is `_011`"]
102 #[inline(always)]
103 pub fn is_011(&self) -> bool {
104 **self == SOSCDIV1_A::_011
105 }
106 #[doc = "Checks if the value of the field is `_100`"]
107 #[inline(always)]
108 pub fn is_100(&self) -> bool {
109 **self == SOSCDIV1_A::_100
110 }
111 #[doc = "Checks if the value of the field is `_101`"]
112 #[inline(always)]
113 pub fn is_101(&self) -> bool {
114 **self == SOSCDIV1_A::_101
115 }
116 #[doc = "Checks if the value of the field is `_110`"]
117 #[inline(always)]
118 pub fn is_110(&self) -> bool {
119 **self == SOSCDIV1_A::_110
120 }
121 #[doc = "Checks if the value of the field is `_111`"]
122 #[inline(always)]
123 pub fn is_111(&self) -> bool {
124 **self == SOSCDIV1_A::_111
125 }
126}
127impl core::ops::Deref for SOSCDIV1_R {
128 type Target = crate::FieldReader<u8, SOSCDIV1_A>;
129 #[inline(always)]
130 fn deref(&self) -> &Self::Target {
131 &self.0
132 }
133}
134#[doc = "Field `SOSCDIV1` writer - System OSC Clock Divide 1"]
135pub struct SOSCDIV1_W<'a> {
136 w: &'a mut W,
137}
138impl<'a> SOSCDIV1_W<'a> {
139 #[doc = r"Writes `variant` to the field"]
140 #[inline(always)]
141 pub fn variant(self, variant: SOSCDIV1_A) -> &'a mut W {
142 self.bits(variant.into())
143 }
144 #[doc = "Output disabled"]
145 #[inline(always)]
146 pub fn _000(self) -> &'a mut W {
147 self.variant(SOSCDIV1_A::_000)
148 }
149 #[doc = "Divide by 1"]
150 #[inline(always)]
151 pub fn _001(self) -> &'a mut W {
152 self.variant(SOSCDIV1_A::_001)
153 }
154 #[doc = "Divide by 2"]
155 #[inline(always)]
156 pub fn _010(self) -> &'a mut W {
157 self.variant(SOSCDIV1_A::_010)
158 }
159 #[doc = "Divide by 4"]
160 #[inline(always)]
161 pub fn _011(self) -> &'a mut W {
162 self.variant(SOSCDIV1_A::_011)
163 }
164 #[doc = "Divide by 8"]
165 #[inline(always)]
166 pub fn _100(self) -> &'a mut W {
167 self.variant(SOSCDIV1_A::_100)
168 }
169 #[doc = "Divide by 16"]
170 #[inline(always)]
171 pub fn _101(self) -> &'a mut W {
172 self.variant(SOSCDIV1_A::_101)
173 }
174 #[doc = "Divide by 32"]
175 #[inline(always)]
176 pub fn _110(self) -> &'a mut W {
177 self.variant(SOSCDIV1_A::_110)
178 }
179 #[doc = "Divide by 64"]
180 #[inline(always)]
181 pub fn _111(self) -> &'a mut W {
182 self.variant(SOSCDIV1_A::_111)
183 }
184 #[doc = r"Writes raw bits to the field"]
185 #[inline(always)]
186 pub fn bits(self, value: u8) -> &'a mut W {
187 self.w.bits = (self.w.bits & !0x07) | (value as u32 & 0x07);
188 self.w
189 }
190}
191#[doc = "System OSC Clock Divide 2\n\nValue on reset: 0"]
192#[derive(Clone, Copy, Debug, PartialEq)]
193#[repr(u8)]
194pub enum SOSCDIV2_A {
195 #[doc = "0: Output disabled"]
196 _000 = 0,
197 #[doc = "1: Divide by 1"]
198 _001 = 1,
199 #[doc = "2: Divide by 2"]
200 _010 = 2,
201 #[doc = "3: Divide by 4"]
202 _011 = 3,
203 #[doc = "4: Divide by 8"]
204 _100 = 4,
205 #[doc = "5: Divide by 16"]
206 _101 = 5,
207 #[doc = "6: Divide by 32"]
208 _110 = 6,
209 #[doc = "7: Divide by 64"]
210 _111 = 7,
211}
212impl From<SOSCDIV2_A> for u8 {
213 #[inline(always)]
214 fn from(variant: SOSCDIV2_A) -> Self {
215 variant as _
216 }
217}
218#[doc = "Field `SOSCDIV2` reader - System OSC Clock Divide 2"]
219pub struct SOSCDIV2_R(crate::FieldReader<u8, SOSCDIV2_A>);
220impl SOSCDIV2_R {
221 #[inline(always)]
222 pub(crate) fn new(bits: u8) -> Self {
223 SOSCDIV2_R(crate::FieldReader::new(bits))
224 }
225 #[doc = r"Get enumerated values variant"]
226 #[inline(always)]
227 pub fn variant(&self) -> SOSCDIV2_A {
228 match self.bits {
229 0 => SOSCDIV2_A::_000,
230 1 => SOSCDIV2_A::_001,
231 2 => SOSCDIV2_A::_010,
232 3 => SOSCDIV2_A::_011,
233 4 => SOSCDIV2_A::_100,
234 5 => SOSCDIV2_A::_101,
235 6 => SOSCDIV2_A::_110,
236 7 => SOSCDIV2_A::_111,
237 _ => unreachable!(),
238 }
239 }
240 #[doc = "Checks if the value of the field is `_000`"]
241 #[inline(always)]
242 pub fn is_000(&self) -> bool {
243 **self == SOSCDIV2_A::_000
244 }
245 #[doc = "Checks if the value of the field is `_001`"]
246 #[inline(always)]
247 pub fn is_001(&self) -> bool {
248 **self == SOSCDIV2_A::_001
249 }
250 #[doc = "Checks if the value of the field is `_010`"]
251 #[inline(always)]
252 pub fn is_010(&self) -> bool {
253 **self == SOSCDIV2_A::_010
254 }
255 #[doc = "Checks if the value of the field is `_011`"]
256 #[inline(always)]
257 pub fn is_011(&self) -> bool {
258 **self == SOSCDIV2_A::_011
259 }
260 #[doc = "Checks if the value of the field is `_100`"]
261 #[inline(always)]
262 pub fn is_100(&self) -> bool {
263 **self == SOSCDIV2_A::_100
264 }
265 #[doc = "Checks if the value of the field is `_101`"]
266 #[inline(always)]
267 pub fn is_101(&self) -> bool {
268 **self == SOSCDIV2_A::_101
269 }
270 #[doc = "Checks if the value of the field is `_110`"]
271 #[inline(always)]
272 pub fn is_110(&self) -> bool {
273 **self == SOSCDIV2_A::_110
274 }
275 #[doc = "Checks if the value of the field is `_111`"]
276 #[inline(always)]
277 pub fn is_111(&self) -> bool {
278 **self == SOSCDIV2_A::_111
279 }
280}
281impl core::ops::Deref for SOSCDIV2_R {
282 type Target = crate::FieldReader<u8, SOSCDIV2_A>;
283 #[inline(always)]
284 fn deref(&self) -> &Self::Target {
285 &self.0
286 }
287}
288#[doc = "Field `SOSCDIV2` writer - System OSC Clock Divide 2"]
289pub struct SOSCDIV2_W<'a> {
290 w: &'a mut W,
291}
292impl<'a> SOSCDIV2_W<'a> {
293 #[doc = r"Writes `variant` to the field"]
294 #[inline(always)]
295 pub fn variant(self, variant: SOSCDIV2_A) -> &'a mut W {
296 self.bits(variant.into())
297 }
298 #[doc = "Output disabled"]
299 #[inline(always)]
300 pub fn _000(self) -> &'a mut W {
301 self.variant(SOSCDIV2_A::_000)
302 }
303 #[doc = "Divide by 1"]
304 #[inline(always)]
305 pub fn _001(self) -> &'a mut W {
306 self.variant(SOSCDIV2_A::_001)
307 }
308 #[doc = "Divide by 2"]
309 #[inline(always)]
310 pub fn _010(self) -> &'a mut W {
311 self.variant(SOSCDIV2_A::_010)
312 }
313 #[doc = "Divide by 4"]
314 #[inline(always)]
315 pub fn _011(self) -> &'a mut W {
316 self.variant(SOSCDIV2_A::_011)
317 }
318 #[doc = "Divide by 8"]
319 #[inline(always)]
320 pub fn _100(self) -> &'a mut W {
321 self.variant(SOSCDIV2_A::_100)
322 }
323 #[doc = "Divide by 16"]
324 #[inline(always)]
325 pub fn _101(self) -> &'a mut W {
326 self.variant(SOSCDIV2_A::_101)
327 }
328 #[doc = "Divide by 32"]
329 #[inline(always)]
330 pub fn _110(self) -> &'a mut W {
331 self.variant(SOSCDIV2_A::_110)
332 }
333 #[doc = "Divide by 64"]
334 #[inline(always)]
335 pub fn _111(self) -> &'a mut W {
336 self.variant(SOSCDIV2_A::_111)
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 & !(0x07 << 8)) | ((value as u32 & 0x07) << 8);
342 self.w
343 }
344}
345impl R {
346 #[doc = "Bits 0:2 - System OSC Clock Divide 1"]
347 #[inline(always)]
348 pub fn soscdiv1(&self) -> SOSCDIV1_R {
349 SOSCDIV1_R::new((self.bits & 0x07) as u8)
350 }
351 #[doc = "Bits 8:10 - System OSC Clock Divide 2"]
352 #[inline(always)]
353 pub fn soscdiv2(&self) -> SOSCDIV2_R {
354 SOSCDIV2_R::new(((self.bits >> 8) & 0x07) as u8)
355 }
356}
357impl W {
358 #[doc = "Bits 0:2 - System OSC Clock Divide 1"]
359 #[inline(always)]
360 pub fn soscdiv1(&mut self) -> SOSCDIV1_W {
361 SOSCDIV1_W { w: self }
362 }
363 #[doc = "Bits 8:10 - System OSC Clock Divide 2"]
364 #[inline(always)]
365 pub fn soscdiv2(&mut self) -> SOSCDIV2_W {
366 SOSCDIV2_W { w: self }
367 }
368 #[doc = "Writes raw bits to the register."]
369 #[inline(always)]
370 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
371 self.0.bits(bits);
372 self
373 }
374}
375#[doc = "System OSC Divide Register\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 [soscdiv](index.html) module"]
376pub struct SOSCDIV_SPEC;
377impl crate::RegisterSpec for SOSCDIV_SPEC {
378 type Ux = u32;
379}
380#[doc = "`read()` method returns [soscdiv::R](R) reader structure"]
381impl crate::Readable for SOSCDIV_SPEC {
382 type Reader = R;
383}
384#[doc = "`write(|w| ..)` method takes [soscdiv::W](W) writer structure"]
385impl crate::Writable for SOSCDIV_SPEC {
386 type Writer = W;
387}
388#[doc = "`reset()` method sets SOSCDIV to value 0"]
389impl crate::Resettable for SOSCDIV_SPEC {
390 #[inline(always)]
391 fn reset_value() -> Self::Ux {
392 0
393 }
394}