efm32pg_pac/efm32pg1b200/adc0/
biasprog.rs

1#[doc = "Register `BIASPROG` reader"]
2pub struct R(crate::R<BIASPROG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<BIASPROG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<BIASPROG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<BIASPROG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `BIASPROG` writer"]
17pub struct W(crate::W<BIASPROG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<BIASPROG_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<BIASPROG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<BIASPROG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ADCBIASPROG` reader - Bias Programming Value of Analog ADC Block"]
38pub type ADCBIASPROG_R = crate::FieldReader<u8, ADCBIASPROG_A>;
39#[doc = "Bias Programming Value of Analog ADC Block\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum ADCBIASPROG_A {
43    #[doc = "0: Normal power (use for 1Msps operation)"]
44    NORMAL = 0,
45    #[doc = "4: Scaling bias to 1/2"]
46    SCALE2 = 4,
47    #[doc = "8: Scaling bias to 1/4"]
48    SCALE4 = 8,
49    #[doc = "12: Scaling bias to 1/8"]
50    SCALE8 = 12,
51    #[doc = "14: Scaling bias to 1/16"]
52    SCALE16 = 14,
53    #[doc = "15: Scaling bias to 1/32"]
54    SCALE32 = 15,
55}
56impl From<ADCBIASPROG_A> for u8 {
57    #[inline(always)]
58    fn from(variant: ADCBIASPROG_A) -> Self {
59        variant as _
60    }
61}
62impl ADCBIASPROG_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<ADCBIASPROG_A> {
66        match self.bits {
67            0 => Some(ADCBIASPROG_A::NORMAL),
68            4 => Some(ADCBIASPROG_A::SCALE2),
69            8 => Some(ADCBIASPROG_A::SCALE4),
70            12 => Some(ADCBIASPROG_A::SCALE8),
71            14 => Some(ADCBIASPROG_A::SCALE16),
72            15 => Some(ADCBIASPROG_A::SCALE32),
73            _ => None,
74        }
75    }
76    #[doc = "Checks if the value of the field is `NORMAL`"]
77    #[inline(always)]
78    pub fn is_normal(&self) -> bool {
79        *self == ADCBIASPROG_A::NORMAL
80    }
81    #[doc = "Checks if the value of the field is `SCALE2`"]
82    #[inline(always)]
83    pub fn is_scale2(&self) -> bool {
84        *self == ADCBIASPROG_A::SCALE2
85    }
86    #[doc = "Checks if the value of the field is `SCALE4`"]
87    #[inline(always)]
88    pub fn is_scale4(&self) -> bool {
89        *self == ADCBIASPROG_A::SCALE4
90    }
91    #[doc = "Checks if the value of the field is `SCALE8`"]
92    #[inline(always)]
93    pub fn is_scale8(&self) -> bool {
94        *self == ADCBIASPROG_A::SCALE8
95    }
96    #[doc = "Checks if the value of the field is `SCALE16`"]
97    #[inline(always)]
98    pub fn is_scale16(&self) -> bool {
99        *self == ADCBIASPROG_A::SCALE16
100    }
101    #[doc = "Checks if the value of the field is `SCALE32`"]
102    #[inline(always)]
103    pub fn is_scale32(&self) -> bool {
104        *self == ADCBIASPROG_A::SCALE32
105    }
106}
107#[doc = "Field `ADCBIASPROG` writer - Bias Programming Value of Analog ADC Block"]
108pub type ADCBIASPROG_W<'a, const O: u8> =
109    crate::FieldWriter<'a, u32, BIASPROG_SPEC, u8, ADCBIASPROG_A, 4, O>;
110impl<'a, const O: u8> ADCBIASPROG_W<'a, O> {
111    #[doc = "Normal power (use for 1Msps operation)"]
112    #[inline(always)]
113    pub fn normal(self) -> &'a mut W {
114        self.variant(ADCBIASPROG_A::NORMAL)
115    }
116    #[doc = "Scaling bias to 1/2"]
117    #[inline(always)]
118    pub fn scale2(self) -> &'a mut W {
119        self.variant(ADCBIASPROG_A::SCALE2)
120    }
121    #[doc = "Scaling bias to 1/4"]
122    #[inline(always)]
123    pub fn scale4(self) -> &'a mut W {
124        self.variant(ADCBIASPROG_A::SCALE4)
125    }
126    #[doc = "Scaling bias to 1/8"]
127    #[inline(always)]
128    pub fn scale8(self) -> &'a mut W {
129        self.variant(ADCBIASPROG_A::SCALE8)
130    }
131    #[doc = "Scaling bias to 1/16"]
132    #[inline(always)]
133    pub fn scale16(self) -> &'a mut W {
134        self.variant(ADCBIASPROG_A::SCALE16)
135    }
136    #[doc = "Scaling bias to 1/32"]
137    #[inline(always)]
138    pub fn scale32(self) -> &'a mut W {
139        self.variant(ADCBIASPROG_A::SCALE32)
140    }
141}
142#[doc = "Field `VFAULTCLR` reader - Clear VREFOF Flag"]
143pub type VFAULTCLR_R = crate::BitReader<bool>;
144#[doc = "Field `VFAULTCLR` writer - Clear VREFOF Flag"]
145pub type VFAULTCLR_W<'a, const O: u8> = crate::BitWriter<'a, u32, BIASPROG_SPEC, bool, O>;
146#[doc = "Field `GPBIASACC` reader - Accuracy Setting for the System Bias During ADC Operation"]
147pub type GPBIASACC_R = crate::BitReader<bool>;
148#[doc = "Field `GPBIASACC` writer - Accuracy Setting for the System Bias During ADC Operation"]
149pub type GPBIASACC_W<'a, const O: u8> = crate::BitWriter<'a, u32, BIASPROG_SPEC, bool, O>;
150impl R {
151    #[doc = "Bits 0:3 - Bias Programming Value of Analog ADC Block"]
152    #[inline(always)]
153    pub fn adcbiasprog(&self) -> ADCBIASPROG_R {
154        ADCBIASPROG_R::new((self.bits & 0x0f) as u8)
155    }
156    #[doc = "Bit 12 - Clear VREFOF Flag"]
157    #[inline(always)]
158    pub fn vfaultclr(&self) -> VFAULTCLR_R {
159        VFAULTCLR_R::new(((self.bits >> 12) & 1) != 0)
160    }
161    #[doc = "Bit 16 - Accuracy Setting for the System Bias During ADC Operation"]
162    #[inline(always)]
163    pub fn gpbiasacc(&self) -> GPBIASACC_R {
164        GPBIASACC_R::new(((self.bits >> 16) & 1) != 0)
165    }
166}
167impl W {
168    #[doc = "Bits 0:3 - Bias Programming Value of Analog ADC Block"]
169    #[inline(always)]
170    #[must_use]
171    pub fn adcbiasprog(&mut self) -> ADCBIASPROG_W<0> {
172        ADCBIASPROG_W::new(self)
173    }
174    #[doc = "Bit 12 - Clear VREFOF Flag"]
175    #[inline(always)]
176    #[must_use]
177    pub fn vfaultclr(&mut self) -> VFAULTCLR_W<12> {
178        VFAULTCLR_W::new(self)
179    }
180    #[doc = "Bit 16 - Accuracy Setting for the System Bias During ADC Operation"]
181    #[inline(always)]
182    #[must_use]
183    pub fn gpbiasacc(&mut self) -> GPBIASACC_W<16> {
184        GPBIASACC_W::new(self)
185    }
186    #[doc = "Writes raw bits to the register."]
187    #[inline(always)]
188    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
189        self.0.bits(bits);
190        self
191    }
192}
193#[doc = "Bias Programming Register for Various Analog Blocks Used in ADC Operation\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 [biasprog](index.html) module"]
194pub struct BIASPROG_SPEC;
195impl crate::RegisterSpec for BIASPROG_SPEC {
196    type Ux = u32;
197}
198#[doc = "`read()` method returns [biasprog::R](R) reader structure"]
199impl crate::Readable for BIASPROG_SPEC {
200    type Reader = R;
201}
202#[doc = "`write(|w| ..)` method takes [biasprog::W](W) writer structure"]
203impl crate::Writable for BIASPROG_SPEC {
204    type Writer = W;
205    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
206    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
207}
208#[doc = "`reset()` method sets BIASPROG to value 0"]
209impl crate::Resettable for BIASPROG_SPEC {
210    const RESET_VALUE: Self::Ux = 0;
211}