stm32l4x2_pac/adc/
ofr3.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::OFR3 {
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 OFFSET3_ENR {
47    bits: bool,
48}
49impl OFFSET3_ENR {
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 OFFSET3_CHR {
68    bits: u8,
69}
70impl OFFSET3_CHR {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bits(&self) -> u8 {
74        self.bits
75    }
76}
77#[doc = r" Value of the field"]
78pub struct OFFSET3R {
79    bits: u16,
80}
81impl OFFSET3R {
82    #[doc = r" Value of the field as raw bits"]
83    #[inline]
84    pub fn bits(&self) -> u16 {
85        self.bits
86    }
87}
88#[doc = r" Proxy"]
89pub struct _OFFSET3_ENW<'a> {
90    w: &'a mut W,
91}
92impl<'a> _OFFSET3_ENW<'a> {
93    #[doc = r" Sets the field bit"]
94    pub fn set_bit(self) -> &'a mut W {
95        self.bit(true)
96    }
97    #[doc = r" Clears the field bit"]
98    pub fn clear_bit(self) -> &'a mut W {
99        self.bit(false)
100    }
101    #[doc = r" Writes raw bits to the field"]
102    #[inline]
103    pub fn bit(self, value: bool) -> &'a mut W {
104        const MASK: bool = true;
105        const OFFSET: u8 = 31;
106        self.w.bits &= !((MASK as u32) << OFFSET);
107        self.w.bits |= ((value & MASK) as u32) << OFFSET;
108        self.w
109    }
110}
111#[doc = r" Proxy"]
112pub struct _OFFSET3_CHW<'a> {
113    w: &'a mut W,
114}
115impl<'a> _OFFSET3_CHW<'a> {
116    #[doc = r" Writes raw bits to the field"]
117    #[inline]
118    pub unsafe fn bits(self, value: u8) -> &'a mut W {
119        const MASK: u8 = 31;
120        const OFFSET: u8 = 26;
121        self.w.bits &= !((MASK as u32) << OFFSET);
122        self.w.bits |= ((value & MASK) as u32) << OFFSET;
123        self.w
124    }
125}
126#[doc = r" Proxy"]
127pub struct _OFFSET3W<'a> {
128    w: &'a mut W,
129}
130impl<'a> _OFFSET3W<'a> {
131    #[doc = r" Writes raw bits to the field"]
132    #[inline]
133    pub unsafe fn bits(self, value: u16) -> &'a mut W {
134        const MASK: u16 = 4095;
135        const OFFSET: u8 = 0;
136        self.w.bits &= !((MASK as u32) << OFFSET);
137        self.w.bits |= ((value & MASK) as u32) << OFFSET;
138        self.w
139    }
140}
141impl R {
142    #[doc = r" Value of the register as raw bits"]
143    #[inline]
144    pub fn bits(&self) -> u32 {
145        self.bits
146    }
147    #[doc = "Bit 31 - OFFSET3_EN"]
148    #[inline]
149    pub fn offset3_en(&self) -> OFFSET3_ENR {
150        let bits = {
151            const MASK: bool = true;
152            const OFFSET: u8 = 31;
153            ((self.bits >> OFFSET) & MASK as u32) != 0
154        };
155        OFFSET3_ENR { bits }
156    }
157    #[doc = "Bits 26:30 - OFFSET3_CH"]
158    #[inline]
159    pub fn offset3_ch(&self) -> OFFSET3_CHR {
160        let bits = {
161            const MASK: u8 = 31;
162            const OFFSET: u8 = 26;
163            ((self.bits >> OFFSET) & MASK as u32) as u8
164        };
165        OFFSET3_CHR { bits }
166    }
167    #[doc = "Bits 0:11 - OFFSET3"]
168    #[inline]
169    pub fn offset3(&self) -> OFFSET3R {
170        let bits = {
171            const MASK: u16 = 4095;
172            const OFFSET: u8 = 0;
173            ((self.bits >> OFFSET) & MASK as u32) as u16
174        };
175        OFFSET3R { bits }
176    }
177}
178impl W {
179    #[doc = r" Reset value of the register"]
180    #[inline]
181    pub fn reset_value() -> W {
182        W { bits: 0 }
183    }
184    #[doc = r" Writes raw bits to the register"]
185    #[inline]
186    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
187        self.bits = bits;
188        self
189    }
190    #[doc = "Bit 31 - OFFSET3_EN"]
191    #[inline]
192    pub fn offset3_en(&mut self) -> _OFFSET3_ENW {
193        _OFFSET3_ENW { w: self }
194    }
195    #[doc = "Bits 26:30 - OFFSET3_CH"]
196    #[inline]
197    pub fn offset3_ch(&mut self) -> _OFFSET3_CHW {
198        _OFFSET3_CHW { w: self }
199    }
200    #[doc = "Bits 0:11 - OFFSET3"]
201    #[inline]
202    pub fn offset3(&mut self) -> _OFFSET3W {
203        _OFFSET3W { w: self }
204    }
205}