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