mcxa_pac/opamp0/
opamp_ctrl.rs1#[doc = "Register `OPAMP_CTRL` reader"]
2pub type R = crate::R<OpampCtrlSpec>;
3#[doc = "Register `OPAMP_CTRL` writer"]
4pub type W = crate::W<OpampCtrlSpec>;
5#[doc = "OPAMP Enable\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum OpaEn {
9 #[doc = "0: Disable"]
10 Disable = 0,
11 #[doc = "1: Enable"]
12 Enable = 1,
13}
14impl From<OpaEn> for bool {
15 #[inline(always)]
16 fn from(variant: OpaEn) -> Self {
17 variant as u8 != 0
18 }
19}
20#[doc = "Field `OPA_EN` reader - OPAMP Enable"]
21pub type OpaEnR = crate::BitReader<OpaEn>;
22impl OpaEnR {
23 #[doc = "Get enumerated values variant"]
24 #[inline(always)]
25 pub const fn variant(&self) -> OpaEn {
26 match self.bits {
27 false => OpaEn::Disable,
28 true => OpaEn::Enable,
29 }
30 }
31 #[doc = "Disable"]
32 #[inline(always)]
33 pub fn is_disable(&self) -> bool {
34 *self == OpaEn::Disable
35 }
36 #[doc = "Enable"]
37 #[inline(always)]
38 pub fn is_enable(&self) -> bool {
39 *self == OpaEn::Enable
40 }
41}
42#[doc = "Field `OPA_EN` writer - OPAMP Enable"]
43pub type OpaEnW<'a, REG> = crate::BitWriter<'a, REG, OpaEn>;
44impl<'a, REG> OpaEnW<'a, REG>
45where
46 REG: crate::Writable + crate::RegisterSpec,
47{
48 #[doc = "Disable"]
49 #[inline(always)]
50 pub fn disable(self) -> &'a mut crate::W<REG> {
51 self.variant(OpaEn::Disable)
52 }
53 #[doc = "Enable"]
54 #[inline(always)]
55 pub fn enable(self) -> &'a mut crate::W<REG> {
56 self.variant(OpaEn::Enable)
57 }
58}
59#[doc = "Compensation capcitor config selection\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62#[repr(u8)]
63pub enum OpaCcSel {
64 #[doc = "0: Fit 2X gains"]
65 Tbd1 = 0,
66 #[doc = "1: Fit 4X gains"]
67 Tbd2 = 1,
68 #[doc = "2: Fit 8X gains"]
69 Tbd3 = 2,
70 #[doc = "3: Fit 16X gains"]
71 Tbd4 = 3,
72}
73impl From<OpaCcSel> for u8 {
74 #[inline(always)]
75 fn from(variant: OpaCcSel) -> Self {
76 variant as _
77 }
78}
79impl crate::FieldSpec for OpaCcSel {
80 type Ux = u8;
81}
82impl crate::IsEnum for OpaCcSel {}
83#[doc = "Field `OPA_CC_SEL` reader - Compensation capcitor config selection"]
84pub type OpaCcSelR = crate::FieldReader<OpaCcSel>;
85impl OpaCcSelR {
86 #[doc = "Get enumerated values variant"]
87 #[inline(always)]
88 pub const fn variant(&self) -> OpaCcSel {
89 match self.bits {
90 0 => OpaCcSel::Tbd1,
91 1 => OpaCcSel::Tbd2,
92 2 => OpaCcSel::Tbd3,
93 3 => OpaCcSel::Tbd4,
94 _ => unreachable!(),
95 }
96 }
97 #[doc = "Fit 2X gains"]
98 #[inline(always)]
99 pub fn is_tbd1(&self) -> bool {
100 *self == OpaCcSel::Tbd1
101 }
102 #[doc = "Fit 4X gains"]
103 #[inline(always)]
104 pub fn is_tbd2(&self) -> bool {
105 *self == OpaCcSel::Tbd2
106 }
107 #[doc = "Fit 8X gains"]
108 #[inline(always)]
109 pub fn is_tbd3(&self) -> bool {
110 *self == OpaCcSel::Tbd3
111 }
112 #[doc = "Fit 16X gains"]
113 #[inline(always)]
114 pub fn is_tbd4(&self) -> bool {
115 *self == OpaCcSel::Tbd4
116 }
117}
118#[doc = "Field `OPA_CC_SEL` writer - Compensation capcitor config selection"]
119pub type OpaCcSelW<'a, REG> = crate::FieldWriter<'a, REG, 2, OpaCcSel, crate::Safe>;
120impl<'a, REG> OpaCcSelW<'a, REG>
121where
122 REG: crate::Writable + crate::RegisterSpec,
123 REG::Ux: From<u8>,
124{
125 #[doc = "Fit 2X gains"]
126 #[inline(always)]
127 pub fn tbd1(self) -> &'a mut crate::W<REG> {
128 self.variant(OpaCcSel::Tbd1)
129 }
130 #[doc = "Fit 4X gains"]
131 #[inline(always)]
132 pub fn tbd2(self) -> &'a mut crate::W<REG> {
133 self.variant(OpaCcSel::Tbd2)
134 }
135 #[doc = "Fit 8X gains"]
136 #[inline(always)]
137 pub fn tbd3(self) -> &'a mut crate::W<REG> {
138 self.variant(OpaCcSel::Tbd3)
139 }
140 #[doc = "Fit 16X gains"]
141 #[inline(always)]
142 pub fn tbd4(self) -> &'a mut crate::W<REG> {
143 self.variant(OpaCcSel::Tbd4)
144 }
145}
146#[doc = "Bias current config selection\n\nValue on reset: 0"]
147#[cfg_attr(feature = "defmt", derive(defmt::Format))]
148#[derive(Clone, Copy, Debug, PartialEq, Eq)]
149#[repr(u8)]
150pub enum OpaBcSel {
151 #[doc = "0: Default value. Keep power consumption constant"]
152 Tbd1 = 0,
153 #[doc = "1: Reduce power consumption to 1/4"]
154 Tbd2 = 1,
155 #[doc = "2: Reduce power consumption to 1/2"]
156 Tbd3 = 2,
157 #[doc = "3: Double the power consumption"]
158 Tbd4 = 3,
159}
160impl From<OpaBcSel> for u8 {
161 #[inline(always)]
162 fn from(variant: OpaBcSel) -> Self {
163 variant as _
164 }
165}
166impl crate::FieldSpec for OpaBcSel {
167 type Ux = u8;
168}
169impl crate::IsEnum for OpaBcSel {}
170#[doc = "Field `OPA_BC_SEL` reader - Bias current config selection"]
171pub type OpaBcSelR = crate::FieldReader<OpaBcSel>;
172impl OpaBcSelR {
173 #[doc = "Get enumerated values variant"]
174 #[inline(always)]
175 pub const fn variant(&self) -> OpaBcSel {
176 match self.bits {
177 0 => OpaBcSel::Tbd1,
178 1 => OpaBcSel::Tbd2,
179 2 => OpaBcSel::Tbd3,
180 3 => OpaBcSel::Tbd4,
181 _ => unreachable!(),
182 }
183 }
184 #[doc = "Default value. Keep power consumption constant"]
185 #[inline(always)]
186 pub fn is_tbd1(&self) -> bool {
187 *self == OpaBcSel::Tbd1
188 }
189 #[doc = "Reduce power consumption to 1/4"]
190 #[inline(always)]
191 pub fn is_tbd2(&self) -> bool {
192 *self == OpaBcSel::Tbd2
193 }
194 #[doc = "Reduce power consumption to 1/2"]
195 #[inline(always)]
196 pub fn is_tbd3(&self) -> bool {
197 *self == OpaBcSel::Tbd3
198 }
199 #[doc = "Double the power consumption"]
200 #[inline(always)]
201 pub fn is_tbd4(&self) -> bool {
202 *self == OpaBcSel::Tbd4
203 }
204}
205#[doc = "Field `OPA_BC_SEL` writer - Bias current config selection"]
206pub type OpaBcSelW<'a, REG> = crate::FieldWriter<'a, REG, 2, OpaBcSel, crate::Safe>;
207impl<'a, REG> OpaBcSelW<'a, REG>
208where
209 REG: crate::Writable + crate::RegisterSpec,
210 REG::Ux: From<u8>,
211{
212 #[doc = "Default value. Keep power consumption constant"]
213 #[inline(always)]
214 pub fn tbd1(self) -> &'a mut crate::W<REG> {
215 self.variant(OpaBcSel::Tbd1)
216 }
217 #[doc = "Reduce power consumption to 1/4"]
218 #[inline(always)]
219 pub fn tbd2(self) -> &'a mut crate::W<REG> {
220 self.variant(OpaBcSel::Tbd2)
221 }
222 #[doc = "Reduce power consumption to 1/2"]
223 #[inline(always)]
224 pub fn tbd3(self) -> &'a mut crate::W<REG> {
225 self.variant(OpaBcSel::Tbd3)
226 }
227 #[doc = "Double the power consumption"]
228 #[inline(always)]
229 pub fn tbd4(self) -> &'a mut crate::W<REG> {
230 self.variant(OpaBcSel::Tbd4)
231 }
232}
233impl R {
234 #[doc = "Bit 0 - OPAMP Enable"]
235 #[inline(always)]
236 pub fn opa_en(&self) -> OpaEnR {
237 OpaEnR::new((self.bits & 1) != 0)
238 }
239 #[doc = "Bits 4:5 - Compensation capcitor config selection"]
240 #[inline(always)]
241 pub fn opa_cc_sel(&self) -> OpaCcSelR {
242 OpaCcSelR::new(((self.bits >> 4) & 3) as u8)
243 }
244 #[doc = "Bits 6:7 - Bias current config selection"]
245 #[inline(always)]
246 pub fn opa_bc_sel(&self) -> OpaBcSelR {
247 OpaBcSelR::new(((self.bits >> 6) & 3) as u8)
248 }
249}
250#[cfg(feature = "debug")]
251impl core::fmt::Debug for R {
252 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
253 f.debug_struct("OPAMP_CTRL")
254 .field("opa_en", &self.opa_en())
255 .field("opa_cc_sel", &self.opa_cc_sel())
256 .field("opa_bc_sel", &self.opa_bc_sel())
257 .finish()
258 }
259}
260impl W {
261 #[doc = "Bit 0 - OPAMP Enable"]
262 #[inline(always)]
263 pub fn opa_en(&mut self) -> OpaEnW<'_, OpampCtrlSpec> {
264 OpaEnW::new(self, 0)
265 }
266 #[doc = "Bits 4:5 - Compensation capcitor config selection"]
267 #[inline(always)]
268 pub fn opa_cc_sel(&mut self) -> OpaCcSelW<'_, OpampCtrlSpec> {
269 OpaCcSelW::new(self, 4)
270 }
271 #[doc = "Bits 6:7 - Bias current config selection"]
272 #[inline(always)]
273 pub fn opa_bc_sel(&mut self) -> OpaBcSelW<'_, OpampCtrlSpec> {
274 OpaBcSelW::new(self, 6)
275 }
276}
277#[doc = "OPAMP Control\n\nYou can [`read`](crate::Reg::read) this register and get [`opamp_ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`opamp_ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
278pub struct OpampCtrlSpec;
279impl crate::RegisterSpec for OpampCtrlSpec {
280 type Ux = u32;
281}
282#[doc = "`read()` method returns [`opamp_ctrl::R`](R) reader structure"]
283impl crate::Readable for OpampCtrlSpec {}
284#[doc = "`write(|w| ..)` method takes [`opamp_ctrl::W`](W) writer structure"]
285impl crate::Writable for OpampCtrlSpec {
286 type Safety = crate::Unsafe;
287}
288#[doc = "`reset()` method sets OPAMP_CTRL to value 0"]
289impl crate::Resettable for OpampCtrlSpec {}