stm32l4x2_pac/vrefbuf/
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::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 ENVRR {
47    bits: bool,
48}
49impl ENVRR {
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 HIZR {
68    bits: bool,
69}
70impl HIZR {
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 VRSR {
89    bits: bool,
90}
91impl VRSR {
92    #[doc = r" Value of the field as raw bits"]
93    #[inline]
94    pub fn bit(&self) -> bool {
95        self.bits
96    }
97    #[doc = r" Returns `true` if the bit is clear (0)"]
98    #[inline]
99    pub fn bit_is_clear(&self) -> bool {
100        !self.bit()
101    }
102    #[doc = r" Returns `true` if the bit is set (1)"]
103    #[inline]
104    pub fn bit_is_set(&self) -> bool {
105        self.bit()
106    }
107}
108#[doc = r" Value of the field"]
109pub struct VRRR {
110    bits: bool,
111}
112impl VRRR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bit(&self) -> bool {
116        self.bits
117    }
118    #[doc = r" Returns `true` if the bit is clear (0)"]
119    #[inline]
120    pub fn bit_is_clear(&self) -> bool {
121        !self.bit()
122    }
123    #[doc = r" Returns `true` if the bit is set (1)"]
124    #[inline]
125    pub fn bit_is_set(&self) -> bool {
126        self.bit()
127    }
128}
129#[doc = r" Proxy"]
130pub struct _ENVRW<'a> {
131    w: &'a mut W,
132}
133impl<'a> _ENVRW<'a> {
134    #[doc = r" Sets the field bit"]
135    pub fn set_bit(self) -> &'a mut W {
136        self.bit(true)
137    }
138    #[doc = r" Clears the field bit"]
139    pub fn clear_bit(self) -> &'a mut W {
140        self.bit(false)
141    }
142    #[doc = r" Writes raw bits to the field"]
143    #[inline]
144    pub fn bit(self, value: bool) -> &'a mut W {
145        const MASK: bool = true;
146        const OFFSET: u8 = 0;
147        self.w.bits &= !((MASK as u32) << OFFSET);
148        self.w.bits |= ((value & MASK) as u32) << OFFSET;
149        self.w
150    }
151}
152#[doc = r" Proxy"]
153pub struct _HIZW<'a> {
154    w: &'a mut W,
155}
156impl<'a> _HIZW<'a> {
157    #[doc = r" Sets the field bit"]
158    pub fn set_bit(self) -> &'a mut W {
159        self.bit(true)
160    }
161    #[doc = r" Clears the field bit"]
162    pub fn clear_bit(self) -> &'a mut W {
163        self.bit(false)
164    }
165    #[doc = r" Writes raw bits to the field"]
166    #[inline]
167    pub fn bit(self, value: bool) -> &'a mut W {
168        const MASK: bool = true;
169        const OFFSET: u8 = 1;
170        self.w.bits &= !((MASK as u32) << OFFSET);
171        self.w.bits |= ((value & MASK) as u32) << OFFSET;
172        self.w
173    }
174}
175#[doc = r" Proxy"]
176pub struct _VRSW<'a> {
177    w: &'a mut W,
178}
179impl<'a> _VRSW<'a> {
180    #[doc = r" Sets the field bit"]
181    pub fn set_bit(self) -> &'a mut W {
182        self.bit(true)
183    }
184    #[doc = r" Clears the field bit"]
185    pub fn clear_bit(self) -> &'a mut W {
186        self.bit(false)
187    }
188    #[doc = r" Writes raw bits to the field"]
189    #[inline]
190    pub fn bit(self, value: bool) -> &'a mut W {
191        const MASK: bool = true;
192        const OFFSET: u8 = 2;
193        self.w.bits &= !((MASK as u32) << OFFSET);
194        self.w.bits |= ((value & MASK) as u32) << OFFSET;
195        self.w
196    }
197}
198impl R {
199    #[doc = r" Value of the register as raw bits"]
200    #[inline]
201    pub fn bits(&self) -> u32 {
202        self.bits
203    }
204    #[doc = "Bit 0 - Voltage reference buffer enable"]
205    #[inline]
206    pub fn envr(&self) -> ENVRR {
207        let bits = {
208            const MASK: bool = true;
209            const OFFSET: u8 = 0;
210            ((self.bits >> OFFSET) & MASK as u32) != 0
211        };
212        ENVRR { bits }
213    }
214    #[doc = "Bit 1 - High impedance mode"]
215    #[inline]
216    pub fn hiz(&self) -> HIZR {
217        let bits = {
218            const MASK: bool = true;
219            const OFFSET: u8 = 1;
220            ((self.bits >> OFFSET) & MASK as u32) != 0
221        };
222        HIZR { bits }
223    }
224    #[doc = "Bit 2 - Voltage reference scale"]
225    #[inline]
226    pub fn vrs(&self) -> VRSR {
227        let bits = {
228            const MASK: bool = true;
229            const OFFSET: u8 = 2;
230            ((self.bits >> OFFSET) & MASK as u32) != 0
231        };
232        VRSR { bits }
233    }
234    #[doc = "Bit 3 - Voltage reference buffer ready"]
235    #[inline]
236    pub fn vrr(&self) -> VRRR {
237        let bits = {
238            const MASK: bool = true;
239            const OFFSET: u8 = 3;
240            ((self.bits >> OFFSET) & MASK as u32) != 0
241        };
242        VRRR { bits }
243    }
244}
245impl W {
246    #[doc = r" Reset value of the register"]
247    #[inline]
248    pub fn reset_value() -> W {
249        W { bits: 2 }
250    }
251    #[doc = r" Writes raw bits to the register"]
252    #[inline]
253    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
254        self.bits = bits;
255        self
256    }
257    #[doc = "Bit 0 - Voltage reference buffer enable"]
258    #[inline]
259    pub fn envr(&mut self) -> _ENVRW {
260        _ENVRW { w: self }
261    }
262    #[doc = "Bit 1 - High impedance mode"]
263    #[inline]
264    pub fn hiz(&mut self) -> _HIZW {
265        _HIZW { w: self }
266    }
267    #[doc = "Bit 2 - Voltage reference scale"]
268    #[inline]
269    pub fn vrs(&mut self) -> _VRSW {
270        _VRSW { w: self }
271    }
272}