stm32l4x2_pac/opamp/
opamp2_csr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::OPAMP2_CSR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct OPAENR {
47    bits: bool,
48}
49impl OPAENR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bit(&self) -> bool {
53        self.bits
54    }
55    #[doc = r" Returns `true` if the bit is clear (0)"]
56    #[inline]
57    pub fn bit_is_clear(&self) -> bool {
58        !self.bit()
59    }
60    #[doc = r" Returns `true` if the bit is set (1)"]
61    #[inline]
62    pub fn bit_is_set(&self) -> bool {
63        self.bit()
64    }
65}
66#[doc = r" Value of the field"]
67pub struct OPALPMR {
68    bits: bool,
69}
70impl OPALPMR {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bit(&self) -> bool {
74        self.bits
75    }
76    #[doc = r" Returns `true` if the bit is clear (0)"]
77    #[inline]
78    pub fn bit_is_clear(&self) -> bool {
79        !self.bit()
80    }
81    #[doc = r" Returns `true` if the bit is set (1)"]
82    #[inline]
83    pub fn bit_is_set(&self) -> bool {
84        self.bit()
85    }
86}
87#[doc = r" Value of the field"]
88pub struct OPAMODER {
89    bits: u8,
90}
91impl OPAMODER {
92    #[doc = r" Value of the field as raw bits"]
93    #[inline]
94    pub fn bits(&self) -> u8 {
95        self.bits
96    }
97}
98#[doc = r" Value of the field"]
99pub struct PGA_GAINR {
100    bits: u8,
101}
102impl PGA_GAINR {
103    #[doc = r" Value of the field as raw bits"]
104    #[inline]
105    pub fn bits(&self) -> u8 {
106        self.bits
107    }
108}
109#[doc = r" Value of the field"]
110pub struct VM_SELR {
111    bits: u8,
112}
113impl VM_SELR {
114    #[doc = r" Value of the field as raw bits"]
115    #[inline]
116    pub fn bits(&self) -> u8 {
117        self.bits
118    }
119}
120#[doc = r" Value of the field"]
121pub struct VP_SELR {
122    bits: bool,
123}
124impl VP_SELR {
125    #[doc = r" Value of the field as raw bits"]
126    #[inline]
127    pub fn bit(&self) -> bool {
128        self.bits
129    }
130    #[doc = r" Returns `true` if the bit is clear (0)"]
131    #[inline]
132    pub fn bit_is_clear(&self) -> bool {
133        !self.bit()
134    }
135    #[doc = r" Returns `true` if the bit is set (1)"]
136    #[inline]
137    pub fn bit_is_set(&self) -> bool {
138        self.bit()
139    }
140}
141#[doc = r" Value of the field"]
142pub struct CALONR {
143    bits: bool,
144}
145impl CALONR {
146    #[doc = r" Value of the field as raw bits"]
147    #[inline]
148    pub fn bit(&self) -> bool {
149        self.bits
150    }
151    #[doc = r" Returns `true` if the bit is clear (0)"]
152    #[inline]
153    pub fn bit_is_clear(&self) -> bool {
154        !self.bit()
155    }
156    #[doc = r" Returns `true` if the bit is set (1)"]
157    #[inline]
158    pub fn bit_is_set(&self) -> bool {
159        self.bit()
160    }
161}
162#[doc = r" Value of the field"]
163pub struct CALSELR {
164    bits: bool,
165}
166impl CALSELR {
167    #[doc = r" Value of the field as raw bits"]
168    #[inline]
169    pub fn bit(&self) -> bool {
170        self.bits
171    }
172    #[doc = r" Returns `true` if the bit is clear (0)"]
173    #[inline]
174    pub fn bit_is_clear(&self) -> bool {
175        !self.bit()
176    }
177    #[doc = r" Returns `true` if the bit is set (1)"]
178    #[inline]
179    pub fn bit_is_set(&self) -> bool {
180        self.bit()
181    }
182}
183#[doc = r" Value of the field"]
184pub struct USERTRIMR {
185    bits: bool,
186}
187impl USERTRIMR {
188    #[doc = r" Value of the field as raw bits"]
189    #[inline]
190    pub fn bit(&self) -> bool {
191        self.bits
192    }
193    #[doc = r" Returns `true` if the bit is clear (0)"]
194    #[inline]
195    pub fn bit_is_clear(&self) -> bool {
196        !self.bit()
197    }
198    #[doc = r" Returns `true` if the bit is set (1)"]
199    #[inline]
200    pub fn bit_is_set(&self) -> bool {
201        self.bit()
202    }
203}
204#[doc = r" Value of the field"]
205pub struct CALOUTR {
206    bits: bool,
207}
208impl CALOUTR {
209    #[doc = r" Value of the field as raw bits"]
210    #[inline]
211    pub fn bit(&self) -> bool {
212        self.bits
213    }
214    #[doc = r" Returns `true` if the bit is clear (0)"]
215    #[inline]
216    pub fn bit_is_clear(&self) -> bool {
217        !self.bit()
218    }
219    #[doc = r" Returns `true` if the bit is set (1)"]
220    #[inline]
221    pub fn bit_is_set(&self) -> bool {
222        self.bit()
223    }
224}
225#[doc = r" Proxy"]
226pub struct _OPAENW<'a> {
227    w: &'a mut W,
228}
229impl<'a> _OPAENW<'a> {
230    #[doc = r" Sets the field bit"]
231    pub fn set_bit(self) -> &'a mut W {
232        self.bit(true)
233    }
234    #[doc = r" Clears the field bit"]
235    pub fn clear_bit(self) -> &'a mut W {
236        self.bit(false)
237    }
238    #[doc = r" Writes raw bits to the field"]
239    #[inline]
240    pub fn bit(self, value: bool) -> &'a mut W {
241        const MASK: bool = true;
242        const OFFSET: u8 = 0;
243        self.w.bits &= !((MASK as u32) << OFFSET);
244        self.w.bits |= ((value & MASK) as u32) << OFFSET;
245        self.w
246    }
247}
248#[doc = r" Proxy"]
249pub struct _OPALPMW<'a> {
250    w: &'a mut W,
251}
252impl<'a> _OPALPMW<'a> {
253    #[doc = r" Sets the field bit"]
254    pub fn set_bit(self) -> &'a mut W {
255        self.bit(true)
256    }
257    #[doc = r" Clears the field bit"]
258    pub fn clear_bit(self) -> &'a mut W {
259        self.bit(false)
260    }
261    #[doc = r" Writes raw bits to the field"]
262    #[inline]
263    pub fn bit(self, value: bool) -> &'a mut W {
264        const MASK: bool = true;
265        const OFFSET: u8 = 1;
266        self.w.bits &= !((MASK as u32) << OFFSET);
267        self.w.bits |= ((value & MASK) as u32) << OFFSET;
268        self.w
269    }
270}
271#[doc = r" Proxy"]
272pub struct _OPAMODEW<'a> {
273    w: &'a mut W,
274}
275impl<'a> _OPAMODEW<'a> {
276    #[doc = r" Writes raw bits to the field"]
277    #[inline]
278    pub unsafe fn bits(self, value: u8) -> &'a mut W {
279        const MASK: u8 = 3;
280        const OFFSET: u8 = 2;
281        self.w.bits &= !((MASK as u32) << OFFSET);
282        self.w.bits |= ((value & MASK) as u32) << OFFSET;
283        self.w
284    }
285}
286#[doc = r" Proxy"]
287pub struct _PGA_GAINW<'a> {
288    w: &'a mut W,
289}
290impl<'a> _PGA_GAINW<'a> {
291    #[doc = r" Writes raw bits to the field"]
292    #[inline]
293    pub unsafe fn bits(self, value: u8) -> &'a mut W {
294        const MASK: u8 = 3;
295        const OFFSET: u8 = 4;
296        self.w.bits &= !((MASK as u32) << OFFSET);
297        self.w.bits |= ((value & MASK) as u32) << OFFSET;
298        self.w
299    }
300}
301#[doc = r" Proxy"]
302pub struct _VM_SELW<'a> {
303    w: &'a mut W,
304}
305impl<'a> _VM_SELW<'a> {
306    #[doc = r" Writes raw bits to the field"]
307    #[inline]
308    pub unsafe fn bits(self, value: u8) -> &'a mut W {
309        const MASK: u8 = 3;
310        const OFFSET: u8 = 8;
311        self.w.bits &= !((MASK as u32) << OFFSET);
312        self.w.bits |= ((value & MASK) as u32) << OFFSET;
313        self.w
314    }
315}
316#[doc = r" Proxy"]
317pub struct _VP_SELW<'a> {
318    w: &'a mut W,
319}
320impl<'a> _VP_SELW<'a> {
321    #[doc = r" Sets the field bit"]
322    pub fn set_bit(self) -> &'a mut W {
323        self.bit(true)
324    }
325    #[doc = r" Clears the field bit"]
326    pub fn clear_bit(self) -> &'a mut W {
327        self.bit(false)
328    }
329    #[doc = r" Writes raw bits to the field"]
330    #[inline]
331    pub fn bit(self, value: bool) -> &'a mut W {
332        const MASK: bool = true;
333        const OFFSET: u8 = 10;
334        self.w.bits &= !((MASK as u32) << OFFSET);
335        self.w.bits |= ((value & MASK) as u32) << OFFSET;
336        self.w
337    }
338}
339#[doc = r" Proxy"]
340pub struct _CALONW<'a> {
341    w: &'a mut W,
342}
343impl<'a> _CALONW<'a> {
344    #[doc = r" Sets the field bit"]
345    pub fn set_bit(self) -> &'a mut W {
346        self.bit(true)
347    }
348    #[doc = r" Clears the field bit"]
349    pub fn clear_bit(self) -> &'a mut W {
350        self.bit(false)
351    }
352    #[doc = r" Writes raw bits to the field"]
353    #[inline]
354    pub fn bit(self, value: bool) -> &'a mut W {
355        const MASK: bool = true;
356        const OFFSET: u8 = 12;
357        self.w.bits &= !((MASK as u32) << OFFSET);
358        self.w.bits |= ((value & MASK) as u32) << OFFSET;
359        self.w
360    }
361}
362#[doc = r" Proxy"]
363pub struct _CALSELW<'a> {
364    w: &'a mut W,
365}
366impl<'a> _CALSELW<'a> {
367    #[doc = r" Sets the field bit"]
368    pub fn set_bit(self) -> &'a mut W {
369        self.bit(true)
370    }
371    #[doc = r" Clears the field bit"]
372    pub fn clear_bit(self) -> &'a mut W {
373        self.bit(false)
374    }
375    #[doc = r" Writes raw bits to the field"]
376    #[inline]
377    pub fn bit(self, value: bool) -> &'a mut W {
378        const MASK: bool = true;
379        const OFFSET: u8 = 13;
380        self.w.bits &= !((MASK as u32) << OFFSET);
381        self.w.bits |= ((value & MASK) as u32) << OFFSET;
382        self.w
383    }
384}
385#[doc = r" Proxy"]
386pub struct _USERTRIMW<'a> {
387    w: &'a mut W,
388}
389impl<'a> _USERTRIMW<'a> {
390    #[doc = r" Sets the field bit"]
391    pub fn set_bit(self) -> &'a mut W {
392        self.bit(true)
393    }
394    #[doc = r" Clears the field bit"]
395    pub fn clear_bit(self) -> &'a mut W {
396        self.bit(false)
397    }
398    #[doc = r" Writes raw bits to the field"]
399    #[inline]
400    pub fn bit(self, value: bool) -> &'a mut W {
401        const MASK: bool = true;
402        const OFFSET: u8 = 14;
403        self.w.bits &= !((MASK as u32) << OFFSET);
404        self.w.bits |= ((value & MASK) as u32) << OFFSET;
405        self.w
406    }
407}
408#[doc = r" Proxy"]
409pub struct _CALOUTW<'a> {
410    w: &'a mut W,
411}
412impl<'a> _CALOUTW<'a> {
413    #[doc = r" Sets the field bit"]
414    pub fn set_bit(self) -> &'a mut W {
415        self.bit(true)
416    }
417    #[doc = r" Clears the field bit"]
418    pub fn clear_bit(self) -> &'a mut W {
419        self.bit(false)
420    }
421    #[doc = r" Writes raw bits to the field"]
422    #[inline]
423    pub fn bit(self, value: bool) -> &'a mut W {
424        const MASK: bool = true;
425        const OFFSET: u8 = 15;
426        self.w.bits &= !((MASK as u32) << OFFSET);
427        self.w.bits |= ((value & MASK) as u32) << OFFSET;
428        self.w
429    }
430}
431impl R {
432    #[doc = r" Value of the register as raw bits"]
433    #[inline]
434    pub fn bits(&self) -> u32 {
435        self.bits
436    }
437    #[doc = "Bit 0 - Operational amplifier Enable"]
438    #[inline]
439    pub fn opaen(&self) -> OPAENR {
440        let bits = {
441            const MASK: bool = true;
442            const OFFSET: u8 = 0;
443            ((self.bits >> OFFSET) & MASK as u32) != 0
444        };
445        OPAENR { bits }
446    }
447    #[doc = "Bit 1 - Operational amplifier Low Power Mode"]
448    #[inline]
449    pub fn opalpm(&self) -> OPALPMR {
450        let bits = {
451            const MASK: bool = true;
452            const OFFSET: u8 = 1;
453            ((self.bits >> OFFSET) & MASK as u32) != 0
454        };
455        OPALPMR { bits }
456    }
457    #[doc = "Bits 2:3 - Operational amplifier PGA mode"]
458    #[inline]
459    pub fn opamode(&self) -> OPAMODER {
460        let bits = {
461            const MASK: u8 = 3;
462            const OFFSET: u8 = 2;
463            ((self.bits >> OFFSET) & MASK as u32) as u8
464        };
465        OPAMODER { bits }
466    }
467    #[doc = "Bits 4:5 - Operational amplifier Programmable amplifier gain value"]
468    #[inline]
469    pub fn pga_gain(&self) -> PGA_GAINR {
470        let bits = {
471            const MASK: u8 = 3;
472            const OFFSET: u8 = 4;
473            ((self.bits >> OFFSET) & MASK as u32) as u8
474        };
475        PGA_GAINR { bits }
476    }
477    #[doc = "Bits 8:9 - Inverting input selection"]
478    #[inline]
479    pub fn vm_sel(&self) -> VM_SELR {
480        let bits = {
481            const MASK: u8 = 3;
482            const OFFSET: u8 = 8;
483            ((self.bits >> OFFSET) & MASK as u32) as u8
484        };
485        VM_SELR { bits }
486    }
487    #[doc = "Bit 10 - Non inverted input selection"]
488    #[inline]
489    pub fn vp_sel(&self) -> VP_SELR {
490        let bits = {
491            const MASK: bool = true;
492            const OFFSET: u8 = 10;
493            ((self.bits >> OFFSET) & MASK as u32) != 0
494        };
495        VP_SELR { bits }
496    }
497    #[doc = "Bit 12 - Calibration mode enabled"]
498    #[inline]
499    pub fn calon(&self) -> CALONR {
500        let bits = {
501            const MASK: bool = true;
502            const OFFSET: u8 = 12;
503            ((self.bits >> OFFSET) & MASK as u32) != 0
504        };
505        CALONR { bits }
506    }
507    #[doc = "Bit 13 - Calibration selection"]
508    #[inline]
509    pub fn calsel(&self) -> CALSELR {
510        let bits = {
511            const MASK: bool = true;
512            const OFFSET: u8 = 13;
513            ((self.bits >> OFFSET) & MASK as u32) != 0
514        };
515        CALSELR { bits }
516    }
517    #[doc = "Bit 14 - allows to switch from AOP offset trimmed values to AOP offset"]
518    #[inline]
519    pub fn usertrim(&self) -> USERTRIMR {
520        let bits = {
521            const MASK: bool = true;
522            const OFFSET: u8 = 14;
523            ((self.bits >> OFFSET) & MASK as u32) != 0
524        };
525        USERTRIMR { bits }
526    }
527    #[doc = "Bit 15 - Operational amplifier calibration output"]
528    #[inline]
529    pub fn calout(&self) -> CALOUTR {
530        let bits = {
531            const MASK: bool = true;
532            const OFFSET: u8 = 15;
533            ((self.bits >> OFFSET) & MASK as u32) != 0
534        };
535        CALOUTR { bits }
536    }
537}
538impl W {
539    #[doc = r" Reset value of the register"]
540    #[inline]
541    pub fn reset_value() -> W {
542        W { bits: 0 }
543    }
544    #[doc = r" Writes raw bits to the register"]
545    #[inline]
546    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
547        self.bits = bits;
548        self
549    }
550    #[doc = "Bit 0 - Operational amplifier Enable"]
551    #[inline]
552    pub fn opaen(&mut self) -> _OPAENW {
553        _OPAENW { w: self }
554    }
555    #[doc = "Bit 1 - Operational amplifier Low Power Mode"]
556    #[inline]
557    pub fn opalpm(&mut self) -> _OPALPMW {
558        _OPALPMW { w: self }
559    }
560    #[doc = "Bits 2:3 - Operational amplifier PGA mode"]
561    #[inline]
562    pub fn opamode(&mut self) -> _OPAMODEW {
563        _OPAMODEW { w: self }
564    }
565    #[doc = "Bits 4:5 - Operational amplifier Programmable amplifier gain value"]
566    #[inline]
567    pub fn pga_gain(&mut self) -> _PGA_GAINW {
568        _PGA_GAINW { w: self }
569    }
570    #[doc = "Bits 8:9 - Inverting input selection"]
571    #[inline]
572    pub fn vm_sel(&mut self) -> _VM_SELW {
573        _VM_SELW { w: self }
574    }
575    #[doc = "Bit 10 - Non inverted input selection"]
576    #[inline]
577    pub fn vp_sel(&mut self) -> _VP_SELW {
578        _VP_SELW { w: self }
579    }
580    #[doc = "Bit 12 - Calibration mode enabled"]
581    #[inline]
582    pub fn calon(&mut self) -> _CALONW {
583        _CALONW { w: self }
584    }
585    #[doc = "Bit 13 - Calibration selection"]
586    #[inline]
587    pub fn calsel(&mut self) -> _CALSELW {
588        _CALSELW { w: self }
589    }
590    #[doc = "Bit 14 - allows to switch from AOP offset trimmed values to AOP offset"]
591    #[inline]
592    pub fn usertrim(&mut self) -> _USERTRIMW {
593        _USERTRIMW { w: self }
594    }
595    #[doc = "Bit 15 - Operational amplifier calibration output"]
596    #[inline]
597    pub fn calout(&mut self) -> _CALOUTW {
598        _CALOUTW { w: self }
599    }
600}