stm32l4x2_pac/comp/
comp1_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::COMP1_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 COMP1_ENR {
47    bits: bool,
48}
49impl COMP1_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 COMP1_PWRMODER {
68    bits: u8,
69}
70impl COMP1_PWRMODER {
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 COMP1_INMSELR {
79    bits: u8,
80}
81impl COMP1_INMSELR {
82    #[doc = r" Value of the field as raw bits"]
83    #[inline]
84    pub fn bits(&self) -> u8 {
85        self.bits
86    }
87}
88#[doc = r" Value of the field"]
89pub struct COMP1_INPSELR {
90    bits: u8,
91}
92impl COMP1_INPSELR {
93    #[doc = r" Value of the field as raw bits"]
94    #[inline]
95    pub fn bits(&self) -> u8 {
96        self.bits
97    }
98}
99#[doc = r" Value of the field"]
100pub struct COMP1_POLARITYR {
101    bits: bool,
102}
103impl COMP1_POLARITYR {
104    #[doc = r" Value of the field as raw bits"]
105    #[inline]
106    pub fn bit(&self) -> bool {
107        self.bits
108    }
109    #[doc = r" Returns `true` if the bit is clear (0)"]
110    #[inline]
111    pub fn bit_is_clear(&self) -> bool {
112        !self.bit()
113    }
114    #[doc = r" Returns `true` if the bit is set (1)"]
115    #[inline]
116    pub fn bit_is_set(&self) -> bool {
117        self.bit()
118    }
119}
120#[doc = r" Value of the field"]
121pub struct COMP1_HYSTR {
122    bits: u8,
123}
124impl COMP1_HYSTR {
125    #[doc = r" Value of the field as raw bits"]
126    #[inline]
127    pub fn bits(&self) -> u8 {
128        self.bits
129    }
130}
131#[doc = r" Value of the field"]
132pub struct COMP1_BLANKINGR {
133    bits: u8,
134}
135impl COMP1_BLANKINGR {
136    #[doc = r" Value of the field as raw bits"]
137    #[inline]
138    pub fn bits(&self) -> u8 {
139        self.bits
140    }
141}
142#[doc = r" Value of the field"]
143pub struct COMP1_BRGENR {
144    bits: bool,
145}
146impl COMP1_BRGENR {
147    #[doc = r" Value of the field as raw bits"]
148    #[inline]
149    pub fn bit(&self) -> bool {
150        self.bits
151    }
152    #[doc = r" Returns `true` if the bit is clear (0)"]
153    #[inline]
154    pub fn bit_is_clear(&self) -> bool {
155        !self.bit()
156    }
157    #[doc = r" Returns `true` if the bit is set (1)"]
158    #[inline]
159    pub fn bit_is_set(&self) -> bool {
160        self.bit()
161    }
162}
163#[doc = r" Value of the field"]
164pub struct COMP1_SCALENR {
165    bits: bool,
166}
167impl COMP1_SCALENR {
168    #[doc = r" Value of the field as raw bits"]
169    #[inline]
170    pub fn bit(&self) -> bool {
171        self.bits
172    }
173    #[doc = r" Returns `true` if the bit is clear (0)"]
174    #[inline]
175    pub fn bit_is_clear(&self) -> bool {
176        !self.bit()
177    }
178    #[doc = r" Returns `true` if the bit is set (1)"]
179    #[inline]
180    pub fn bit_is_set(&self) -> bool {
181        self.bit()
182    }
183}
184#[doc = r" Value of the field"]
185pub struct COMP1_INMESELR {
186    bits: u8,
187}
188impl COMP1_INMESELR {
189    #[doc = r" Value of the field as raw bits"]
190    #[inline]
191    pub fn bits(&self) -> u8 {
192        self.bits
193    }
194}
195#[doc = r" Value of the field"]
196pub struct COMP1_VALUER {
197    bits: bool,
198}
199impl COMP1_VALUER {
200    #[doc = r" Value of the field as raw bits"]
201    #[inline]
202    pub fn bit(&self) -> bool {
203        self.bits
204    }
205    #[doc = r" Returns `true` if the bit is clear (0)"]
206    #[inline]
207    pub fn bit_is_clear(&self) -> bool {
208        !self.bit()
209    }
210    #[doc = r" Returns `true` if the bit is set (1)"]
211    #[inline]
212    pub fn bit_is_set(&self) -> bool {
213        self.bit()
214    }
215}
216#[doc = r" Proxy"]
217pub struct _COMP1_ENW<'a> {
218    w: &'a mut W,
219}
220impl<'a> _COMP1_ENW<'a> {
221    #[doc = r" Sets the field bit"]
222    pub fn set_bit(self) -> &'a mut W {
223        self.bit(true)
224    }
225    #[doc = r" Clears the field bit"]
226    pub fn clear_bit(self) -> &'a mut W {
227        self.bit(false)
228    }
229    #[doc = r" Writes raw bits to the field"]
230    #[inline]
231    pub fn bit(self, value: bool) -> &'a mut W {
232        const MASK: bool = true;
233        const OFFSET: u8 = 0;
234        self.w.bits &= !((MASK as u32) << OFFSET);
235        self.w.bits |= ((value & MASK) as u32) << OFFSET;
236        self.w
237    }
238}
239#[doc = r" Proxy"]
240pub struct _COMP1_PWRMODEW<'a> {
241    w: &'a mut W,
242}
243impl<'a> _COMP1_PWRMODEW<'a> {
244    #[doc = r" Writes raw bits to the field"]
245    #[inline]
246    pub unsafe fn bits(self, value: u8) -> &'a mut W {
247        const MASK: u8 = 3;
248        const OFFSET: u8 = 2;
249        self.w.bits &= !((MASK as u32) << OFFSET);
250        self.w.bits |= ((value & MASK) as u32) << OFFSET;
251        self.w
252    }
253}
254#[doc = r" Proxy"]
255pub struct _COMP1_INMSELW<'a> {
256    w: &'a mut W,
257}
258impl<'a> _COMP1_INMSELW<'a> {
259    #[doc = r" Writes raw bits to the field"]
260    #[inline]
261    pub unsafe fn bits(self, value: u8) -> &'a mut W {
262        const MASK: u8 = 7;
263        const OFFSET: u8 = 4;
264        self.w.bits &= !((MASK as u32) << OFFSET);
265        self.w.bits |= ((value & MASK) as u32) << OFFSET;
266        self.w
267    }
268}
269#[doc = r" Proxy"]
270pub struct _COMP1_INPSELW<'a> {
271    w: &'a mut W,
272}
273impl<'a> _COMP1_INPSELW<'a> {
274    #[doc = r" Writes raw bits to the field"]
275    #[inline]
276    pub unsafe fn bits(self, value: u8) -> &'a mut W {
277        const MASK: u8 = 3;
278        const OFFSET: u8 = 7;
279        self.w.bits &= !((MASK as u32) << OFFSET);
280        self.w.bits |= ((value & MASK) as u32) << OFFSET;
281        self.w
282    }
283}
284#[doc = r" Proxy"]
285pub struct _COMP1_POLARITYW<'a> {
286    w: &'a mut W,
287}
288impl<'a> _COMP1_POLARITYW<'a> {
289    #[doc = r" Sets the field bit"]
290    pub fn set_bit(self) -> &'a mut W {
291        self.bit(true)
292    }
293    #[doc = r" Clears the field bit"]
294    pub fn clear_bit(self) -> &'a mut W {
295        self.bit(false)
296    }
297    #[doc = r" Writes raw bits to the field"]
298    #[inline]
299    pub fn bit(self, value: bool) -> &'a mut W {
300        const MASK: bool = true;
301        const OFFSET: u8 = 15;
302        self.w.bits &= !((MASK as u32) << OFFSET);
303        self.w.bits |= ((value & MASK) as u32) << OFFSET;
304        self.w
305    }
306}
307#[doc = r" Proxy"]
308pub struct _COMP1_HYSTW<'a> {
309    w: &'a mut W,
310}
311impl<'a> _COMP1_HYSTW<'a> {
312    #[doc = r" Writes raw bits to the field"]
313    #[inline]
314    pub unsafe fn bits(self, value: u8) -> &'a mut W {
315        const MASK: u8 = 3;
316        const OFFSET: u8 = 16;
317        self.w.bits &= !((MASK as u32) << OFFSET);
318        self.w.bits |= ((value & MASK) as u32) << OFFSET;
319        self.w
320    }
321}
322#[doc = r" Proxy"]
323pub struct _COMP1_BLANKINGW<'a> {
324    w: &'a mut W,
325}
326impl<'a> _COMP1_BLANKINGW<'a> {
327    #[doc = r" Writes raw bits to the field"]
328    #[inline]
329    pub unsafe fn bits(self, value: u8) -> &'a mut W {
330        const MASK: u8 = 7;
331        const OFFSET: u8 = 18;
332        self.w.bits &= !((MASK as u32) << OFFSET);
333        self.w.bits |= ((value & MASK) as u32) << OFFSET;
334        self.w
335    }
336}
337#[doc = r" Proxy"]
338pub struct _COMP1_BRGENW<'a> {
339    w: &'a mut W,
340}
341impl<'a> _COMP1_BRGENW<'a> {
342    #[doc = r" Sets the field bit"]
343    pub fn set_bit(self) -> &'a mut W {
344        self.bit(true)
345    }
346    #[doc = r" Clears the field bit"]
347    pub fn clear_bit(self) -> &'a mut W {
348        self.bit(false)
349    }
350    #[doc = r" Writes raw bits to the field"]
351    #[inline]
352    pub fn bit(self, value: bool) -> &'a mut W {
353        const MASK: bool = true;
354        const OFFSET: u8 = 22;
355        self.w.bits &= !((MASK as u32) << OFFSET);
356        self.w.bits |= ((value & MASK) as u32) << OFFSET;
357        self.w
358    }
359}
360#[doc = r" Proxy"]
361pub struct _COMP1_SCALENW<'a> {
362    w: &'a mut W,
363}
364impl<'a> _COMP1_SCALENW<'a> {
365    #[doc = r" Sets the field bit"]
366    pub fn set_bit(self) -> &'a mut W {
367        self.bit(true)
368    }
369    #[doc = r" Clears the field bit"]
370    pub fn clear_bit(self) -> &'a mut W {
371        self.bit(false)
372    }
373    #[doc = r" Writes raw bits to the field"]
374    #[inline]
375    pub fn bit(self, value: bool) -> &'a mut W {
376        const MASK: bool = true;
377        const OFFSET: u8 = 23;
378        self.w.bits &= !((MASK as u32) << OFFSET);
379        self.w.bits |= ((value & MASK) as u32) << OFFSET;
380        self.w
381    }
382}
383#[doc = r" Proxy"]
384pub struct _COMP1_INMESELW<'a> {
385    w: &'a mut W,
386}
387impl<'a> _COMP1_INMESELW<'a> {
388    #[doc = r" Writes raw bits to the field"]
389    #[inline]
390    pub unsafe fn bits(self, value: u8) -> &'a mut W {
391        const MASK: u8 = 3;
392        const OFFSET: u8 = 25;
393        self.w.bits &= !((MASK as u32) << OFFSET);
394        self.w.bits |= ((value & MASK) as u32) << OFFSET;
395        self.w
396    }
397}
398#[doc = r" Proxy"]
399pub struct _COMP1_LOCKW<'a> {
400    w: &'a mut W,
401}
402impl<'a> _COMP1_LOCKW<'a> {
403    #[doc = r" Sets the field bit"]
404    pub fn set_bit(self) -> &'a mut W {
405        self.bit(true)
406    }
407    #[doc = r" Clears the field bit"]
408    pub fn clear_bit(self) -> &'a mut W {
409        self.bit(false)
410    }
411    #[doc = r" Writes raw bits to the field"]
412    #[inline]
413    pub fn bit(self, value: bool) -> &'a mut W {
414        const MASK: bool = true;
415        const OFFSET: u8 = 31;
416        self.w.bits &= !((MASK as u32) << OFFSET);
417        self.w.bits |= ((value & MASK) as u32) << OFFSET;
418        self.w
419    }
420}
421impl R {
422    #[doc = r" Value of the register as raw bits"]
423    #[inline]
424    pub fn bits(&self) -> u32 {
425        self.bits
426    }
427    #[doc = "Bit 0 - Comparator 1 enable bit"]
428    #[inline]
429    pub fn comp1_en(&self) -> COMP1_ENR {
430        let bits = {
431            const MASK: bool = true;
432            const OFFSET: u8 = 0;
433            ((self.bits >> OFFSET) & MASK as u32) != 0
434        };
435        COMP1_ENR { bits }
436    }
437    #[doc = "Bits 2:3 - Power Mode of the comparator 1"]
438    #[inline]
439    pub fn comp1_pwrmode(&self) -> COMP1_PWRMODER {
440        let bits = {
441            const MASK: u8 = 3;
442            const OFFSET: u8 = 2;
443            ((self.bits >> OFFSET) & MASK as u32) as u8
444        };
445        COMP1_PWRMODER { bits }
446    }
447    #[doc = "Bits 4:6 - Comparator 1 Input Minus connection configuration bit"]
448    #[inline]
449    pub fn comp1_inmsel(&self) -> COMP1_INMSELR {
450        let bits = {
451            const MASK: u8 = 7;
452            const OFFSET: u8 = 4;
453            ((self.bits >> OFFSET) & MASK as u32) as u8
454        };
455        COMP1_INMSELR { bits }
456    }
457    #[doc = "Bits 7:8 - Comparator1 input plus selection bit"]
458    #[inline]
459    pub fn comp1_inpsel(&self) -> COMP1_INPSELR {
460        let bits = {
461            const MASK: u8 = 3;
462            const OFFSET: u8 = 7;
463            ((self.bits >> OFFSET) & MASK as u32) as u8
464        };
465        COMP1_INPSELR { bits }
466    }
467    #[doc = "Bit 15 - Comparator 1 polarity selection bit"]
468    #[inline]
469    pub fn comp1_polarity(&self) -> COMP1_POLARITYR {
470        let bits = {
471            const MASK: bool = true;
472            const OFFSET: u8 = 15;
473            ((self.bits >> OFFSET) & MASK as u32) != 0
474        };
475        COMP1_POLARITYR { bits }
476    }
477    #[doc = "Bits 16:17 - Comparator 1 hysteresis selection bits"]
478    #[inline]
479    pub fn comp1_hyst(&self) -> COMP1_HYSTR {
480        let bits = {
481            const MASK: u8 = 3;
482            const OFFSET: u8 = 16;
483            ((self.bits >> OFFSET) & MASK as u32) as u8
484        };
485        COMP1_HYSTR { bits }
486    }
487    #[doc = "Bits 18:20 - Comparator 1 blanking source selection bits"]
488    #[inline]
489    pub fn comp1_blanking(&self) -> COMP1_BLANKINGR {
490        let bits = {
491            const MASK: u8 = 7;
492            const OFFSET: u8 = 18;
493            ((self.bits >> OFFSET) & MASK as u32) as u8
494        };
495        COMP1_BLANKINGR { bits }
496    }
497    #[doc = "Bit 22 - Scaler bridge enable"]
498    #[inline]
499    pub fn comp1_brgen(&self) -> COMP1_BRGENR {
500        let bits = {
501            const MASK: bool = true;
502            const OFFSET: u8 = 22;
503            ((self.bits >> OFFSET) & MASK as u32) != 0
504        };
505        COMP1_BRGENR { bits }
506    }
507    #[doc = "Bit 23 - Voltage scaler enable bit"]
508    #[inline]
509    pub fn comp1_scalen(&self) -> COMP1_SCALENR {
510        let bits = {
511            const MASK: bool = true;
512            const OFFSET: u8 = 23;
513            ((self.bits >> OFFSET) & MASK as u32) != 0
514        };
515        COMP1_SCALENR { bits }
516    }
517    #[doc = "Bits 25:26 - comparator 1 input minus extended selection bits"]
518    #[inline]
519    pub fn comp1_inmesel(&self) -> COMP1_INMESELR {
520        let bits = {
521            const MASK: u8 = 3;
522            const OFFSET: u8 = 25;
523            ((self.bits >> OFFSET) & MASK as u32) as u8
524        };
525        COMP1_INMESELR { bits }
526    }
527    #[doc = "Bit 30 - Comparator 1 output status bit"]
528    #[inline]
529    pub fn comp1_value(&self) -> COMP1_VALUER {
530        let bits = {
531            const MASK: bool = true;
532            const OFFSET: u8 = 30;
533            ((self.bits >> OFFSET) & MASK as u32) != 0
534        };
535        COMP1_VALUER { 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 - Comparator 1 enable bit"]
551    #[inline]
552    pub fn comp1_en(&mut self) -> _COMP1_ENW {
553        _COMP1_ENW { w: self }
554    }
555    #[doc = "Bits 2:3 - Power Mode of the comparator 1"]
556    #[inline]
557    pub fn comp1_pwrmode(&mut self) -> _COMP1_PWRMODEW {
558        _COMP1_PWRMODEW { w: self }
559    }
560    #[doc = "Bits 4:6 - Comparator 1 Input Minus connection configuration bit"]
561    #[inline]
562    pub fn comp1_inmsel(&mut self) -> _COMP1_INMSELW {
563        _COMP1_INMSELW { w: self }
564    }
565    #[doc = "Bits 7:8 - Comparator1 input plus selection bit"]
566    #[inline]
567    pub fn comp1_inpsel(&mut self) -> _COMP1_INPSELW {
568        _COMP1_INPSELW { w: self }
569    }
570    #[doc = "Bit 15 - Comparator 1 polarity selection bit"]
571    #[inline]
572    pub fn comp1_polarity(&mut self) -> _COMP1_POLARITYW {
573        _COMP1_POLARITYW { w: self }
574    }
575    #[doc = "Bits 16:17 - Comparator 1 hysteresis selection bits"]
576    #[inline]
577    pub fn comp1_hyst(&mut self) -> _COMP1_HYSTW {
578        _COMP1_HYSTW { w: self }
579    }
580    #[doc = "Bits 18:20 - Comparator 1 blanking source selection bits"]
581    #[inline]
582    pub fn comp1_blanking(&mut self) -> _COMP1_BLANKINGW {
583        _COMP1_BLANKINGW { w: self }
584    }
585    #[doc = "Bit 22 - Scaler bridge enable"]
586    #[inline]
587    pub fn comp1_brgen(&mut self) -> _COMP1_BRGENW {
588        _COMP1_BRGENW { w: self }
589    }
590    #[doc = "Bit 23 - Voltage scaler enable bit"]
591    #[inline]
592    pub fn comp1_scalen(&mut self) -> _COMP1_SCALENW {
593        _COMP1_SCALENW { w: self }
594    }
595    #[doc = "Bits 25:26 - comparator 1 input minus extended selection bits"]
596    #[inline]
597    pub fn comp1_inmesel(&mut self) -> _COMP1_INMESELW {
598        _COMP1_INMESELW { w: self }
599    }
600    #[doc = "Bit 31 - COMP1_CSR register lock bit"]
601    #[inline]
602    pub fn comp1_lock(&mut self) -> _COMP1_LOCKW {
603        _COMP1_LOCKW { w: self }
604    }
605}