efm32tg11b_pac/efm32tg11b120/acmp0/
hysteresis1.rs

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