efm32tg11b540_pac/adc0/
biasprog.rs1#[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 = "Bias Programming Value of Analog ADC Block\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum ADCBIASPROG_A {
41 #[doc = "0: Normal power (use for 1Msps operation)"]
42 NORMAL = 0,
43 #[doc = "4: Scaling bias to 1/2"]
44 SCALE2 = 4,
45 #[doc = "8: Scaling bias to 1/4"]
46 SCALE4 = 8,
47 #[doc = "12: Scaling bias to 1/8"]
48 SCALE8 = 12,
49 #[doc = "14: Scaling bias to 1/16"]
50 SCALE16 = 14,
51 #[doc = "15: Scaling bias to 1/32"]
52 SCALE32 = 15,
53}
54impl From<ADCBIASPROG_A> for u8 {
55 #[inline(always)]
56 fn from(variant: ADCBIASPROG_A) -> Self {
57 variant as _
58 }
59}
60#[doc = "Field `ADCBIASPROG` reader - Bias Programming Value of Analog ADC Block"]
61pub type ADCBIASPROG_R = crate::FieldReader<u8, ADCBIASPROG_A>;
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> = crate::FieldWriter<'a, u32, BIASPROG_SPEC, u8, ADCBIASPROG_A, 4, 0>;
109impl<'a> ADCBIASPROG_W<'a> {
110 #[doc = "Normal power (use for 1Msps operation)"]
111 #[inline(always)]
112 pub fn normal(self) -> &'a mut W {
113 self.variant(ADCBIASPROG_A::NORMAL)
114 }
115 #[doc = "Scaling bias to 1/2"]
116 #[inline(always)]
117 pub fn scale2(self) -> &'a mut W {
118 self.variant(ADCBIASPROG_A::SCALE2)
119 }
120 #[doc = "Scaling bias to 1/4"]
121 #[inline(always)]
122 pub fn scale4(self) -> &'a mut W {
123 self.variant(ADCBIASPROG_A::SCALE4)
124 }
125 #[doc = "Scaling bias to 1/8"]
126 #[inline(always)]
127 pub fn scale8(self) -> &'a mut W {
128 self.variant(ADCBIASPROG_A::SCALE8)
129 }
130 #[doc = "Scaling bias to 1/16"]
131 #[inline(always)]
132 pub fn scale16(self) -> &'a mut W {
133 self.variant(ADCBIASPROG_A::SCALE16)
134 }
135 #[doc = "Scaling bias to 1/32"]
136 #[inline(always)]
137 pub fn scale32(self) -> &'a mut W {
138 self.variant(ADCBIASPROG_A::SCALE32)
139 }
140}
141#[doc = "Field `VFAULTCLR` reader - Clear VREFOF Flag"]
142pub type VFAULTCLR_R = crate::BitReader<bool>;
143#[doc = "Field `VFAULTCLR` writer - Clear VREFOF Flag"]
144pub type VFAULTCLR_W<'a> = crate::BitWriter<'a, u32, BIASPROG_SPEC, bool, 12>;
145#[doc = "Field `GPBIASACC` reader - Accuracy Setting for the System Bias During ADC Operation"]
146pub type GPBIASACC_R = crate::BitReader<bool>;
147#[doc = "Field `GPBIASACC` writer - Accuracy Setting for the System Bias During ADC Operation"]
148pub type GPBIASACC_W<'a> = crate::BitWriter<'a, u32, BIASPROG_SPEC, bool, 16>;
149impl R {
150 #[doc = "Bits 0:3 - Bias Programming Value of Analog ADC Block"]
151 #[inline(always)]
152 pub fn adcbiasprog(&self) -> ADCBIASPROG_R {
153 ADCBIASPROG_R::new((self.bits & 0x0f) as u8)
154 }
155 #[doc = "Bit 12 - Clear VREFOF Flag"]
156 #[inline(always)]
157 pub fn vfaultclr(&self) -> VFAULTCLR_R {
158 VFAULTCLR_R::new(((self.bits >> 12) & 1) != 0)
159 }
160 #[doc = "Bit 16 - Accuracy Setting for the System Bias During ADC Operation"]
161 #[inline(always)]
162 pub fn gpbiasacc(&self) -> GPBIASACC_R {
163 GPBIASACC_R::new(((self.bits >> 16) & 1) != 0)
164 }
165}
166impl W {
167 #[doc = "Bits 0:3 - Bias Programming Value of Analog ADC Block"]
168 #[inline(always)]
169 pub fn adcbiasprog(&mut self) -> ADCBIASPROG_W {
170 ADCBIASPROG_W::new(self)
171 }
172 #[doc = "Bit 12 - Clear VREFOF Flag"]
173 #[inline(always)]
174 pub fn vfaultclr(&mut self) -> VFAULTCLR_W {
175 VFAULTCLR_W::new(self)
176 }
177 #[doc = "Bit 16 - Accuracy Setting for the System Bias During ADC Operation"]
178 #[inline(always)]
179 pub fn gpbiasacc(&mut self) -> GPBIASACC_W {
180 GPBIASACC_W::new(self)
181 }
182 #[doc = "Writes raw bits to the register."]
183 #[inline(always)]
184 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
185 self.0.bits(bits);
186 self
187 }
188}
189#[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"]
190pub struct BIASPROG_SPEC;
191impl crate::RegisterSpec for BIASPROG_SPEC {
192 type Ux = u32;
193}
194#[doc = "`read()` method returns [biasprog::R](R) reader structure"]
195impl crate::Readable for BIASPROG_SPEC {
196 type Reader = R;
197}
198#[doc = "`write(|w| ..)` method takes [biasprog::W](W) writer structure"]
199impl crate::Writable for BIASPROG_SPEC {
200 type Writer = W;
201}
202#[doc = "`reset()` method sets BIASPROG to value 0"]
203impl crate::Resettable for BIASPROG_SPEC {
204 #[inline(always)]
205 fn reset_value() -> Self::Ux {
206 0
207 }
208}