efm32pg12_pac/idac0/
curprog.rs

1#[doc = "Reader of register CURPROG"]
2pub type R = crate::R<u32, super::CURPROG>;
3#[doc = "Writer for register CURPROG"]
4pub type W = crate::W<u32, super::CURPROG>;
5#[doc = "Register CURPROG `reset()`'s with value 0x009b_0000"]
6impl crate::ResetValue for super::CURPROG {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x009b_0000
11    }
12}
13#[doc = "Current Range Select\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum RANGESEL_A {
17    #[doc = "0: Current range set to 0 - 1.6 uA."]
18    RANGE0 = 0,
19    #[doc = "1: Current range set to 1.6 - 4.7 uA."]
20    RANGE1 = 1,
21    #[doc = "2: Current range set to 0.5 - 16 uA."]
22    RANGE2 = 2,
23    #[doc = "3: Current range set to 2 - 64 uA."]
24    RANGE3 = 3,
25}
26impl From<RANGESEL_A> for u8 {
27    #[inline(always)]
28    fn from(variant: RANGESEL_A) -> Self {
29        variant as _
30    }
31}
32#[doc = "Reader of field `RANGESEL`"]
33pub type RANGESEL_R = crate::R<u8, RANGESEL_A>;
34impl RANGESEL_R {
35    #[doc = r"Get enumerated values variant"]
36    #[inline(always)]
37    pub fn variant(&self) -> RANGESEL_A {
38        match self.bits {
39            0 => RANGESEL_A::RANGE0,
40            1 => RANGESEL_A::RANGE1,
41            2 => RANGESEL_A::RANGE2,
42            3 => RANGESEL_A::RANGE3,
43            _ => unreachable!(),
44        }
45    }
46    #[doc = "Checks if the value of the field is `RANGE0`"]
47    #[inline(always)]
48    pub fn is_range0(&self) -> bool {
49        *self == RANGESEL_A::RANGE0
50    }
51    #[doc = "Checks if the value of the field is `RANGE1`"]
52    #[inline(always)]
53    pub fn is_range1(&self) -> bool {
54        *self == RANGESEL_A::RANGE1
55    }
56    #[doc = "Checks if the value of the field is `RANGE2`"]
57    #[inline(always)]
58    pub fn is_range2(&self) -> bool {
59        *self == RANGESEL_A::RANGE2
60    }
61    #[doc = "Checks if the value of the field is `RANGE3`"]
62    #[inline(always)]
63    pub fn is_range3(&self) -> bool {
64        *self == RANGESEL_A::RANGE3
65    }
66}
67#[doc = "Write proxy for field `RANGESEL`"]
68pub struct RANGESEL_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> RANGESEL_W<'a> {
72    #[doc = r"Writes `variant` to the field"]
73    #[inline(always)]
74    pub fn variant(self, variant: RANGESEL_A) -> &'a mut W {
75        {
76            self.bits(variant.into())
77        }
78    }
79    #[doc = "Current range set to 0 - 1.6 uA."]
80    #[inline(always)]
81    pub fn range0(self) -> &'a mut W {
82        self.variant(RANGESEL_A::RANGE0)
83    }
84    #[doc = "Current range set to 1.6 - 4.7 uA."]
85    #[inline(always)]
86    pub fn range1(self) -> &'a mut W {
87        self.variant(RANGESEL_A::RANGE1)
88    }
89    #[doc = "Current range set to 0.5 - 16 uA."]
90    #[inline(always)]
91    pub fn range2(self) -> &'a mut W {
92        self.variant(RANGESEL_A::RANGE2)
93    }
94    #[doc = "Current range set to 2 - 64 uA."]
95    #[inline(always)]
96    pub fn range3(self) -> &'a mut W {
97        self.variant(RANGESEL_A::RANGE3)
98    }
99    #[doc = r"Writes raw bits to the field"]
100    #[inline(always)]
101    pub fn bits(self, value: u8) -> &'a mut W {
102        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
103        self.w
104    }
105}
106#[doc = "Reader of field `STEPSEL`"]
107pub type STEPSEL_R = crate::R<u8, u8>;
108#[doc = "Write proxy for field `STEPSEL`"]
109pub struct STEPSEL_W<'a> {
110    w: &'a mut W,
111}
112impl<'a> STEPSEL_W<'a> {
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub unsafe fn bits(self, value: u8) -> &'a mut W {
116        self.w.bits = (self.w.bits & !(0x1f << 8)) | (((value as u32) & 0x1f) << 8);
117        self.w
118    }
119}
120#[doc = "Reader of field `TUNING`"]
121pub type TUNING_R = crate::R<u8, u8>;
122#[doc = "Write proxy for field `TUNING`"]
123pub struct TUNING_W<'a> {
124    w: &'a mut W,
125}
126impl<'a> TUNING_W<'a> {
127    #[doc = r"Writes raw bits to the field"]
128    #[inline(always)]
129    pub unsafe fn bits(self, value: u8) -> &'a mut W {
130        self.w.bits = (self.w.bits & !(0xff << 16)) | (((value as u32) & 0xff) << 16);
131        self.w
132    }
133}
134impl R {
135    #[doc = "Bits 0:1 - Current Range Select"]
136    #[inline(always)]
137    pub fn rangesel(&self) -> RANGESEL_R {
138        RANGESEL_R::new((self.bits & 0x03) as u8)
139    }
140    #[doc = "Bits 8:12 - Current Step Size Select"]
141    #[inline(always)]
142    pub fn stepsel(&self) -> STEPSEL_R {
143        STEPSEL_R::new(((self.bits >> 8) & 0x1f) as u8)
144    }
145    #[doc = "Bits 16:23 - Tune the Current to Given Accuracy"]
146    #[inline(always)]
147    pub fn tuning(&self) -> TUNING_R {
148        TUNING_R::new(((self.bits >> 16) & 0xff) as u8)
149    }
150}
151impl W {
152    #[doc = "Bits 0:1 - Current Range Select"]
153    #[inline(always)]
154    pub fn rangesel(&mut self) -> RANGESEL_W {
155        RANGESEL_W { w: self }
156    }
157    #[doc = "Bits 8:12 - Current Step Size Select"]
158    #[inline(always)]
159    pub fn stepsel(&mut self) -> STEPSEL_W {
160        STEPSEL_W { w: self }
161    }
162    #[doc = "Bits 16:23 - Tune the Current to Given Accuracy"]
163    #[inline(always)]
164    pub fn tuning(&mut self) -> TUNING_W {
165        TUNING_W { w: self }
166    }
167}