efm32pg12_pac/wtimer0/
dtctrl.rs

1#[doc = "Reader of register DTCTRL"]
2pub type R = crate::R<u32, super::DTCTRL>;
3#[doc = "Writer for register DTCTRL"]
4pub type W = crate::W<u32, super::DTCTRL>;
5#[doc = "Register DTCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::DTCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `DTEN`"]
14pub type DTEN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `DTEN`"]
16pub struct DTEN_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> DTEN_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `DTDAS`"]
38pub type DTDAS_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `DTDAS`"]
40pub struct DTDAS_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> DTDAS_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
58        self.w
59    }
60}
61#[doc = "Reader of field `DTIPOL`"]
62pub type DTIPOL_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `DTIPOL`"]
64pub struct DTIPOL_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> DTIPOL_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
82        self.w
83    }
84}
85#[doc = "Reader of field `DTCINV`"]
86pub type DTCINV_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `DTCINV`"]
88pub struct DTCINV_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> DTCINV_W<'a> {
92    #[doc = r"Sets the field bit"]
93    #[inline(always)]
94    pub fn set_bit(self) -> &'a mut W {
95        self.bit(true)
96    }
97    #[doc = r"Clears the field bit"]
98    #[inline(always)]
99    pub fn clear_bit(self) -> &'a mut W {
100        self.bit(false)
101    }
102    #[doc = r"Writes raw bits to the field"]
103    #[inline(always)]
104    pub fn bit(self, value: bool) -> &'a mut W {
105        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
106        self.w
107    }
108}
109#[doc = "DTI PRS Source Channel Select\n\nValue on reset: 0"]
110#[derive(Clone, Copy, Debug, PartialEq)]
111#[repr(u8)]
112pub enum DTPRSSEL_A {
113    #[doc = "0: PRS Channel 0 selected as input"]
114    PRSCH0 = 0,
115    #[doc = "1: PRS Channel 1 selected as input"]
116    PRSCH1 = 1,
117    #[doc = "2: PRS Channel 2 selected as input"]
118    PRSCH2 = 2,
119    #[doc = "3: PRS Channel 3 selected as input"]
120    PRSCH3 = 3,
121    #[doc = "4: PRS Channel 4 selected as input"]
122    PRSCH4 = 4,
123    #[doc = "5: PRS Channel 5 selected as input"]
124    PRSCH5 = 5,
125    #[doc = "6: PRS Channel 6 selected as input"]
126    PRSCH6 = 6,
127    #[doc = "7: PRS Channel 7 selected as input"]
128    PRSCH7 = 7,
129    #[doc = "8: PRS Channel 8 selected as input"]
130    PRSCH8 = 8,
131    #[doc = "9: PRS Channel 9 selected as input"]
132    PRSCH9 = 9,
133    #[doc = "10: PRS Channel 10 selected as input"]
134    PRSCH10 = 10,
135    #[doc = "11: PRS Channel 11 selected as input"]
136    PRSCH11 = 11,
137}
138impl From<DTPRSSEL_A> for u8 {
139    #[inline(always)]
140    fn from(variant: DTPRSSEL_A) -> Self {
141        variant as _
142    }
143}
144#[doc = "Reader of field `DTPRSSEL`"]
145pub type DTPRSSEL_R = crate::R<u8, DTPRSSEL_A>;
146impl DTPRSSEL_R {
147    #[doc = r"Get enumerated values variant"]
148    #[inline(always)]
149    pub fn variant(&self) -> crate::Variant<u8, DTPRSSEL_A> {
150        use crate::Variant::*;
151        match self.bits {
152            0 => Val(DTPRSSEL_A::PRSCH0),
153            1 => Val(DTPRSSEL_A::PRSCH1),
154            2 => Val(DTPRSSEL_A::PRSCH2),
155            3 => Val(DTPRSSEL_A::PRSCH3),
156            4 => Val(DTPRSSEL_A::PRSCH4),
157            5 => Val(DTPRSSEL_A::PRSCH5),
158            6 => Val(DTPRSSEL_A::PRSCH6),
159            7 => Val(DTPRSSEL_A::PRSCH7),
160            8 => Val(DTPRSSEL_A::PRSCH8),
161            9 => Val(DTPRSSEL_A::PRSCH9),
162            10 => Val(DTPRSSEL_A::PRSCH10),
163            11 => Val(DTPRSSEL_A::PRSCH11),
164            i => Res(i),
165        }
166    }
167    #[doc = "Checks if the value of the field is `PRSCH0`"]
168    #[inline(always)]
169    pub fn is_prsch0(&self) -> bool {
170        *self == DTPRSSEL_A::PRSCH0
171    }
172    #[doc = "Checks if the value of the field is `PRSCH1`"]
173    #[inline(always)]
174    pub fn is_prsch1(&self) -> bool {
175        *self == DTPRSSEL_A::PRSCH1
176    }
177    #[doc = "Checks if the value of the field is `PRSCH2`"]
178    #[inline(always)]
179    pub fn is_prsch2(&self) -> bool {
180        *self == DTPRSSEL_A::PRSCH2
181    }
182    #[doc = "Checks if the value of the field is `PRSCH3`"]
183    #[inline(always)]
184    pub fn is_prsch3(&self) -> bool {
185        *self == DTPRSSEL_A::PRSCH3
186    }
187    #[doc = "Checks if the value of the field is `PRSCH4`"]
188    #[inline(always)]
189    pub fn is_prsch4(&self) -> bool {
190        *self == DTPRSSEL_A::PRSCH4
191    }
192    #[doc = "Checks if the value of the field is `PRSCH5`"]
193    #[inline(always)]
194    pub fn is_prsch5(&self) -> bool {
195        *self == DTPRSSEL_A::PRSCH5
196    }
197    #[doc = "Checks if the value of the field is `PRSCH6`"]
198    #[inline(always)]
199    pub fn is_prsch6(&self) -> bool {
200        *self == DTPRSSEL_A::PRSCH6
201    }
202    #[doc = "Checks if the value of the field is `PRSCH7`"]
203    #[inline(always)]
204    pub fn is_prsch7(&self) -> bool {
205        *self == DTPRSSEL_A::PRSCH7
206    }
207    #[doc = "Checks if the value of the field is `PRSCH8`"]
208    #[inline(always)]
209    pub fn is_prsch8(&self) -> bool {
210        *self == DTPRSSEL_A::PRSCH8
211    }
212    #[doc = "Checks if the value of the field is `PRSCH9`"]
213    #[inline(always)]
214    pub fn is_prsch9(&self) -> bool {
215        *self == DTPRSSEL_A::PRSCH9
216    }
217    #[doc = "Checks if the value of the field is `PRSCH10`"]
218    #[inline(always)]
219    pub fn is_prsch10(&self) -> bool {
220        *self == DTPRSSEL_A::PRSCH10
221    }
222    #[doc = "Checks if the value of the field is `PRSCH11`"]
223    #[inline(always)]
224    pub fn is_prsch11(&self) -> bool {
225        *self == DTPRSSEL_A::PRSCH11
226    }
227}
228#[doc = "Write proxy for field `DTPRSSEL`"]
229pub struct DTPRSSEL_W<'a> {
230    w: &'a mut W,
231}
232impl<'a> DTPRSSEL_W<'a> {
233    #[doc = r"Writes `variant` to the field"]
234    #[inline(always)]
235    pub fn variant(self, variant: DTPRSSEL_A) -> &'a mut W {
236        unsafe { self.bits(variant.into()) }
237    }
238    #[doc = "PRS Channel 0 selected as input"]
239    #[inline(always)]
240    pub fn prsch0(self) -> &'a mut W {
241        self.variant(DTPRSSEL_A::PRSCH0)
242    }
243    #[doc = "PRS Channel 1 selected as input"]
244    #[inline(always)]
245    pub fn prsch1(self) -> &'a mut W {
246        self.variant(DTPRSSEL_A::PRSCH1)
247    }
248    #[doc = "PRS Channel 2 selected as input"]
249    #[inline(always)]
250    pub fn prsch2(self) -> &'a mut W {
251        self.variant(DTPRSSEL_A::PRSCH2)
252    }
253    #[doc = "PRS Channel 3 selected as input"]
254    #[inline(always)]
255    pub fn prsch3(self) -> &'a mut W {
256        self.variant(DTPRSSEL_A::PRSCH3)
257    }
258    #[doc = "PRS Channel 4 selected as input"]
259    #[inline(always)]
260    pub fn prsch4(self) -> &'a mut W {
261        self.variant(DTPRSSEL_A::PRSCH4)
262    }
263    #[doc = "PRS Channel 5 selected as input"]
264    #[inline(always)]
265    pub fn prsch5(self) -> &'a mut W {
266        self.variant(DTPRSSEL_A::PRSCH5)
267    }
268    #[doc = "PRS Channel 6 selected as input"]
269    #[inline(always)]
270    pub fn prsch6(self) -> &'a mut W {
271        self.variant(DTPRSSEL_A::PRSCH6)
272    }
273    #[doc = "PRS Channel 7 selected as input"]
274    #[inline(always)]
275    pub fn prsch7(self) -> &'a mut W {
276        self.variant(DTPRSSEL_A::PRSCH7)
277    }
278    #[doc = "PRS Channel 8 selected as input"]
279    #[inline(always)]
280    pub fn prsch8(self) -> &'a mut W {
281        self.variant(DTPRSSEL_A::PRSCH8)
282    }
283    #[doc = "PRS Channel 9 selected as input"]
284    #[inline(always)]
285    pub fn prsch9(self) -> &'a mut W {
286        self.variant(DTPRSSEL_A::PRSCH9)
287    }
288    #[doc = "PRS Channel 10 selected as input"]
289    #[inline(always)]
290    pub fn prsch10(self) -> &'a mut W {
291        self.variant(DTPRSSEL_A::PRSCH10)
292    }
293    #[doc = "PRS Channel 11 selected as input"]
294    #[inline(always)]
295    pub fn prsch11(self) -> &'a mut W {
296        self.variant(DTPRSSEL_A::PRSCH11)
297    }
298    #[doc = r"Writes raw bits to the field"]
299    #[inline(always)]
300    pub unsafe fn bits(self, value: u8) -> &'a mut W {
301        self.w.bits = (self.w.bits & !(0x0f << 4)) | (((value as u32) & 0x0f) << 4);
302        self.w
303    }
304}
305#[doc = "Reader of field `DTAR`"]
306pub type DTAR_R = crate::R<bool, bool>;
307#[doc = "Write proxy for field `DTAR`"]
308pub struct DTAR_W<'a> {
309    w: &'a mut W,
310}
311impl<'a> DTAR_W<'a> {
312    #[doc = r"Sets the field bit"]
313    #[inline(always)]
314    pub fn set_bit(self) -> &'a mut W {
315        self.bit(true)
316    }
317    #[doc = r"Clears the field bit"]
318    #[inline(always)]
319    pub fn clear_bit(self) -> &'a mut W {
320        self.bit(false)
321    }
322    #[doc = r"Writes raw bits to the field"]
323    #[inline(always)]
324    pub fn bit(self, value: bool) -> &'a mut W {
325        self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
326        self.w
327    }
328}
329#[doc = "Reader of field `DTFATS`"]
330pub type DTFATS_R = crate::R<bool, bool>;
331#[doc = "Write proxy for field `DTFATS`"]
332pub struct DTFATS_W<'a> {
333    w: &'a mut W,
334}
335impl<'a> DTFATS_W<'a> {
336    #[doc = r"Sets the field bit"]
337    #[inline(always)]
338    pub fn set_bit(self) -> &'a mut W {
339        self.bit(true)
340    }
341    #[doc = r"Clears the field bit"]
342    #[inline(always)]
343    pub fn clear_bit(self) -> &'a mut W {
344        self.bit(false)
345    }
346    #[doc = r"Writes raw bits to the field"]
347    #[inline(always)]
348    pub fn bit(self, value: bool) -> &'a mut W {
349        self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
350        self.w
351    }
352}
353#[doc = "Reader of field `DTPRSEN`"]
354pub type DTPRSEN_R = crate::R<bool, bool>;
355#[doc = "Write proxy for field `DTPRSEN`"]
356pub struct DTPRSEN_W<'a> {
357    w: &'a mut W,
358}
359impl<'a> DTPRSEN_W<'a> {
360    #[doc = r"Sets the field bit"]
361    #[inline(always)]
362    pub fn set_bit(self) -> &'a mut W {
363        self.bit(true)
364    }
365    #[doc = r"Clears the field bit"]
366    #[inline(always)]
367    pub fn clear_bit(self) -> &'a mut W {
368        self.bit(false)
369    }
370    #[doc = r"Writes raw bits to the field"]
371    #[inline(always)]
372    pub fn bit(self, value: bool) -> &'a mut W {
373        self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
374        self.w
375    }
376}
377impl R {
378    #[doc = "Bit 0 - DTI Enable"]
379    #[inline(always)]
380    pub fn dten(&self) -> DTEN_R {
381        DTEN_R::new((self.bits & 0x01) != 0)
382    }
383    #[doc = "Bit 1 - DTI Automatic Start-up Functionality"]
384    #[inline(always)]
385    pub fn dtdas(&self) -> DTDAS_R {
386        DTDAS_R::new(((self.bits >> 1) & 0x01) != 0)
387    }
388    #[doc = "Bit 2 - DTI Inactive Polarity"]
389    #[inline(always)]
390    pub fn dtipol(&self) -> DTIPOL_R {
391        DTIPOL_R::new(((self.bits >> 2) & 0x01) != 0)
392    }
393    #[doc = "Bit 3 - DTI Complementary Output Invert"]
394    #[inline(always)]
395    pub fn dtcinv(&self) -> DTCINV_R {
396        DTCINV_R::new(((self.bits >> 3) & 0x01) != 0)
397    }
398    #[doc = "Bits 4:7 - DTI PRS Source Channel Select"]
399    #[inline(always)]
400    pub fn dtprssel(&self) -> DTPRSSEL_R {
401        DTPRSSEL_R::new(((self.bits >> 4) & 0x0f) as u8)
402    }
403    #[doc = "Bit 9 - DTI Always Run"]
404    #[inline(always)]
405    pub fn dtar(&self) -> DTAR_R {
406        DTAR_R::new(((self.bits >> 9) & 0x01) != 0)
407    }
408    #[doc = "Bit 10 - DTI Fault Action on Timer Stop"]
409    #[inline(always)]
410    pub fn dtfats(&self) -> DTFATS_R {
411        DTFATS_R::new(((self.bits >> 10) & 0x01) != 0)
412    }
413    #[doc = "Bit 24 - DTI PRS Source Enable"]
414    #[inline(always)]
415    pub fn dtprsen(&self) -> DTPRSEN_R {
416        DTPRSEN_R::new(((self.bits >> 24) & 0x01) != 0)
417    }
418}
419impl W {
420    #[doc = "Bit 0 - DTI Enable"]
421    #[inline(always)]
422    pub fn dten(&mut self) -> DTEN_W {
423        DTEN_W { w: self }
424    }
425    #[doc = "Bit 1 - DTI Automatic Start-up Functionality"]
426    #[inline(always)]
427    pub fn dtdas(&mut self) -> DTDAS_W {
428        DTDAS_W { w: self }
429    }
430    #[doc = "Bit 2 - DTI Inactive Polarity"]
431    #[inline(always)]
432    pub fn dtipol(&mut self) -> DTIPOL_W {
433        DTIPOL_W { w: self }
434    }
435    #[doc = "Bit 3 - DTI Complementary Output Invert"]
436    #[inline(always)]
437    pub fn dtcinv(&mut self) -> DTCINV_W {
438        DTCINV_W { w: self }
439    }
440    #[doc = "Bits 4:7 - DTI PRS Source Channel Select"]
441    #[inline(always)]
442    pub fn dtprssel(&mut self) -> DTPRSSEL_W {
443        DTPRSSEL_W { w: self }
444    }
445    #[doc = "Bit 9 - DTI Always Run"]
446    #[inline(always)]
447    pub fn dtar(&mut self) -> DTAR_W {
448        DTAR_W { w: self }
449    }
450    #[doc = "Bit 10 - DTI Fault Action on Timer Stop"]
451    #[inline(always)]
452    pub fn dtfats(&mut self) -> DTFATS_W {
453        DTFATS_W { w: self }
454    }
455    #[doc = "Bit 24 - DTI PRS Source Enable"]
456    #[inline(always)]
457    pub fn dtprsen(&mut self) -> DTPRSEN_W {
458        DTPRSEN_W { w: self }
459    }
460}