efm32gg11b820_pac/vdac0/
opa2_mux.rs

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