efm32pg12_pac/vdac0/
opa0_mux.rs

1#[doc = "Reader of register OPA0_MUX"]
2pub type R = crate::R<u32, super::OPA0_MUX>;
3#[doc = "Writer for register OPA0_MUX"]
4pub type W = crate::W<u32, super::OPA0_MUX>;
5#[doc = "Register OPA0_MUX `reset()`'s with value 0x0016_f2f1"]
6impl crate::ResetValue for super::OPA0_MUX {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x0016_f2f1
11    }
12}
13#[doc = "Reader of field `POSSEL`"]
14pub type POSSEL_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `POSSEL`"]
16pub struct POSSEL_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> POSSEL_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff);
24        self.w
25    }
26}
27#[doc = "Reader of field `NEGSEL`"]
28pub type NEGSEL_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `NEGSEL`"]
30pub struct NEGSEL_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> NEGSEL_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0xff << 8)) | (((value as u32) & 0xff) << 8);
38        self.w
39    }
40}
41#[doc = "OPAx Resistor Ladder Input Mux\n\nValue on reset: 6"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum RESINMUX_A {
45    #[doc = "0: Set for Unity Gain"]
46    DISABLE = 0,
47    #[doc = "1: Set for NEXTOUT(x-1) input"]
48    OPANEXT = 1,
49    #[doc = "2: NEG pad connected"]
50    NEGPAD = 2,
51    #[doc = "3: POS pad connected"]
52    POSPAD = 3,
53    #[doc = "4: Neg pad of OPA0 connected. Direct input to support common reference."]
54    COMPAD = 4,
55    #[doc = "5: OPA0 and OPA1 Resmux connected to form fully differential instrumentation amplifier."]
56    CENTER = 5,
57    #[doc = "6: VSS connected"]
58    VSS = 6,
59}
60impl From<RESINMUX_A> for u8 {
61    #[inline(always)]
62    fn from(variant: RESINMUX_A) -> Self {
63        variant as _
64    }
65}
66#[doc = "Reader of field `RESINMUX`"]
67pub type RESINMUX_R = crate::R<u8, RESINMUX_A>;
68impl RESINMUX_R {
69    #[doc = r"Get enumerated values variant"]
70    #[inline(always)]
71    pub fn variant(&self) -> crate::Variant<u8, RESINMUX_A> {
72        use crate::Variant::*;
73        match self.bits {
74            0 => Val(RESINMUX_A::DISABLE),
75            1 => Val(RESINMUX_A::OPANEXT),
76            2 => Val(RESINMUX_A::NEGPAD),
77            3 => Val(RESINMUX_A::POSPAD),
78            4 => Val(RESINMUX_A::COMPAD),
79            5 => Val(RESINMUX_A::CENTER),
80            6 => Val(RESINMUX_A::VSS),
81            i => Res(i),
82        }
83    }
84    #[doc = "Checks if the value of the field is `DISABLE`"]
85    #[inline(always)]
86    pub fn is_disable(&self) -> bool {
87        *self == RESINMUX_A::DISABLE
88    }
89    #[doc = "Checks if the value of the field is `OPANEXT`"]
90    #[inline(always)]
91    pub fn is_opanext(&self) -> bool {
92        *self == RESINMUX_A::OPANEXT
93    }
94    #[doc = "Checks if the value of the field is `NEGPAD`"]
95    #[inline(always)]
96    pub fn is_negpad(&self) -> bool {
97        *self == RESINMUX_A::NEGPAD
98    }
99    #[doc = "Checks if the value of the field is `POSPAD`"]
100    #[inline(always)]
101    pub fn is_pospad(&self) -> bool {
102        *self == RESINMUX_A::POSPAD
103    }
104    #[doc = "Checks if the value of the field is `COMPAD`"]
105    #[inline(always)]
106    pub fn is_compad(&self) -> bool {
107        *self == RESINMUX_A::COMPAD
108    }
109    #[doc = "Checks if the value of the field is `CENTER`"]
110    #[inline(always)]
111    pub fn is_center(&self) -> bool {
112        *self == RESINMUX_A::CENTER
113    }
114    #[doc = "Checks if the value of the field is `VSS`"]
115    #[inline(always)]
116    pub fn is_vss(&self) -> bool {
117        *self == RESINMUX_A::VSS
118    }
119}
120#[doc = "Write proxy for field `RESINMUX`"]
121pub struct RESINMUX_W<'a> {
122    w: &'a mut W,
123}
124impl<'a> RESINMUX_W<'a> {
125    #[doc = r"Writes `variant` to the field"]
126    #[inline(always)]
127    pub fn variant(self, variant: RESINMUX_A) -> &'a mut W {
128        unsafe { self.bits(variant.into()) }
129    }
130    #[doc = "Set for Unity Gain"]
131    #[inline(always)]
132    pub fn disable(self) -> &'a mut W {
133        self.variant(RESINMUX_A::DISABLE)
134    }
135    #[doc = "Set for NEXTOUT(x-1) input"]
136    #[inline(always)]
137    pub fn opanext(self) -> &'a mut W {
138        self.variant(RESINMUX_A::OPANEXT)
139    }
140    #[doc = "NEG pad connected"]
141    #[inline(always)]
142    pub fn negpad(self) -> &'a mut W {
143        self.variant(RESINMUX_A::NEGPAD)
144    }
145    #[doc = "POS pad connected"]
146    #[inline(always)]
147    pub fn pospad(self) -> &'a mut W {
148        self.variant(RESINMUX_A::POSPAD)
149    }
150    #[doc = "Neg pad of OPA0 connected. Direct input to support common reference."]
151    #[inline(always)]
152    pub fn compad(self) -> &'a mut W {
153        self.variant(RESINMUX_A::COMPAD)
154    }
155    #[doc = "OPA0 and OPA1 Resmux connected to form fully differential instrumentation amplifier."]
156    #[inline(always)]
157    pub fn center(self) -> &'a mut W {
158        self.variant(RESINMUX_A::CENTER)
159    }
160    #[doc = "VSS connected"]
161    #[inline(always)]
162    pub fn vss(self) -> &'a mut W {
163        self.variant(RESINMUX_A::VSS)
164    }
165    #[doc = r"Writes raw bits to the field"]
166    #[inline(always)]
167    pub unsafe fn bits(self, value: u8) -> &'a mut W {
168        self.w.bits = (self.w.bits & !(0x07 << 16)) | (((value as u32) & 0x07) << 16);
169        self.w
170    }
171}
172#[doc = "Reader of field `GAIN3X`"]
173pub type GAIN3X_R = crate::R<bool, bool>;
174#[doc = "Write proxy for field `GAIN3X`"]
175pub struct GAIN3X_W<'a> {
176    w: &'a mut W,
177}
178impl<'a> GAIN3X_W<'a> {
179    #[doc = r"Sets the field bit"]
180    #[inline(always)]
181    pub fn set_bit(self) -> &'a mut W {
182        self.bit(true)
183    }
184    #[doc = r"Clears the field bit"]
185    #[inline(always)]
186    pub fn clear_bit(self) -> &'a mut W {
187        self.bit(false)
188    }
189    #[doc = r"Writes raw bits to the field"]
190    #[inline(always)]
191    pub fn bit(self, value: bool) -> &'a mut W {
192        self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20);
193        self.w
194    }
195}
196#[doc = "OPAx Resistor Ladder Select\n\nValue on reset: 0"]
197#[derive(Clone, Copy, Debug, PartialEq)]
198#[repr(u8)]
199pub enum RESSEL_A {
200    #[doc = "0: Gain of 1/3"]
201    RES0 = 0,
202    #[doc = "1: Gain of 1"]
203    RES1 = 1,
204    #[doc = "2: Gain of 1 2/3"]
205    RES2 = 2,
206    #[doc = "3: Gain of 2 1/5"]
207    RES3 = 3,
208    #[doc = "4: Gain of 3"]
209    RES4 = 4,
210    #[doc = "5: Gain of 4 1/3"]
211    RES5 = 5,
212    #[doc = "6: Gain of 7"]
213    RES6 = 6,
214    #[doc = "7: Gain of 15"]
215    RES7 = 7,
216}
217impl From<RESSEL_A> for u8 {
218    #[inline(always)]
219    fn from(variant: RESSEL_A) -> Self {
220        variant as _
221    }
222}
223#[doc = "Reader of field `RESSEL`"]
224pub type RESSEL_R = crate::R<u8, RESSEL_A>;
225impl RESSEL_R {
226    #[doc = r"Get enumerated values variant"]
227    #[inline(always)]
228    pub fn variant(&self) -> RESSEL_A {
229        match self.bits {
230            0 => RESSEL_A::RES0,
231            1 => RESSEL_A::RES1,
232            2 => RESSEL_A::RES2,
233            3 => RESSEL_A::RES3,
234            4 => RESSEL_A::RES4,
235            5 => RESSEL_A::RES5,
236            6 => RESSEL_A::RES6,
237            7 => RESSEL_A::RES7,
238            _ => unreachable!(),
239        }
240    }
241    #[doc = "Checks if the value of the field is `RES0`"]
242    #[inline(always)]
243    pub fn is_res0(&self) -> bool {
244        *self == RESSEL_A::RES0
245    }
246    #[doc = "Checks if the value of the field is `RES1`"]
247    #[inline(always)]
248    pub fn is_res1(&self) -> bool {
249        *self == RESSEL_A::RES1
250    }
251    #[doc = "Checks if the value of the field is `RES2`"]
252    #[inline(always)]
253    pub fn is_res2(&self) -> bool {
254        *self == RESSEL_A::RES2
255    }
256    #[doc = "Checks if the value of the field is `RES3`"]
257    #[inline(always)]
258    pub fn is_res3(&self) -> bool {
259        *self == RESSEL_A::RES3
260    }
261    #[doc = "Checks if the value of the field is `RES4`"]
262    #[inline(always)]
263    pub fn is_res4(&self) -> bool {
264        *self == RESSEL_A::RES4
265    }
266    #[doc = "Checks if the value of the field is `RES5`"]
267    #[inline(always)]
268    pub fn is_res5(&self) -> bool {
269        *self == RESSEL_A::RES5
270    }
271    #[doc = "Checks if the value of the field is `RES6`"]
272    #[inline(always)]
273    pub fn is_res6(&self) -> bool {
274        *self == RESSEL_A::RES6
275    }
276    #[doc = "Checks if the value of the field is `RES7`"]
277    #[inline(always)]
278    pub fn is_res7(&self) -> bool {
279        *self == RESSEL_A::RES7
280    }
281}
282#[doc = "Write proxy for field `RESSEL`"]
283pub struct RESSEL_W<'a> {
284    w: &'a mut W,
285}
286impl<'a> RESSEL_W<'a> {
287    #[doc = r"Writes `variant` to the field"]
288    #[inline(always)]
289    pub fn variant(self, variant: RESSEL_A) -> &'a mut W {
290        {
291            self.bits(variant.into())
292        }
293    }
294    #[doc = "Gain of 1/3"]
295    #[inline(always)]
296    pub fn res0(self) -> &'a mut W {
297        self.variant(RESSEL_A::RES0)
298    }
299    #[doc = "Gain of 1"]
300    #[inline(always)]
301    pub fn res1(self) -> &'a mut W {
302        self.variant(RESSEL_A::RES1)
303    }
304    #[doc = "Gain of 1 2/3"]
305    #[inline(always)]
306    pub fn res2(self) -> &'a mut W {
307        self.variant(RESSEL_A::RES2)
308    }
309    #[doc = "Gain of 2 1/5"]
310    #[inline(always)]
311    pub fn res3(self) -> &'a mut W {
312        self.variant(RESSEL_A::RES3)
313    }
314    #[doc = "Gain of 3"]
315    #[inline(always)]
316    pub fn res4(self) -> &'a mut W {
317        self.variant(RESSEL_A::RES4)
318    }
319    #[doc = "Gain of 4 1/3"]
320    #[inline(always)]
321    pub fn res5(self) -> &'a mut W {
322        self.variant(RESSEL_A::RES5)
323    }
324    #[doc = "Gain of 7"]
325    #[inline(always)]
326    pub fn res6(self) -> &'a mut W {
327        self.variant(RESSEL_A::RES6)
328    }
329    #[doc = "Gain of 15"]
330    #[inline(always)]
331    pub fn res7(self) -> &'a mut W {
332        self.variant(RESSEL_A::RES7)
333    }
334    #[doc = r"Writes raw bits to the field"]
335    #[inline(always)]
336    pub fn bits(self, value: u8) -> &'a mut W {
337        self.w.bits = (self.w.bits & !(0x07 << 24)) | (((value as u32) & 0x07) << 24);
338        self.w
339    }
340}
341impl R {
342    #[doc = "Bits 0:7 - OPAx Non-inverting Input Mux"]
343    #[inline(always)]
344    pub fn possel(&self) -> POSSEL_R {
345        POSSEL_R::new((self.bits & 0xff) as u8)
346    }
347    #[doc = "Bits 8:15 - OPAx Inverting Input Mux"]
348    #[inline(always)]
349    pub fn negsel(&self) -> NEGSEL_R {
350        NEGSEL_R::new(((self.bits >> 8) & 0xff) as u8)
351    }
352    #[doc = "Bits 16:18 - OPAx Resistor Ladder Input Mux"]
353    #[inline(always)]
354    pub fn resinmux(&self) -> RESINMUX_R {
355        RESINMUX_R::new(((self.bits >> 16) & 0x07) as u8)
356    }
357    #[doc = "Bit 20 - OPAx Dedicated 3x Gain Resistor Ladder"]
358    #[inline(always)]
359    pub fn gain3x(&self) -> GAIN3X_R {
360        GAIN3X_R::new(((self.bits >> 20) & 0x01) != 0)
361    }
362    #[doc = "Bits 24:26 - OPAx Resistor Ladder Select"]
363    #[inline(always)]
364    pub fn ressel(&self) -> RESSEL_R {
365        RESSEL_R::new(((self.bits >> 24) & 0x07) as u8)
366    }
367}
368impl W {
369    #[doc = "Bits 0:7 - OPAx Non-inverting Input Mux"]
370    #[inline(always)]
371    pub fn possel(&mut self) -> POSSEL_W {
372        POSSEL_W { w: self }
373    }
374    #[doc = "Bits 8:15 - OPAx Inverting Input Mux"]
375    #[inline(always)]
376    pub fn negsel(&mut self) -> NEGSEL_W {
377        NEGSEL_W { w: self }
378    }
379    #[doc = "Bits 16:18 - OPAx Resistor Ladder Input Mux"]
380    #[inline(always)]
381    pub fn resinmux(&mut self) -> RESINMUX_W {
382        RESINMUX_W { w: self }
383    }
384    #[doc = "Bit 20 - OPAx Dedicated 3x Gain Resistor Ladder"]
385    #[inline(always)]
386    pub fn gain3x(&mut self) -> GAIN3X_W {
387        GAIN3X_W { w: self }
388    }
389    #[doc = "Bits 24:26 - OPAx Resistor Ladder Select"]
390    #[inline(always)]
391    pub fn ressel(&mut self) -> RESSEL_W {
392        RESSEL_W { w: self }
393    }
394}