stm32wb_pac/comp/
comp1_csr.rs

1#[doc = "Reader of register COMP1_CSR"]
2pub type R = crate::R<u32, super::COMP1_CSR>;
3#[doc = "Writer for register COMP1_CSR"]
4pub type W = crate::W<u32, super::COMP1_CSR>;
5#[doc = "Register COMP1_CSR `reset()`'s with value 0"]
6impl crate::ResetValue for super::COMP1_CSR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `COMP1_EN`"]
14pub type COMP1_EN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `COMP1_EN`"]
16pub struct COMP1_EN_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> COMP1_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 `COMP1_PWRMODE`"]
38pub type COMP1_PWRMODE_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `COMP1_PWRMODE`"]
40pub struct COMP1_PWRMODE_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> COMP1_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 `COMP1_INMSEL`"]
52pub type COMP1_INMSEL_R = crate::R<u8, u8>;
53#[doc = "Write proxy for field `COMP1_INMSEL`"]
54pub struct COMP1_INMSEL_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> COMP1_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 & !(0x07 << 4)) | (((value as u32) & 0x07) << 4);
62        self.w
63    }
64}
65#[doc = "Reader of field `COMP1_INPSEL`"]
66pub type COMP1_INPSEL_R = crate::R<u8, u8>;
67#[doc = "Write proxy for field `COMP1_INPSEL`"]
68pub struct COMP1_INPSEL_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> COMP1_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 `COMP1_POLARITY`"]
80pub type COMP1_POLARITY_R = crate::R<bool, bool>;
81#[doc = "Write proxy for field `COMP1_POLARITY`"]
82pub struct COMP1_POLARITY_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> COMP1_POLARITY_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 << 15)) | (((value as u32) & 0x01) << 15);
100        self.w
101    }
102}
103#[doc = "Reader of field `COMP1_HYST`"]
104pub type COMP1_HYST_R = crate::R<u8, u8>;
105#[doc = "Write proxy for field `COMP1_HYST`"]
106pub struct COMP1_HYST_W<'a> {
107    w: &'a mut W,
108}
109impl<'a> COMP1_HYST_W<'a> {
110    #[doc = r"Writes raw bits to the field"]
111    #[inline(always)]
112    pub unsafe fn bits(self, value: u8) -> &'a mut W {
113        self.w.bits = (self.w.bits & !(0x03 << 16)) | (((value as u32) & 0x03) << 16);
114        self.w
115    }
116}
117#[doc = "Reader of field `COMP1_BLANKING`"]
118pub type COMP1_BLANKING_R = crate::R<u8, u8>;
119#[doc = "Write proxy for field `COMP1_BLANKING`"]
120pub struct COMP1_BLANKING_W<'a> {
121    w: &'a mut W,
122}
123impl<'a> COMP1_BLANKING_W<'a> {
124    #[doc = r"Writes raw bits to the field"]
125    #[inline(always)]
126    pub unsafe fn bits(self, value: u8) -> &'a mut W {
127        self.w.bits = (self.w.bits & !(0x07 << 18)) | (((value as u32) & 0x07) << 18);
128        self.w
129    }
130}
131#[doc = "Reader of field `COMP1_BRGEN`"]
132pub type COMP1_BRGEN_R = crate::R<bool, bool>;
133#[doc = "Write proxy for field `COMP1_BRGEN`"]
134pub struct COMP1_BRGEN_W<'a> {
135    w: &'a mut W,
136}
137impl<'a> COMP1_BRGEN_W<'a> {
138    #[doc = r"Sets the field bit"]
139    #[inline(always)]
140    pub fn set_bit(self) -> &'a mut W {
141        self.bit(true)
142    }
143    #[doc = r"Clears the field bit"]
144    #[inline(always)]
145    pub fn clear_bit(self) -> &'a mut W {
146        self.bit(false)
147    }
148    #[doc = r"Writes raw bits to the field"]
149    #[inline(always)]
150    pub fn bit(self, value: bool) -> &'a mut W {
151        self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22);
152        self.w
153    }
154}
155#[doc = "Reader of field `COMP1_SCALEN`"]
156pub type COMP1_SCALEN_R = crate::R<bool, bool>;
157#[doc = "Write proxy for field `COMP1_SCALEN`"]
158pub struct COMP1_SCALEN_W<'a> {
159    w: &'a mut W,
160}
161impl<'a> COMP1_SCALEN_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 << 23)) | (((value as u32) & 0x01) << 23);
176        self.w
177    }
178}
179#[doc = "Reader of field `COMP1_INMESEL`"]
180pub type COMP1_INMESEL_R = crate::R<u8, u8>;
181#[doc = "Write proxy for field `COMP1_INMESEL`"]
182pub struct COMP1_INMESEL_W<'a> {
183    w: &'a mut W,
184}
185impl<'a> COMP1_INMESEL_W<'a> {
186    #[doc = r"Writes raw bits to the field"]
187    #[inline(always)]
188    pub unsafe fn bits(self, value: u8) -> &'a mut W {
189        self.w.bits = (self.w.bits & !(0x03 << 25)) | (((value as u32) & 0x03) << 25);
190        self.w
191    }
192}
193#[doc = "Reader of field `COMP1_VALUE`"]
194pub type COMP1_VALUE_R = crate::R<bool, bool>;
195#[doc = "Reader of field `COMP1_LOCK`"]
196pub type COMP1_LOCK_R = crate::R<bool, bool>;
197#[doc = "Write proxy for field `COMP1_LOCK`"]
198pub struct COMP1_LOCK_W<'a> {
199    w: &'a mut W,
200}
201impl<'a> COMP1_LOCK_W<'a> {
202    #[doc = r"Sets the field bit"]
203    #[inline(always)]
204    pub fn set_bit(self) -> &'a mut W {
205        self.bit(true)
206    }
207    #[doc = r"Clears the field bit"]
208    #[inline(always)]
209    pub fn clear_bit(self) -> &'a mut W {
210        self.bit(false)
211    }
212    #[doc = r"Writes raw bits to the field"]
213    #[inline(always)]
214    pub fn bit(self, value: bool) -> &'a mut W {
215        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
216        self.w
217    }
218}
219impl R {
220    #[doc = "Bit 0 - Comparator enable"]
221    #[inline(always)]
222    pub fn comp1_en(&self) -> COMP1_EN_R {
223        COMP1_EN_R::new((self.bits & 0x01) != 0)
224    }
225    #[doc = "Bits 2:3 - Comparator power mode"]
226    #[inline(always)]
227    pub fn comp1_pwrmode(&self) -> COMP1_PWRMODE_R {
228        COMP1_PWRMODE_R::new(((self.bits >> 2) & 0x03) as u8)
229    }
230    #[doc = "Bits 4:6 - Comparator input minus selection"]
231    #[inline(always)]
232    pub fn comp1_inmsel(&self) -> COMP1_INMSEL_R {
233        COMP1_INMSEL_R::new(((self.bits >> 4) & 0x07) as u8)
234    }
235    #[doc = "Bits 7:8 - Comparator input plus selection"]
236    #[inline(always)]
237    pub fn comp1_inpsel(&self) -> COMP1_INPSEL_R {
238        COMP1_INPSEL_R::new(((self.bits >> 7) & 0x03) as u8)
239    }
240    #[doc = "Bit 15 - Comparator output polarity"]
241    #[inline(always)]
242    pub fn comp1_polarity(&self) -> COMP1_POLARITY_R {
243        COMP1_POLARITY_R::new(((self.bits >> 15) & 0x01) != 0)
244    }
245    #[doc = "Bits 16:17 - Comparator hysteresis"]
246    #[inline(always)]
247    pub fn comp1_hyst(&self) -> COMP1_HYST_R {
248        COMP1_HYST_R::new(((self.bits >> 16) & 0x03) as u8)
249    }
250    #[doc = "Bits 18:20 - Comparator blanking source"]
251    #[inline(always)]
252    pub fn comp1_blanking(&self) -> COMP1_BLANKING_R {
253        COMP1_BLANKING_R::new(((self.bits >> 18) & 0x07) as u8)
254    }
255    #[doc = "Bit 22 - Comparator voltage scaler enable"]
256    #[inline(always)]
257    pub fn comp1_brgen(&self) -> COMP1_BRGEN_R {
258        COMP1_BRGEN_R::new(((self.bits >> 22) & 0x01) != 0)
259    }
260    #[doc = "Bit 23 - Comparator scaler bridge enable"]
261    #[inline(always)]
262    pub fn comp1_scalen(&self) -> COMP1_SCALEN_R {
263        COMP1_SCALEN_R::new(((self.bits >> 23) & 0x01) != 0)
264    }
265    #[doc = "Bits 25:26 - Comparator input minus extended selection"]
266    #[inline(always)]
267    pub fn comp1_inmesel(&self) -> COMP1_INMESEL_R {
268        COMP1_INMESEL_R::new(((self.bits >> 25) & 0x03) as u8)
269    }
270    #[doc = "Bit 30 - Comparator output level"]
271    #[inline(always)]
272    pub fn comp1_value(&self) -> COMP1_VALUE_R {
273        COMP1_VALUE_R::new(((self.bits >> 30) & 0x01) != 0)
274    }
275    #[doc = "Bit 31 - Comparator lock"]
276    #[inline(always)]
277    pub fn comp1_lock(&self) -> COMP1_LOCK_R {
278        COMP1_LOCK_R::new(((self.bits >> 31) & 0x01) != 0)
279    }
280}
281impl W {
282    #[doc = "Bit 0 - Comparator enable"]
283    #[inline(always)]
284    pub fn comp1_en(&mut self) -> COMP1_EN_W {
285        COMP1_EN_W { w: self }
286    }
287    #[doc = "Bits 2:3 - Comparator power mode"]
288    #[inline(always)]
289    pub fn comp1_pwrmode(&mut self) -> COMP1_PWRMODE_W {
290        COMP1_PWRMODE_W { w: self }
291    }
292    #[doc = "Bits 4:6 - Comparator input minus selection"]
293    #[inline(always)]
294    pub fn comp1_inmsel(&mut self) -> COMP1_INMSEL_W {
295        COMP1_INMSEL_W { w: self }
296    }
297    #[doc = "Bits 7:8 - Comparator input plus selection"]
298    #[inline(always)]
299    pub fn comp1_inpsel(&mut self) -> COMP1_INPSEL_W {
300        COMP1_INPSEL_W { w: self }
301    }
302    #[doc = "Bit 15 - Comparator output polarity"]
303    #[inline(always)]
304    pub fn comp1_polarity(&mut self) -> COMP1_POLARITY_W {
305        COMP1_POLARITY_W { w: self }
306    }
307    #[doc = "Bits 16:17 - Comparator hysteresis"]
308    #[inline(always)]
309    pub fn comp1_hyst(&mut self) -> COMP1_HYST_W {
310        COMP1_HYST_W { w: self }
311    }
312    #[doc = "Bits 18:20 - Comparator blanking source"]
313    #[inline(always)]
314    pub fn comp1_blanking(&mut self) -> COMP1_BLANKING_W {
315        COMP1_BLANKING_W { w: self }
316    }
317    #[doc = "Bit 22 - Comparator voltage scaler enable"]
318    #[inline(always)]
319    pub fn comp1_brgen(&mut self) -> COMP1_BRGEN_W {
320        COMP1_BRGEN_W { w: self }
321    }
322    #[doc = "Bit 23 - Comparator scaler bridge enable"]
323    #[inline(always)]
324    pub fn comp1_scalen(&mut self) -> COMP1_SCALEN_W {
325        COMP1_SCALEN_W { w: self }
326    }
327    #[doc = "Bits 25:26 - Comparator input minus extended selection"]
328    #[inline(always)]
329    pub fn comp1_inmesel(&mut self) -> COMP1_INMESEL_W {
330        COMP1_INMESEL_W { w: self }
331    }
332    #[doc = "Bit 31 - Comparator lock"]
333    #[inline(always)]
334    pub fn comp1_lock(&mut self) -> COMP1_LOCK_W {
335        COMP1_LOCK_W { w: self }
336    }
337}