efm32pg12_pac/acmp0/
hysteresis1.rs

1#[doc = "Reader of register HYSTERESIS1"]
2pub type R = crate::R<u32, super::HYSTERESIS1>;
3#[doc = "Writer for register HYSTERESIS1"]
4pub type W = crate::W<u32, super::HYSTERESIS1>;
5#[doc = "Register HYSTERESIS1 `reset()`'s with value 0"]
6impl crate::ResetValue for super::HYSTERESIS1 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Hysteresis Select When ACMPOUT=1\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum HYST_A {
17    #[doc = "0: No hysteresis"]
18    HYST0 = 0,
19    #[doc = "1: 14 mV hysteresis"]
20    HYST1 = 1,
21    #[doc = "2: 25 mV hysteresis"]
22    HYST2 = 2,
23    #[doc = "3: 30 mV hysteresis"]
24    HYST3 = 3,
25    #[doc = "4: 35 mV hysteresis"]
26    HYST4 = 4,
27    #[doc = "5: 39 mV hysteresis"]
28    HYST5 = 5,
29    #[doc = "6: 42 mV hysteresis"]
30    HYST6 = 6,
31    #[doc = "7: 45 mV hysteresis"]
32    HYST7 = 7,
33    #[doc = "8: No hysteresis"]
34    HYST8 = 8,
35    #[doc = "9: -14 mV hysteresis"]
36    HYST9 = 9,
37    #[doc = "10: -25 mV hysteresis"]
38    HYST10 = 10,
39    #[doc = "11: -30 mV hysteresis"]
40    HYST11 = 11,
41    #[doc = "12: -35 mV hysteresis"]
42    HYST12 = 12,
43    #[doc = "13: -39 mV hysteresis"]
44    HYST13 = 13,
45    #[doc = "14: -42 mV hysteresis"]
46    HYST14 = 14,
47    #[doc = "15: -45 mV hysteresis"]
48    HYST15 = 15,
49}
50impl From<HYST_A> for u8 {
51    #[inline(always)]
52    fn from(variant: HYST_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Reader of field `HYST`"]
57pub type HYST_R = crate::R<u8, HYST_A>;
58impl HYST_R {
59    #[doc = r"Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> HYST_A {
62        match self.bits {
63            0 => HYST_A::HYST0,
64            1 => HYST_A::HYST1,
65            2 => HYST_A::HYST2,
66            3 => HYST_A::HYST3,
67            4 => HYST_A::HYST4,
68            5 => HYST_A::HYST5,
69            6 => HYST_A::HYST6,
70            7 => HYST_A::HYST7,
71            8 => HYST_A::HYST8,
72            9 => HYST_A::HYST9,
73            10 => HYST_A::HYST10,
74            11 => HYST_A::HYST11,
75            12 => HYST_A::HYST12,
76            13 => HYST_A::HYST13,
77            14 => HYST_A::HYST14,
78            15 => HYST_A::HYST15,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `HYST0`"]
83    #[inline(always)]
84    pub fn is_hyst0(&self) -> bool {
85        *self == HYST_A::HYST0
86    }
87    #[doc = "Checks if the value of the field is `HYST1`"]
88    #[inline(always)]
89    pub fn is_hyst1(&self) -> bool {
90        *self == HYST_A::HYST1
91    }
92    #[doc = "Checks if the value of the field is `HYST2`"]
93    #[inline(always)]
94    pub fn is_hyst2(&self) -> bool {
95        *self == HYST_A::HYST2
96    }
97    #[doc = "Checks if the value of the field is `HYST3`"]
98    #[inline(always)]
99    pub fn is_hyst3(&self) -> bool {
100        *self == HYST_A::HYST3
101    }
102    #[doc = "Checks if the value of the field is `HYST4`"]
103    #[inline(always)]
104    pub fn is_hyst4(&self) -> bool {
105        *self == HYST_A::HYST4
106    }
107    #[doc = "Checks if the value of the field is `HYST5`"]
108    #[inline(always)]
109    pub fn is_hyst5(&self) -> bool {
110        *self == HYST_A::HYST5
111    }
112    #[doc = "Checks if the value of the field is `HYST6`"]
113    #[inline(always)]
114    pub fn is_hyst6(&self) -> bool {
115        *self == HYST_A::HYST6
116    }
117    #[doc = "Checks if the value of the field is `HYST7`"]
118    #[inline(always)]
119    pub fn is_hyst7(&self) -> bool {
120        *self == HYST_A::HYST7
121    }
122    #[doc = "Checks if the value of the field is `HYST8`"]
123    #[inline(always)]
124    pub fn is_hyst8(&self) -> bool {
125        *self == HYST_A::HYST8
126    }
127    #[doc = "Checks if the value of the field is `HYST9`"]
128    #[inline(always)]
129    pub fn is_hyst9(&self) -> bool {
130        *self == HYST_A::HYST9
131    }
132    #[doc = "Checks if the value of the field is `HYST10`"]
133    #[inline(always)]
134    pub fn is_hyst10(&self) -> bool {
135        *self == HYST_A::HYST10
136    }
137    #[doc = "Checks if the value of the field is `HYST11`"]
138    #[inline(always)]
139    pub fn is_hyst11(&self) -> bool {
140        *self == HYST_A::HYST11
141    }
142    #[doc = "Checks if the value of the field is `HYST12`"]
143    #[inline(always)]
144    pub fn is_hyst12(&self) -> bool {
145        *self == HYST_A::HYST12
146    }
147    #[doc = "Checks if the value of the field is `HYST13`"]
148    #[inline(always)]
149    pub fn is_hyst13(&self) -> bool {
150        *self == HYST_A::HYST13
151    }
152    #[doc = "Checks if the value of the field is `HYST14`"]
153    #[inline(always)]
154    pub fn is_hyst14(&self) -> bool {
155        *self == HYST_A::HYST14
156    }
157    #[doc = "Checks if the value of the field is `HYST15`"]
158    #[inline(always)]
159    pub fn is_hyst15(&self) -> bool {
160        *self == HYST_A::HYST15
161    }
162}
163#[doc = "Write proxy for field `HYST`"]
164pub struct HYST_W<'a> {
165    w: &'a mut W,
166}
167impl<'a> HYST_W<'a> {
168    #[doc = r"Writes `variant` to the field"]
169    #[inline(always)]
170    pub fn variant(self, variant: HYST_A) -> &'a mut W {
171        {
172            self.bits(variant.into())
173        }
174    }
175    #[doc = "No hysteresis"]
176    #[inline(always)]
177    pub fn hyst0(self) -> &'a mut W {
178        self.variant(HYST_A::HYST0)
179    }
180    #[doc = "14 mV hysteresis"]
181    #[inline(always)]
182    pub fn hyst1(self) -> &'a mut W {
183        self.variant(HYST_A::HYST1)
184    }
185    #[doc = "25 mV hysteresis"]
186    #[inline(always)]
187    pub fn hyst2(self) -> &'a mut W {
188        self.variant(HYST_A::HYST2)
189    }
190    #[doc = "30 mV hysteresis"]
191    #[inline(always)]
192    pub fn hyst3(self) -> &'a mut W {
193        self.variant(HYST_A::HYST3)
194    }
195    #[doc = "35 mV hysteresis"]
196    #[inline(always)]
197    pub fn hyst4(self) -> &'a mut W {
198        self.variant(HYST_A::HYST4)
199    }
200    #[doc = "39 mV hysteresis"]
201    #[inline(always)]
202    pub fn hyst5(self) -> &'a mut W {
203        self.variant(HYST_A::HYST5)
204    }
205    #[doc = "42 mV hysteresis"]
206    #[inline(always)]
207    pub fn hyst6(self) -> &'a mut W {
208        self.variant(HYST_A::HYST6)
209    }
210    #[doc = "45 mV hysteresis"]
211    #[inline(always)]
212    pub fn hyst7(self) -> &'a mut W {
213        self.variant(HYST_A::HYST7)
214    }
215    #[doc = "No hysteresis"]
216    #[inline(always)]
217    pub fn hyst8(self) -> &'a mut W {
218        self.variant(HYST_A::HYST8)
219    }
220    #[doc = "-14 mV hysteresis"]
221    #[inline(always)]
222    pub fn hyst9(self) -> &'a mut W {
223        self.variant(HYST_A::HYST9)
224    }
225    #[doc = "-25 mV hysteresis"]
226    #[inline(always)]
227    pub fn hyst10(self) -> &'a mut W {
228        self.variant(HYST_A::HYST10)
229    }
230    #[doc = "-30 mV hysteresis"]
231    #[inline(always)]
232    pub fn hyst11(self) -> &'a mut W {
233        self.variant(HYST_A::HYST11)
234    }
235    #[doc = "-35 mV hysteresis"]
236    #[inline(always)]
237    pub fn hyst12(self) -> &'a mut W {
238        self.variant(HYST_A::HYST12)
239    }
240    #[doc = "-39 mV hysteresis"]
241    #[inline(always)]
242    pub fn hyst13(self) -> &'a mut W {
243        self.variant(HYST_A::HYST13)
244    }
245    #[doc = "-42 mV hysteresis"]
246    #[inline(always)]
247    pub fn hyst14(self) -> &'a mut W {
248        self.variant(HYST_A::HYST14)
249    }
250    #[doc = "-45 mV hysteresis"]
251    #[inline(always)]
252    pub fn hyst15(self) -> &'a mut W {
253        self.variant(HYST_A::HYST15)
254    }
255    #[doc = r"Writes raw bits to the field"]
256    #[inline(always)]
257    pub fn bits(self, value: u8) -> &'a mut W {
258        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
259        self.w
260    }
261}
262#[doc = "Reader of field `DIVVA`"]
263pub type DIVVA_R = crate::R<u8, u8>;
264#[doc = "Write proxy for field `DIVVA`"]
265pub struct DIVVA_W<'a> {
266    w: &'a mut W,
267}
268impl<'a> DIVVA_W<'a> {
269    #[doc = r"Writes raw bits to the field"]
270    #[inline(always)]
271    pub unsafe fn bits(self, value: u8) -> &'a mut W {
272        self.w.bits = (self.w.bits & !(0x3f << 16)) | (((value as u32) & 0x3f) << 16);
273        self.w
274    }
275}
276#[doc = "Reader of field `DIVVB`"]
277pub type DIVVB_R = crate::R<u8, u8>;
278#[doc = "Write proxy for field `DIVVB`"]
279pub struct DIVVB_W<'a> {
280    w: &'a mut W,
281}
282impl<'a> DIVVB_W<'a> {
283    #[doc = r"Writes raw bits to the field"]
284    #[inline(always)]
285    pub unsafe fn bits(self, value: u8) -> &'a mut W {
286        self.w.bits = (self.w.bits & !(0x3f << 24)) | (((value as u32) & 0x3f) << 24);
287        self.w
288    }
289}
290impl R {
291    #[doc = "Bits 0:3 - Hysteresis Select When ACMPOUT=1"]
292    #[inline(always)]
293    pub fn hyst(&self) -> HYST_R {
294        HYST_R::new((self.bits & 0x0f) as u8)
295    }
296    #[doc = "Bits 16:21 - Divider for VA Voltage When ACMPOUT=1"]
297    #[inline(always)]
298    pub fn divva(&self) -> DIVVA_R {
299        DIVVA_R::new(((self.bits >> 16) & 0x3f) as u8)
300    }
301    #[doc = "Bits 24:29 - Divider for VB Voltage When ACMPOUT=1"]
302    #[inline(always)]
303    pub fn divvb(&self) -> DIVVB_R {
304        DIVVB_R::new(((self.bits >> 24) & 0x3f) as u8)
305    }
306}
307impl W {
308    #[doc = "Bits 0:3 - Hysteresis Select When ACMPOUT=1"]
309    #[inline(always)]
310    pub fn hyst(&mut self) -> HYST_W {
311        HYST_W { w: self }
312    }
313    #[doc = "Bits 16:21 - Divider for VA Voltage When ACMPOUT=1"]
314    #[inline(always)]
315    pub fn divva(&mut self) -> DIVVA_W {
316        DIVVA_W { w: self }
317    }
318    #[doc = "Bits 24:29 - Divider for VB Voltage When ACMPOUT=1"]
319    #[inline(always)]
320    pub fn divvb(&mut self) -> DIVVB_W {
321        DIVVB_W { w: self }
322    }
323}