stm32wb_pac/comp/
comp2_csr.rs

1#[doc = "Reader of register COMP2_CSR"]
2pub type R = crate::R<u32, super::COMP2_CSR>;
3#[doc = "Writer for register COMP2_CSR"]
4pub type W = crate::W<u32, super::COMP2_CSR>;
5#[doc = "Register COMP2_CSR `reset()`'s with value 0"]
6impl crate::ResetValue for super::COMP2_CSR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `COMP2_EN`"]
14pub type COMP2_EN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `COMP2_EN`"]
16pub struct COMP2_EN_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> COMP2_EN_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `COMP2_PWRMODE`"]
38pub type COMP2_PWRMODE_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `COMP2_PWRMODE`"]
40pub struct COMP2_PWRMODE_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> COMP2_PWRMODE_W<'a> {
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub unsafe fn bits(self, value: u8) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u32) & 0x03) << 2);
48        self.w
49    }
50}
51#[doc = "Reader of field `COMP2_INMSEL`"]
52pub type COMP2_INMSEL_R = crate::R<u8, u8>;
53#[doc = "Write proxy for field `COMP2_INMSEL`"]
54pub struct COMP2_INMSEL_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> COMP2_INMSEL_W<'a> {
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub unsafe fn bits(self, value: u8) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
62        self.w
63    }
64}
65#[doc = "Reader of field `COMP2_INPSEL`"]
66pub type COMP2_INPSEL_R = crate::R<u8, u8>;
67#[doc = "Write proxy for field `COMP2_INPSEL`"]
68pub struct COMP2_INPSEL_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> COMP2_INPSEL_W<'a> {
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u8) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x03 << 7)) | (((value as u32) & 0x03) << 7);
76        self.w
77    }
78}
79#[doc = "Reader of field `COMP2_WINMODE`"]
80pub type COMP2_WINMODE_R = crate::R<bool, bool>;
81#[doc = "Write proxy for field `COMP2_WINMODE`"]
82pub struct COMP2_WINMODE_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> COMP2_WINMODE_W<'a> {
86    #[doc = r"Sets the field bit"]
87    #[inline(always)]
88    pub fn set_bit(self) -> &'a mut W {
89        self.bit(true)
90    }
91    #[doc = r"Clears the field bit"]
92    #[inline(always)]
93    pub fn clear_bit(self) -> &'a mut W {
94        self.bit(false)
95    }
96    #[doc = r"Writes raw bits to the field"]
97    #[inline(always)]
98    pub fn bit(self, value: bool) -> &'a mut W {
99        self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
100        self.w
101    }
102}
103#[doc = "Reader of field `COMP2_POLARITY`"]
104pub type COMP2_POLARITY_R = crate::R<bool, bool>;
105#[doc = "Write proxy for field `COMP2_POLARITY`"]
106pub struct COMP2_POLARITY_W<'a> {
107    w: &'a mut W,
108}
109impl<'a> COMP2_POLARITY_W<'a> {
110    #[doc = r"Sets the field bit"]
111    #[inline(always)]
112    pub fn set_bit(self) -> &'a mut W {
113        self.bit(true)
114    }
115    #[doc = r"Clears the field bit"]
116    #[inline(always)]
117    pub fn clear_bit(self) -> &'a mut W {
118        self.bit(false)
119    }
120    #[doc = r"Writes raw bits to the field"]
121    #[inline(always)]
122    pub fn bit(self, value: bool) -> &'a mut W {
123        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
124        self.w
125    }
126}
127#[doc = "Reader of field `COMP2_HYST`"]
128pub type COMP2_HYST_R = crate::R<u8, u8>;
129#[doc = "Write proxy for field `COMP2_HYST`"]
130pub struct COMP2_HYST_W<'a> {
131    w: &'a mut W,
132}
133impl<'a> COMP2_HYST_W<'a> {
134    #[doc = r"Writes raw bits to the field"]
135    #[inline(always)]
136    pub unsafe fn bits(self, value: u8) -> &'a mut W {
137        self.w.bits = (self.w.bits & !(0x03 << 16)) | (((value as u32) & 0x03) << 16);
138        self.w
139    }
140}
141#[doc = "Reader of field `COMP2_BLANKING`"]
142pub type COMP2_BLANKING_R = crate::R<u8, u8>;
143#[doc = "Write proxy for field `COMP2_BLANKING`"]
144pub struct COMP2_BLANKING_W<'a> {
145    w: &'a mut W,
146}
147impl<'a> COMP2_BLANKING_W<'a> {
148    #[doc = r"Writes raw bits to the field"]
149    #[inline(always)]
150    pub unsafe fn bits(self, value: u8) -> &'a mut W {
151        self.w.bits = (self.w.bits & !(0x07 << 18)) | (((value as u32) & 0x07) << 18);
152        self.w
153    }
154}
155#[doc = "Reader of field `COMP2_BRGEN`"]
156pub type COMP2_BRGEN_R = crate::R<bool, bool>;
157#[doc = "Write proxy for field `COMP2_BRGEN`"]
158pub struct COMP2_BRGEN_W<'a> {
159    w: &'a mut W,
160}
161impl<'a> COMP2_BRGEN_W<'a> {
162    #[doc = r"Sets the field bit"]
163    #[inline(always)]
164    pub fn set_bit(self) -> &'a mut W {
165        self.bit(true)
166    }
167    #[doc = r"Clears the field bit"]
168    #[inline(always)]
169    pub fn clear_bit(self) -> &'a mut W {
170        self.bit(false)
171    }
172    #[doc = r"Writes raw bits to the field"]
173    #[inline(always)]
174    pub fn bit(self, value: bool) -> &'a mut W {
175        self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22);
176        self.w
177    }
178}
179#[doc = "Reader of field `COMP2_SCALEN`"]
180pub type COMP2_SCALEN_R = crate::R<bool, bool>;
181#[doc = "Write proxy for field `COMP2_SCALEN`"]
182pub struct COMP2_SCALEN_W<'a> {
183    w: &'a mut W,
184}
185impl<'a> COMP2_SCALEN_W<'a> {
186    #[doc = r"Sets the field bit"]
187    #[inline(always)]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r"Clears the field bit"]
192    #[inline(always)]
193    pub fn clear_bit(self) -> &'a mut W {
194        self.bit(false)
195    }
196    #[doc = r"Writes raw bits to the field"]
197    #[inline(always)]
198    pub fn bit(self, value: bool) -> &'a mut W {
199        self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23);
200        self.w
201    }
202}
203#[doc = "Reader of field `COMP2_INMESEL`"]
204pub type COMP2_INMESEL_R = crate::R<u8, u8>;
205#[doc = "Write proxy for field `COMP2_INMESEL`"]
206pub struct COMP2_INMESEL_W<'a> {
207    w: &'a mut W,
208}
209impl<'a> COMP2_INMESEL_W<'a> {
210    #[doc = r"Writes raw bits to the field"]
211    #[inline(always)]
212    pub unsafe fn bits(self, value: u8) -> &'a mut W {
213        self.w.bits = (self.w.bits & !(0x03 << 25)) | (((value as u32) & 0x03) << 25);
214        self.w
215    }
216}
217#[doc = "Reader of field `COMP2_VALUE`"]
218pub type COMP2_VALUE_R = crate::R<bool, bool>;
219#[doc = "Reader of field `COMP2_LOCK`"]
220pub type COMP2_LOCK_R = crate::R<bool, bool>;
221#[doc = "Write proxy for field `COMP2_LOCK`"]
222pub struct COMP2_LOCK_W<'a> {
223    w: &'a mut W,
224}
225impl<'a> COMP2_LOCK_W<'a> {
226    #[doc = r"Sets the field bit"]
227    #[inline(always)]
228    pub fn set_bit(self) -> &'a mut W {
229        self.bit(true)
230    }
231    #[doc = r"Clears the field bit"]
232    #[inline(always)]
233    pub fn clear_bit(self) -> &'a mut W {
234        self.bit(false)
235    }
236    #[doc = r"Writes raw bits to the field"]
237    #[inline(always)]
238    pub fn bit(self, value: bool) -> &'a mut W {
239        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
240        self.w
241    }
242}
243impl R {
244    #[doc = "Bit 0 - Comparator 2 enable bit"]
245    #[inline(always)]
246    pub fn comp2_en(&self) -> COMP2_EN_R {
247        COMP2_EN_R::new((self.bits & 0x01) != 0)
248    }
249    #[doc = "Bits 2:3 - Power Mode of the comparator 2"]
250    #[inline(always)]
251    pub fn comp2_pwrmode(&self) -> COMP2_PWRMODE_R {
252        COMP2_PWRMODE_R::new(((self.bits >> 2) & 0x03) as u8)
253    }
254    #[doc = "Bits 4:5 - Comparator 2 input minus selection bits"]
255    #[inline(always)]
256    pub fn comp2_inmsel(&self) -> COMP2_INMSEL_R {
257        COMP2_INMSEL_R::new(((self.bits >> 4) & 0x03) as u8)
258    }
259    #[doc = "Bits 7:8 - Comparator 1 input plus selection bit"]
260    #[inline(always)]
261    pub fn comp2_inpsel(&self) -> COMP2_INPSEL_R {
262        COMP2_INPSEL_R::new(((self.bits >> 7) & 0x03) as u8)
263    }
264    #[doc = "Bit 9 - Windows mode selection bit"]
265    #[inline(always)]
266    pub fn comp2_winmode(&self) -> COMP2_WINMODE_R {
267        COMP2_WINMODE_R::new(((self.bits >> 9) & 0x01) != 0)
268    }
269    #[doc = "Bit 15 - Comparator 2 polarity selection bit"]
270    #[inline(always)]
271    pub fn comp2_polarity(&self) -> COMP2_POLARITY_R {
272        COMP2_POLARITY_R::new(((self.bits >> 15) & 0x01) != 0)
273    }
274    #[doc = "Bits 16:17 - Comparator 2 hysteresis selection bits"]
275    #[inline(always)]
276    pub fn comp2_hyst(&self) -> COMP2_HYST_R {
277        COMP2_HYST_R::new(((self.bits >> 16) & 0x03) as u8)
278    }
279    #[doc = "Bits 18:20 - Comparator 2 blanking source selection bits"]
280    #[inline(always)]
281    pub fn comp2_blanking(&self) -> COMP2_BLANKING_R {
282        COMP2_BLANKING_R::new(((self.bits >> 18) & 0x07) as u8)
283    }
284    #[doc = "Bit 22 - Scaler bridge enable"]
285    #[inline(always)]
286    pub fn comp2_brgen(&self) -> COMP2_BRGEN_R {
287        COMP2_BRGEN_R::new(((self.bits >> 22) & 0x01) != 0)
288    }
289    #[doc = "Bit 23 - Voltage scaler enable bit"]
290    #[inline(always)]
291    pub fn comp2_scalen(&self) -> COMP2_SCALEN_R {
292        COMP2_SCALEN_R::new(((self.bits >> 23) & 0x01) != 0)
293    }
294    #[doc = "Bits 25:26 - comparator 2 input minus extended selection bits."]
295    #[inline(always)]
296    pub fn comp2_inmesel(&self) -> COMP2_INMESEL_R {
297        COMP2_INMESEL_R::new(((self.bits >> 25) & 0x03) as u8)
298    }
299    #[doc = "Bit 30 - Comparator 2 output status bit"]
300    #[inline(always)]
301    pub fn comp2_value(&self) -> COMP2_VALUE_R {
302        COMP2_VALUE_R::new(((self.bits >> 30) & 0x01) != 0)
303    }
304    #[doc = "Bit 31 - CSR register lock bit"]
305    #[inline(always)]
306    pub fn comp2_lock(&self) -> COMP2_LOCK_R {
307        COMP2_LOCK_R::new(((self.bits >> 31) & 0x01) != 0)
308    }
309}
310impl W {
311    #[doc = "Bit 0 - Comparator 2 enable bit"]
312    #[inline(always)]
313    pub fn comp2_en(&mut self) -> COMP2_EN_W {
314        COMP2_EN_W { w: self }
315    }
316    #[doc = "Bits 2:3 - Power Mode of the comparator 2"]
317    #[inline(always)]
318    pub fn comp2_pwrmode(&mut self) -> COMP2_PWRMODE_W {
319        COMP2_PWRMODE_W { w: self }
320    }
321    #[doc = "Bits 4:5 - Comparator 2 input minus selection bits"]
322    #[inline(always)]
323    pub fn comp2_inmsel(&mut self) -> COMP2_INMSEL_W {
324        COMP2_INMSEL_W { w: self }
325    }
326    #[doc = "Bits 7:8 - Comparator 1 input plus selection bit"]
327    #[inline(always)]
328    pub fn comp2_inpsel(&mut self) -> COMP2_INPSEL_W {
329        COMP2_INPSEL_W { w: self }
330    }
331    #[doc = "Bit 9 - Windows mode selection bit"]
332    #[inline(always)]
333    pub fn comp2_winmode(&mut self) -> COMP2_WINMODE_W {
334        COMP2_WINMODE_W { w: self }
335    }
336    #[doc = "Bit 15 - Comparator 2 polarity selection bit"]
337    #[inline(always)]
338    pub fn comp2_polarity(&mut self) -> COMP2_POLARITY_W {
339        COMP2_POLARITY_W { w: self }
340    }
341    #[doc = "Bits 16:17 - Comparator 2 hysteresis selection bits"]
342    #[inline(always)]
343    pub fn comp2_hyst(&mut self) -> COMP2_HYST_W {
344        COMP2_HYST_W { w: self }
345    }
346    #[doc = "Bits 18:20 - Comparator 2 blanking source selection bits"]
347    #[inline(always)]
348    pub fn comp2_blanking(&mut self) -> COMP2_BLANKING_W {
349        COMP2_BLANKING_W { w: self }
350    }
351    #[doc = "Bit 22 - Scaler bridge enable"]
352    #[inline(always)]
353    pub fn comp2_brgen(&mut self) -> COMP2_BRGEN_W {
354        COMP2_BRGEN_W { w: self }
355    }
356    #[doc = "Bit 23 - Voltage scaler enable bit"]
357    #[inline(always)]
358    pub fn comp2_scalen(&mut self) -> COMP2_SCALEN_W {
359        COMP2_SCALEN_W { w: self }
360    }
361    #[doc = "Bits 25:26 - comparator 2 input minus extended selection bits."]
362    #[inline(always)]
363    pub fn comp2_inmesel(&mut self) -> COMP2_INMESEL_W {
364        COMP2_INMESEL_W { w: self }
365    }
366    #[doc = "Bit 31 - CSR register lock bit"]
367    #[inline(always)]
368    pub fn comp2_lock(&mut self) -> COMP2_LOCK_W {
369        COMP2_LOCK_W { w: self }
370    }
371}