efm32gg12b110_pac/vdac0/
opa2_ctrl.rs

1#[doc = "Register `OPA2_CTRL` reader"]
2pub struct R(crate::R<OPA2_CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<OPA2_CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<OPA2_CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<OPA2_CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `OPA2_CTRL` writer"]
17pub struct W(crate::W<OPA2_CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<OPA2_CTRL_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_CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<OPA2_CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "OPAx Operation Mode\n\nValue on reset: 2"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum DRIVESTRENGTH_A {
41    #[doc = "0: Lower accuracy with Low drive strength."]
42    _0 = 0,
43    #[doc = "1: Low accuracy with Low drive strength."]
44    _1 = 1,
45    #[doc = "2: High accuracy with High drive strength."]
46    _2 = 2,
47    #[doc = "3: Higher accuracy with High drive strength."]
48    _3 = 3,
49}
50impl From<DRIVESTRENGTH_A> for u8 {
51    #[inline(always)]
52    fn from(variant: DRIVESTRENGTH_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `DRIVESTRENGTH` reader - OPAx Operation Mode"]
57pub type DRIVESTRENGTH_R = crate::FieldReader<u8, DRIVESTRENGTH_A>;
58impl DRIVESTRENGTH_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> DRIVESTRENGTH_A {
62        match self.bits {
63            0 => DRIVESTRENGTH_A::_0,
64            1 => DRIVESTRENGTH_A::_1,
65            2 => DRIVESTRENGTH_A::_2,
66            3 => DRIVESTRENGTH_A::_3,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_0`"]
71    #[inline(always)]
72    pub fn is_0(&self) -> bool {
73        *self == DRIVESTRENGTH_A::_0
74    }
75    #[doc = "Checks if the value of the field is `_1`"]
76    #[inline(always)]
77    pub fn is_1(&self) -> bool {
78        *self == DRIVESTRENGTH_A::_1
79    }
80    #[doc = "Checks if the value of the field is `_2`"]
81    #[inline(always)]
82    pub fn is_2(&self) -> bool {
83        *self == DRIVESTRENGTH_A::_2
84    }
85    #[doc = "Checks if the value of the field is `_3`"]
86    #[inline(always)]
87    pub fn is_3(&self) -> bool {
88        *self == DRIVESTRENGTH_A::_3
89    }
90}
91#[doc = "Field `DRIVESTRENGTH` writer - OPAx Operation Mode"]
92pub type DRIVESTRENGTH_W<'a> =
93    crate::FieldWriterSafe<'a, u32, OPA2_CTRL_SPEC, u8, DRIVESTRENGTH_A, 2, 0>;
94impl<'a> DRIVESTRENGTH_W<'a> {
95    #[doc = "Lower accuracy with Low drive strength."]
96    #[inline(always)]
97    pub fn _0(self) -> &'a mut W {
98        self.variant(DRIVESTRENGTH_A::_0)
99    }
100    #[doc = "Low accuracy with Low drive strength."]
101    #[inline(always)]
102    pub fn _1(self) -> &'a mut W {
103        self.variant(DRIVESTRENGTH_A::_1)
104    }
105    #[doc = "High accuracy with High drive strength."]
106    #[inline(always)]
107    pub fn _2(self) -> &'a mut W {
108        self.variant(DRIVESTRENGTH_A::_2)
109    }
110    #[doc = "Higher accuracy with High drive strength."]
111    #[inline(always)]
112    pub fn _3(self) -> &'a mut W {
113        self.variant(DRIVESTRENGTH_A::_3)
114    }
115}
116#[doc = "Field `INCBW` reader - OPAx Unity Gain Bandwidth Scale"]
117pub type INCBW_R = crate::BitReader<bool>;
118#[doc = "Field `INCBW` writer - OPAx Unity Gain Bandwidth Scale"]
119pub type INCBW_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 2>;
120#[doc = "Field `HCMDIS` reader - High Common Mode Disable"]
121pub type HCMDIS_R = crate::BitReader<bool>;
122#[doc = "Field `HCMDIS` writer - High Common Mode Disable"]
123pub type HCMDIS_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 3>;
124#[doc = "Field `OUTSCALE` reader - Scale OPAx Output Driving Strength"]
125pub type OUTSCALE_R = crate::BitReader<bool>;
126#[doc = "Field `OUTSCALE` writer - Scale OPAx Output Driving Strength"]
127pub type OUTSCALE_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 4>;
128#[doc = "Field `PRSEN` reader - OPAx PRS Trigger Enable"]
129pub type PRSEN_R = crate::BitReader<bool>;
130#[doc = "Field `PRSEN` writer - OPAx PRS Trigger Enable"]
131pub type PRSEN_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 8>;
132#[doc = "Field `PRSMODE` reader - OPAx PRS Trigger Mode"]
133pub type PRSMODE_R = crate::BitReader<bool>;
134#[doc = "Field `PRSMODE` writer - OPAx PRS Trigger Mode"]
135pub type PRSMODE_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 9>;
136#[doc = "OPAx PRS Trigger Select\n\nValue on reset: 0"]
137#[derive(Clone, Copy, Debug, PartialEq)]
138#[repr(u8)]
139pub enum PRSSEL_A {
140    #[doc = "0: PRS ch 0 triggers OPA."]
141    PRSCH0 = 0,
142    #[doc = "1: PRS ch 1 triggers OPA."]
143    PRSCH1 = 1,
144    #[doc = "2: PRS ch 2 triggers OPA."]
145    PRSCH2 = 2,
146    #[doc = "3: PRS ch 3 triggers OPA."]
147    PRSCH3 = 3,
148    #[doc = "4: PRS ch 4 triggers OPA."]
149    PRSCH4 = 4,
150    #[doc = "5: PRS ch 5 triggers OPA."]
151    PRSCH5 = 5,
152    #[doc = "6: PRS ch 6 triggers OPA."]
153    PRSCH6 = 6,
154    #[doc = "7: PRS ch 7 triggers OPA."]
155    PRSCH7 = 7,
156    #[doc = "8: PRS ch 8 triggers OPA."]
157    PRSCH8 = 8,
158    #[doc = "9: PRS ch 9 triggers OPA."]
159    PRSCH9 = 9,
160    #[doc = "10: PRS ch 10 triggers OPA."]
161    PRSCH10 = 10,
162    #[doc = "11: PRS ch 11 triggers OPA."]
163    PRSCH11 = 11,
164    #[doc = "12: PRS ch 12 triggers OPA."]
165    PRSCH12 = 12,
166    #[doc = "13: PRS ch 13 triggers OPA."]
167    PRSCH13 = 13,
168    #[doc = "14: PRS ch 14 triggers OPA."]
169    PRSCH14 = 14,
170    #[doc = "15: PRS ch 15 triggers OPA."]
171    PRSCH15 = 15,
172}
173impl From<PRSSEL_A> for u8 {
174    #[inline(always)]
175    fn from(variant: PRSSEL_A) -> Self {
176        variant as _
177    }
178}
179#[doc = "Field `PRSSEL` reader - OPAx PRS Trigger Select"]
180pub type PRSSEL_R = crate::FieldReader<u8, PRSSEL_A>;
181impl PRSSEL_R {
182    #[doc = "Get enumerated values variant"]
183    #[inline(always)]
184    pub fn variant(&self) -> PRSSEL_A {
185        match self.bits {
186            0 => PRSSEL_A::PRSCH0,
187            1 => PRSSEL_A::PRSCH1,
188            2 => PRSSEL_A::PRSCH2,
189            3 => PRSSEL_A::PRSCH3,
190            4 => PRSSEL_A::PRSCH4,
191            5 => PRSSEL_A::PRSCH5,
192            6 => PRSSEL_A::PRSCH6,
193            7 => PRSSEL_A::PRSCH7,
194            8 => PRSSEL_A::PRSCH8,
195            9 => PRSSEL_A::PRSCH9,
196            10 => PRSSEL_A::PRSCH10,
197            11 => PRSSEL_A::PRSCH11,
198            12 => PRSSEL_A::PRSCH12,
199            13 => PRSSEL_A::PRSCH13,
200            14 => PRSSEL_A::PRSCH14,
201            15 => PRSSEL_A::PRSCH15,
202            _ => unreachable!(),
203        }
204    }
205    #[doc = "Checks if the value of the field is `PRSCH0`"]
206    #[inline(always)]
207    pub fn is_prsch0(&self) -> bool {
208        *self == PRSSEL_A::PRSCH0
209    }
210    #[doc = "Checks if the value of the field is `PRSCH1`"]
211    #[inline(always)]
212    pub fn is_prsch1(&self) -> bool {
213        *self == PRSSEL_A::PRSCH1
214    }
215    #[doc = "Checks if the value of the field is `PRSCH2`"]
216    #[inline(always)]
217    pub fn is_prsch2(&self) -> bool {
218        *self == PRSSEL_A::PRSCH2
219    }
220    #[doc = "Checks if the value of the field is `PRSCH3`"]
221    #[inline(always)]
222    pub fn is_prsch3(&self) -> bool {
223        *self == PRSSEL_A::PRSCH3
224    }
225    #[doc = "Checks if the value of the field is `PRSCH4`"]
226    #[inline(always)]
227    pub fn is_prsch4(&self) -> bool {
228        *self == PRSSEL_A::PRSCH4
229    }
230    #[doc = "Checks if the value of the field is `PRSCH5`"]
231    #[inline(always)]
232    pub fn is_prsch5(&self) -> bool {
233        *self == PRSSEL_A::PRSCH5
234    }
235    #[doc = "Checks if the value of the field is `PRSCH6`"]
236    #[inline(always)]
237    pub fn is_prsch6(&self) -> bool {
238        *self == PRSSEL_A::PRSCH6
239    }
240    #[doc = "Checks if the value of the field is `PRSCH7`"]
241    #[inline(always)]
242    pub fn is_prsch7(&self) -> bool {
243        *self == PRSSEL_A::PRSCH7
244    }
245    #[doc = "Checks if the value of the field is `PRSCH8`"]
246    #[inline(always)]
247    pub fn is_prsch8(&self) -> bool {
248        *self == PRSSEL_A::PRSCH8
249    }
250    #[doc = "Checks if the value of the field is `PRSCH9`"]
251    #[inline(always)]
252    pub fn is_prsch9(&self) -> bool {
253        *self == PRSSEL_A::PRSCH9
254    }
255    #[doc = "Checks if the value of the field is `PRSCH10`"]
256    #[inline(always)]
257    pub fn is_prsch10(&self) -> bool {
258        *self == PRSSEL_A::PRSCH10
259    }
260    #[doc = "Checks if the value of the field is `PRSCH11`"]
261    #[inline(always)]
262    pub fn is_prsch11(&self) -> bool {
263        *self == PRSSEL_A::PRSCH11
264    }
265    #[doc = "Checks if the value of the field is `PRSCH12`"]
266    #[inline(always)]
267    pub fn is_prsch12(&self) -> bool {
268        *self == PRSSEL_A::PRSCH12
269    }
270    #[doc = "Checks if the value of the field is `PRSCH13`"]
271    #[inline(always)]
272    pub fn is_prsch13(&self) -> bool {
273        *self == PRSSEL_A::PRSCH13
274    }
275    #[doc = "Checks if the value of the field is `PRSCH14`"]
276    #[inline(always)]
277    pub fn is_prsch14(&self) -> bool {
278        *self == PRSSEL_A::PRSCH14
279    }
280    #[doc = "Checks if the value of the field is `PRSCH15`"]
281    #[inline(always)]
282    pub fn is_prsch15(&self) -> bool {
283        *self == PRSSEL_A::PRSCH15
284    }
285}
286#[doc = "Field `PRSSEL` writer - OPAx PRS Trigger Select"]
287pub type PRSSEL_W<'a> = crate::FieldWriterSafe<'a, u32, OPA2_CTRL_SPEC, u8, PRSSEL_A, 4, 10>;
288impl<'a> PRSSEL_W<'a> {
289    #[doc = "PRS ch 0 triggers OPA."]
290    #[inline(always)]
291    pub fn prsch0(self) -> &'a mut W {
292        self.variant(PRSSEL_A::PRSCH0)
293    }
294    #[doc = "PRS ch 1 triggers OPA."]
295    #[inline(always)]
296    pub fn prsch1(self) -> &'a mut W {
297        self.variant(PRSSEL_A::PRSCH1)
298    }
299    #[doc = "PRS ch 2 triggers OPA."]
300    #[inline(always)]
301    pub fn prsch2(self) -> &'a mut W {
302        self.variant(PRSSEL_A::PRSCH2)
303    }
304    #[doc = "PRS ch 3 triggers OPA."]
305    #[inline(always)]
306    pub fn prsch3(self) -> &'a mut W {
307        self.variant(PRSSEL_A::PRSCH3)
308    }
309    #[doc = "PRS ch 4 triggers OPA."]
310    #[inline(always)]
311    pub fn prsch4(self) -> &'a mut W {
312        self.variant(PRSSEL_A::PRSCH4)
313    }
314    #[doc = "PRS ch 5 triggers OPA."]
315    #[inline(always)]
316    pub fn prsch5(self) -> &'a mut W {
317        self.variant(PRSSEL_A::PRSCH5)
318    }
319    #[doc = "PRS ch 6 triggers OPA."]
320    #[inline(always)]
321    pub fn prsch6(self) -> &'a mut W {
322        self.variant(PRSSEL_A::PRSCH6)
323    }
324    #[doc = "PRS ch 7 triggers OPA."]
325    #[inline(always)]
326    pub fn prsch7(self) -> &'a mut W {
327        self.variant(PRSSEL_A::PRSCH7)
328    }
329    #[doc = "PRS ch 8 triggers OPA."]
330    #[inline(always)]
331    pub fn prsch8(self) -> &'a mut W {
332        self.variant(PRSSEL_A::PRSCH8)
333    }
334    #[doc = "PRS ch 9 triggers OPA."]
335    #[inline(always)]
336    pub fn prsch9(self) -> &'a mut W {
337        self.variant(PRSSEL_A::PRSCH9)
338    }
339    #[doc = "PRS ch 10 triggers OPA."]
340    #[inline(always)]
341    pub fn prsch10(self) -> &'a mut W {
342        self.variant(PRSSEL_A::PRSCH10)
343    }
344    #[doc = "PRS ch 11 triggers OPA."]
345    #[inline(always)]
346    pub fn prsch11(self) -> &'a mut W {
347        self.variant(PRSSEL_A::PRSCH11)
348    }
349    #[doc = "PRS ch 12 triggers OPA."]
350    #[inline(always)]
351    pub fn prsch12(self) -> &'a mut W {
352        self.variant(PRSSEL_A::PRSCH12)
353    }
354    #[doc = "PRS ch 13 triggers OPA."]
355    #[inline(always)]
356    pub fn prsch13(self) -> &'a mut W {
357        self.variant(PRSSEL_A::PRSCH13)
358    }
359    #[doc = "PRS ch 14 triggers OPA."]
360    #[inline(always)]
361    pub fn prsch14(self) -> &'a mut W {
362        self.variant(PRSSEL_A::PRSCH14)
363    }
364    #[doc = "PRS ch 15 triggers OPA."]
365    #[inline(always)]
366    pub fn prsch15(self) -> &'a mut W {
367        self.variant(PRSSEL_A::PRSCH15)
368    }
369}
370#[doc = "Field `PRSOUTMODE` reader - OPAx PRS Output Select"]
371pub type PRSOUTMODE_R = crate::BitReader<bool>;
372#[doc = "Field `PRSOUTMODE` writer - OPAx PRS Output Select"]
373pub type PRSOUTMODE_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 16>;
374#[doc = "Field `APORTXMASTERDIS` reader - APORT Bus Master Disable"]
375pub type APORTXMASTERDIS_R = crate::BitReader<bool>;
376#[doc = "Field `APORTXMASTERDIS` writer - APORT Bus Master Disable"]
377pub type APORTXMASTERDIS_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 20>;
378#[doc = "Field `APORTYMASTERDIS` reader - APORT Bus Master Disable"]
379pub type APORTYMASTERDIS_R = crate::BitReader<bool>;
380#[doc = "Field `APORTYMASTERDIS` writer - APORT Bus Master Disable"]
381pub type APORTYMASTERDIS_W<'a> = crate::BitWriter<'a, u32, OPA2_CTRL_SPEC, bool, 21>;
382impl R {
383    #[doc = "Bits 0:1 - OPAx Operation Mode"]
384    #[inline(always)]
385    pub fn drivestrength(&self) -> DRIVESTRENGTH_R {
386        DRIVESTRENGTH_R::new((self.bits & 3) as u8)
387    }
388    #[doc = "Bit 2 - OPAx Unity Gain Bandwidth Scale"]
389    #[inline(always)]
390    pub fn incbw(&self) -> INCBW_R {
391        INCBW_R::new(((self.bits >> 2) & 1) != 0)
392    }
393    #[doc = "Bit 3 - High Common Mode Disable"]
394    #[inline(always)]
395    pub fn hcmdis(&self) -> HCMDIS_R {
396        HCMDIS_R::new(((self.bits >> 3) & 1) != 0)
397    }
398    #[doc = "Bit 4 - Scale OPAx Output Driving Strength"]
399    #[inline(always)]
400    pub fn outscale(&self) -> OUTSCALE_R {
401        OUTSCALE_R::new(((self.bits >> 4) & 1) != 0)
402    }
403    #[doc = "Bit 8 - OPAx PRS Trigger Enable"]
404    #[inline(always)]
405    pub fn prsen(&self) -> PRSEN_R {
406        PRSEN_R::new(((self.bits >> 8) & 1) != 0)
407    }
408    #[doc = "Bit 9 - OPAx PRS Trigger Mode"]
409    #[inline(always)]
410    pub fn prsmode(&self) -> PRSMODE_R {
411        PRSMODE_R::new(((self.bits >> 9) & 1) != 0)
412    }
413    #[doc = "Bits 10:13 - OPAx PRS Trigger Select"]
414    #[inline(always)]
415    pub fn prssel(&self) -> PRSSEL_R {
416        PRSSEL_R::new(((self.bits >> 10) & 0x0f) as u8)
417    }
418    #[doc = "Bit 16 - OPAx PRS Output Select"]
419    #[inline(always)]
420    pub fn prsoutmode(&self) -> PRSOUTMODE_R {
421        PRSOUTMODE_R::new(((self.bits >> 16) & 1) != 0)
422    }
423    #[doc = "Bit 20 - APORT Bus Master Disable"]
424    #[inline(always)]
425    pub fn aportxmasterdis(&self) -> APORTXMASTERDIS_R {
426        APORTXMASTERDIS_R::new(((self.bits >> 20) & 1) != 0)
427    }
428    #[doc = "Bit 21 - APORT Bus Master Disable"]
429    #[inline(always)]
430    pub fn aportymasterdis(&self) -> APORTYMASTERDIS_R {
431        APORTYMASTERDIS_R::new(((self.bits >> 21) & 1) != 0)
432    }
433}
434impl W {
435    #[doc = "Bits 0:1 - OPAx Operation Mode"]
436    #[inline(always)]
437    pub fn drivestrength(&mut self) -> DRIVESTRENGTH_W {
438        DRIVESTRENGTH_W::new(self)
439    }
440    #[doc = "Bit 2 - OPAx Unity Gain Bandwidth Scale"]
441    #[inline(always)]
442    pub fn incbw(&mut self) -> INCBW_W {
443        INCBW_W::new(self)
444    }
445    #[doc = "Bit 3 - High Common Mode Disable"]
446    #[inline(always)]
447    pub fn hcmdis(&mut self) -> HCMDIS_W {
448        HCMDIS_W::new(self)
449    }
450    #[doc = "Bit 4 - Scale OPAx Output Driving Strength"]
451    #[inline(always)]
452    pub fn outscale(&mut self) -> OUTSCALE_W {
453        OUTSCALE_W::new(self)
454    }
455    #[doc = "Bit 8 - OPAx PRS Trigger Enable"]
456    #[inline(always)]
457    pub fn prsen(&mut self) -> PRSEN_W {
458        PRSEN_W::new(self)
459    }
460    #[doc = "Bit 9 - OPAx PRS Trigger Mode"]
461    #[inline(always)]
462    pub fn prsmode(&mut self) -> PRSMODE_W {
463        PRSMODE_W::new(self)
464    }
465    #[doc = "Bits 10:13 - OPAx PRS Trigger Select"]
466    #[inline(always)]
467    pub fn prssel(&mut self) -> PRSSEL_W {
468        PRSSEL_W::new(self)
469    }
470    #[doc = "Bit 16 - OPAx PRS Output Select"]
471    #[inline(always)]
472    pub fn prsoutmode(&mut self) -> PRSOUTMODE_W {
473        PRSOUTMODE_W::new(self)
474    }
475    #[doc = "Bit 20 - APORT Bus Master Disable"]
476    #[inline(always)]
477    pub fn aportxmasterdis(&mut self) -> APORTXMASTERDIS_W {
478        APORTXMASTERDIS_W::new(self)
479    }
480    #[doc = "Bit 21 - APORT Bus Master Disable"]
481    #[inline(always)]
482    pub fn aportymasterdis(&mut self) -> APORTYMASTERDIS_W {
483        APORTYMASTERDIS_W::new(self)
484    }
485    #[doc = "Writes raw bits to the register."]
486    #[inline(always)]
487    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
488        self.0.bits(bits);
489        self
490    }
491}
492#[doc = "Operational Amplifier Control 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_ctrl](index.html) module"]
493pub struct OPA2_CTRL_SPEC;
494impl crate::RegisterSpec for OPA2_CTRL_SPEC {
495    type Ux = u32;
496}
497#[doc = "`read()` method returns [opa2_ctrl::R](R) reader structure"]
498impl crate::Readable for OPA2_CTRL_SPEC {
499    type Reader = R;
500}
501#[doc = "`write(|w| ..)` method takes [opa2_ctrl::W](W) writer structure"]
502impl crate::Writable for OPA2_CTRL_SPEC {
503    type Writer = W;
504}
505#[doc = "`reset()` method sets OPA2_CTRL to value 0x0e"]
506impl crate::Resettable for OPA2_CTRL_SPEC {
507    #[inline(always)]
508    fn reset_value() -> Self::Ux {
509        0x0e
510    }
511}