stm32l4x2_pac/comp/
comp2_csr.rs1#[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::COMP2_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 COMP2_ENR {
47 bits: bool,
48}
49impl COMP2_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 COMP2_PWRMODER {
68 bits: u8,
69}
70impl COMP2_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 COMP2_INMSELR {
79 bits: u8,
80}
81impl COMP2_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 COMP2_INPSELR {
90 bits: u8,
91}
92impl COMP2_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 COMP2_WINMODER {
101 bits: bool,
102}
103impl COMP2_WINMODER {
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 COMP2_POLARITYR {
122 bits: bool,
123}
124impl COMP2_POLARITYR {
125 #[doc = r" Value of the field as raw bits"]
126 #[inline]
127 pub fn bit(&self) -> bool {
128 self.bits
129 }
130 #[doc = r" Returns `true` if the bit is clear (0)"]
131 #[inline]
132 pub fn bit_is_clear(&self) -> bool {
133 !self.bit()
134 }
135 #[doc = r" Returns `true` if the bit is set (1)"]
136 #[inline]
137 pub fn bit_is_set(&self) -> bool {
138 self.bit()
139 }
140}
141#[doc = r" Value of the field"]
142pub struct COMP2_HYSTR {
143 bits: u8,
144}
145impl COMP2_HYSTR {
146 #[doc = r" Value of the field as raw bits"]
147 #[inline]
148 pub fn bits(&self) -> u8 {
149 self.bits
150 }
151}
152#[doc = r" Value of the field"]
153pub struct COMP2_BLANKINGR {
154 bits: u8,
155}
156impl COMP2_BLANKINGR {
157 #[doc = r" Value of the field as raw bits"]
158 #[inline]
159 pub fn bits(&self) -> u8 {
160 self.bits
161 }
162}
163#[doc = r" Value of the field"]
164pub struct COMP2_BRGENR {
165 bits: bool,
166}
167impl COMP2_BRGENR {
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 COMP2_SCALENR {
186 bits: bool,
187}
188impl COMP2_SCALENR {
189 #[doc = r" Value of the field as raw bits"]
190 #[inline]
191 pub fn bit(&self) -> bool {
192 self.bits
193 }
194 #[doc = r" Returns `true` if the bit is clear (0)"]
195 #[inline]
196 pub fn bit_is_clear(&self) -> bool {
197 !self.bit()
198 }
199 #[doc = r" Returns `true` if the bit is set (1)"]
200 #[inline]
201 pub fn bit_is_set(&self) -> bool {
202 self.bit()
203 }
204}
205#[doc = r" Value of the field"]
206pub struct COMP2_INMESELR {
207 bits: u8,
208}
209impl COMP2_INMESELR {
210 #[doc = r" Value of the field as raw bits"]
211 #[inline]
212 pub fn bits(&self) -> u8 {
213 self.bits
214 }
215}
216#[doc = r" Value of the field"]
217pub struct COMP2_VALUER {
218 bits: bool,
219}
220impl COMP2_VALUER {
221 #[doc = r" Value of the field as raw bits"]
222 #[inline]
223 pub fn bit(&self) -> bool {
224 self.bits
225 }
226 #[doc = r" Returns `true` if the bit is clear (0)"]
227 #[inline]
228 pub fn bit_is_clear(&self) -> bool {
229 !self.bit()
230 }
231 #[doc = r" Returns `true` if the bit is set (1)"]
232 #[inline]
233 pub fn bit_is_set(&self) -> bool {
234 self.bit()
235 }
236}
237#[doc = r" Proxy"]
238pub struct _COMP2_ENW<'a> {
239 w: &'a mut W,
240}
241impl<'a> _COMP2_ENW<'a> {
242 #[doc = r" Sets the field bit"]
243 pub fn set_bit(self) -> &'a mut W {
244 self.bit(true)
245 }
246 #[doc = r" Clears the field bit"]
247 pub fn clear_bit(self) -> &'a mut W {
248 self.bit(false)
249 }
250 #[doc = r" Writes raw bits to the field"]
251 #[inline]
252 pub fn bit(self, value: bool) -> &'a mut W {
253 const MASK: bool = true;
254 const OFFSET: u8 = 0;
255 self.w.bits &= !((MASK as u32) << OFFSET);
256 self.w.bits |= ((value & MASK) as u32) << OFFSET;
257 self.w
258 }
259}
260#[doc = r" Proxy"]
261pub struct _COMP2_PWRMODEW<'a> {
262 w: &'a mut W,
263}
264impl<'a> _COMP2_PWRMODEW<'a> {
265 #[doc = r" Writes raw bits to the field"]
266 #[inline]
267 pub unsafe fn bits(self, value: u8) -> &'a mut W {
268 const MASK: u8 = 3;
269 const OFFSET: u8 = 2;
270 self.w.bits &= !((MASK as u32) << OFFSET);
271 self.w.bits |= ((value & MASK) as u32) << OFFSET;
272 self.w
273 }
274}
275#[doc = r" Proxy"]
276pub struct _COMP2_INMSELW<'a> {
277 w: &'a mut W,
278}
279impl<'a> _COMP2_INMSELW<'a> {
280 #[doc = r" Writes raw bits to the field"]
281 #[inline]
282 pub unsafe fn bits(self, value: u8) -> &'a mut W {
283 const MASK: u8 = 7;
284 const OFFSET: u8 = 4;
285 self.w.bits &= !((MASK as u32) << OFFSET);
286 self.w.bits |= ((value & MASK) as u32) << OFFSET;
287 self.w
288 }
289}
290#[doc = r" Proxy"]
291pub struct _COMP2_INPSELW<'a> {
292 w: &'a mut W,
293}
294impl<'a> _COMP2_INPSELW<'a> {
295 #[doc = r" Writes raw bits to the field"]
296 #[inline]
297 pub unsafe fn bits(self, value: u8) -> &'a mut W {
298 const MASK: u8 = 3;
299 const OFFSET: u8 = 7;
300 self.w.bits &= !((MASK as u32) << OFFSET);
301 self.w.bits |= ((value & MASK) as u32) << OFFSET;
302 self.w
303 }
304}
305#[doc = r" Proxy"]
306pub struct _COMP2_WINMODEW<'a> {
307 w: &'a mut W,
308}
309impl<'a> _COMP2_WINMODEW<'a> {
310 #[doc = r" Sets the field bit"]
311 pub fn set_bit(self) -> &'a mut W {
312 self.bit(true)
313 }
314 #[doc = r" Clears the field bit"]
315 pub fn clear_bit(self) -> &'a mut W {
316 self.bit(false)
317 }
318 #[doc = r" Writes raw bits to the field"]
319 #[inline]
320 pub fn bit(self, value: bool) -> &'a mut W {
321 const MASK: bool = true;
322 const OFFSET: u8 = 9;
323 self.w.bits &= !((MASK as u32) << OFFSET);
324 self.w.bits |= ((value & MASK) as u32) << OFFSET;
325 self.w
326 }
327}
328#[doc = r" Proxy"]
329pub struct _COMP2_POLARITYW<'a> {
330 w: &'a mut W,
331}
332impl<'a> _COMP2_POLARITYW<'a> {
333 #[doc = r" Sets the field bit"]
334 pub fn set_bit(self) -> &'a mut W {
335 self.bit(true)
336 }
337 #[doc = r" Clears the field bit"]
338 pub fn clear_bit(self) -> &'a mut W {
339 self.bit(false)
340 }
341 #[doc = r" Writes raw bits to the field"]
342 #[inline]
343 pub fn bit(self, value: bool) -> &'a mut W {
344 const MASK: bool = true;
345 const OFFSET: u8 = 15;
346 self.w.bits &= !((MASK as u32) << OFFSET);
347 self.w.bits |= ((value & MASK) as u32) << OFFSET;
348 self.w
349 }
350}
351#[doc = r" Proxy"]
352pub struct _COMP2_HYSTW<'a> {
353 w: &'a mut W,
354}
355impl<'a> _COMP2_HYSTW<'a> {
356 #[doc = r" Writes raw bits to the field"]
357 #[inline]
358 pub unsafe fn bits(self, value: u8) -> &'a mut W {
359 const MASK: u8 = 3;
360 const OFFSET: u8 = 16;
361 self.w.bits &= !((MASK as u32) << OFFSET);
362 self.w.bits |= ((value & MASK) as u32) << OFFSET;
363 self.w
364 }
365}
366#[doc = r" Proxy"]
367pub struct _COMP2_BLANKINGW<'a> {
368 w: &'a mut W,
369}
370impl<'a> _COMP2_BLANKINGW<'a> {
371 #[doc = r" Writes raw bits to the field"]
372 #[inline]
373 pub unsafe fn bits(self, value: u8) -> &'a mut W {
374 const MASK: u8 = 7;
375 const OFFSET: u8 = 18;
376 self.w.bits &= !((MASK as u32) << OFFSET);
377 self.w.bits |= ((value & MASK) as u32) << OFFSET;
378 self.w
379 }
380}
381#[doc = r" Proxy"]
382pub struct _COMP2_BRGENW<'a> {
383 w: &'a mut W,
384}
385impl<'a> _COMP2_BRGENW<'a> {
386 #[doc = r" Sets the field bit"]
387 pub fn set_bit(self) -> &'a mut W {
388 self.bit(true)
389 }
390 #[doc = r" Clears the field bit"]
391 pub fn clear_bit(self) -> &'a mut W {
392 self.bit(false)
393 }
394 #[doc = r" Writes raw bits to the field"]
395 #[inline]
396 pub fn bit(self, value: bool) -> &'a mut W {
397 const MASK: bool = true;
398 const OFFSET: u8 = 22;
399 self.w.bits &= !((MASK as u32) << OFFSET);
400 self.w.bits |= ((value & MASK) as u32) << OFFSET;
401 self.w
402 }
403}
404#[doc = r" Proxy"]
405pub struct _COMP2_SCALENW<'a> {
406 w: &'a mut W,
407}
408impl<'a> _COMP2_SCALENW<'a> {
409 #[doc = r" Sets the field bit"]
410 pub fn set_bit(self) -> &'a mut W {
411 self.bit(true)
412 }
413 #[doc = r" Clears the field bit"]
414 pub fn clear_bit(self) -> &'a mut W {
415 self.bit(false)
416 }
417 #[doc = r" Writes raw bits to the field"]
418 #[inline]
419 pub fn bit(self, value: bool) -> &'a mut W {
420 const MASK: bool = true;
421 const OFFSET: u8 = 23;
422 self.w.bits &= !((MASK as u32) << OFFSET);
423 self.w.bits |= ((value & MASK) as u32) << OFFSET;
424 self.w
425 }
426}
427#[doc = r" Proxy"]
428pub struct _COMP2_INMESELW<'a> {
429 w: &'a mut W,
430}
431impl<'a> _COMP2_INMESELW<'a> {
432 #[doc = r" Writes raw bits to the field"]
433 #[inline]
434 pub unsafe fn bits(self, value: u8) -> &'a mut W {
435 const MASK: u8 = 3;
436 const OFFSET: u8 = 25;
437 self.w.bits &= !((MASK as u32) << OFFSET);
438 self.w.bits |= ((value & MASK) as u32) << OFFSET;
439 self.w
440 }
441}
442#[doc = r" Proxy"]
443pub struct _COMP2_LOCKW<'a> {
444 w: &'a mut W,
445}
446impl<'a> _COMP2_LOCKW<'a> {
447 #[doc = r" Sets the field bit"]
448 pub fn set_bit(self) -> &'a mut W {
449 self.bit(true)
450 }
451 #[doc = r" Clears the field bit"]
452 pub fn clear_bit(self) -> &'a mut W {
453 self.bit(false)
454 }
455 #[doc = r" Writes raw bits to the field"]
456 #[inline]
457 pub fn bit(self, value: bool) -> &'a mut W {
458 const MASK: bool = true;
459 const OFFSET: u8 = 31;
460 self.w.bits &= !((MASK as u32) << OFFSET);
461 self.w.bits |= ((value & MASK) as u32) << OFFSET;
462 self.w
463 }
464}
465impl R {
466 #[doc = r" Value of the register as raw bits"]
467 #[inline]
468 pub fn bits(&self) -> u32 {
469 self.bits
470 }
471 #[doc = "Bit 0 - Comparator 2 enable bit"]
472 #[inline]
473 pub fn comp2_en(&self) -> COMP2_ENR {
474 let bits = {
475 const MASK: bool = true;
476 const OFFSET: u8 = 0;
477 ((self.bits >> OFFSET) & MASK as u32) != 0
478 };
479 COMP2_ENR { bits }
480 }
481 #[doc = "Bits 2:3 - Power Mode of the comparator 2"]
482 #[inline]
483 pub fn comp2_pwrmode(&self) -> COMP2_PWRMODER {
484 let bits = {
485 const MASK: u8 = 3;
486 const OFFSET: u8 = 2;
487 ((self.bits >> OFFSET) & MASK as u32) as u8
488 };
489 COMP2_PWRMODER { bits }
490 }
491 #[doc = "Bits 4:6 - Comparator 2 Input Minus connection configuration bit"]
492 #[inline]
493 pub fn comp2_inmsel(&self) -> COMP2_INMSELR {
494 let bits = {
495 const MASK: u8 = 7;
496 const OFFSET: u8 = 4;
497 ((self.bits >> OFFSET) & MASK as u32) as u8
498 };
499 COMP2_INMSELR { bits }
500 }
501 #[doc = "Bits 7:8 - Comparator 2 Input Plus connection configuration bit"]
502 #[inline]
503 pub fn comp2_inpsel(&self) -> COMP2_INPSELR {
504 let bits = {
505 const MASK: u8 = 3;
506 const OFFSET: u8 = 7;
507 ((self.bits >> OFFSET) & MASK as u32) as u8
508 };
509 COMP2_INPSELR { bits }
510 }
511 #[doc = "Bit 9 - Windows mode selection bit"]
512 #[inline]
513 pub fn comp2_winmode(&self) -> COMP2_WINMODER {
514 let bits = {
515 const MASK: bool = true;
516 const OFFSET: u8 = 9;
517 ((self.bits >> OFFSET) & MASK as u32) != 0
518 };
519 COMP2_WINMODER { bits }
520 }
521 #[doc = "Bit 15 - Comparator 2 polarity selection bit"]
522 #[inline]
523 pub fn comp2_polarity(&self) -> COMP2_POLARITYR {
524 let bits = {
525 const MASK: bool = true;
526 const OFFSET: u8 = 15;
527 ((self.bits >> OFFSET) & MASK as u32) != 0
528 };
529 COMP2_POLARITYR { bits }
530 }
531 #[doc = "Bits 16:17 - Comparator 2 hysteresis selection bits"]
532 #[inline]
533 pub fn comp2_hyst(&self) -> COMP2_HYSTR {
534 let bits = {
535 const MASK: u8 = 3;
536 const OFFSET: u8 = 16;
537 ((self.bits >> OFFSET) & MASK as u32) as u8
538 };
539 COMP2_HYSTR { bits }
540 }
541 #[doc = "Bits 18:20 - Comparator 2 blanking source selection bits"]
542 #[inline]
543 pub fn comp2_blanking(&self) -> COMP2_BLANKINGR {
544 let bits = {
545 const MASK: u8 = 7;
546 const OFFSET: u8 = 18;
547 ((self.bits >> OFFSET) & MASK as u32) as u8
548 };
549 COMP2_BLANKINGR { bits }
550 }
551 #[doc = "Bit 22 - Scaler bridge enable"]
552 #[inline]
553 pub fn comp2_brgen(&self) -> COMP2_BRGENR {
554 let bits = {
555 const MASK: bool = true;
556 const OFFSET: u8 = 22;
557 ((self.bits >> OFFSET) & MASK as u32) != 0
558 };
559 COMP2_BRGENR { bits }
560 }
561 #[doc = "Bit 23 - Voltage scaler enable bit"]
562 #[inline]
563 pub fn comp2_scalen(&self) -> COMP2_SCALENR {
564 let bits = {
565 const MASK: bool = true;
566 const OFFSET: u8 = 23;
567 ((self.bits >> OFFSET) & MASK as u32) != 0
568 };
569 COMP2_SCALENR { bits }
570 }
571 #[doc = "Bits 25:26 - comparator 2 input minus extended selection bits"]
572 #[inline]
573 pub fn comp2_inmesel(&self) -> COMP2_INMESELR {
574 let bits = {
575 const MASK: u8 = 3;
576 const OFFSET: u8 = 25;
577 ((self.bits >> OFFSET) & MASK as u32) as u8
578 };
579 COMP2_INMESELR { bits }
580 }
581 #[doc = "Bit 30 - Comparator 2 output status bit"]
582 #[inline]
583 pub fn comp2_value(&self) -> COMP2_VALUER {
584 let bits = {
585 const MASK: bool = true;
586 const OFFSET: u8 = 30;
587 ((self.bits >> OFFSET) & MASK as u32) != 0
588 };
589 COMP2_VALUER { bits }
590 }
591}
592impl W {
593 #[doc = r" Reset value of the register"]
594 #[inline]
595 pub fn reset_value() -> W {
596 W { bits: 0 }
597 }
598 #[doc = r" Writes raw bits to the register"]
599 #[inline]
600 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
601 self.bits = bits;
602 self
603 }
604 #[doc = "Bit 0 - Comparator 2 enable bit"]
605 #[inline]
606 pub fn comp2_en(&mut self) -> _COMP2_ENW {
607 _COMP2_ENW { w: self }
608 }
609 #[doc = "Bits 2:3 - Power Mode of the comparator 2"]
610 #[inline]
611 pub fn comp2_pwrmode(&mut self) -> _COMP2_PWRMODEW {
612 _COMP2_PWRMODEW { w: self }
613 }
614 #[doc = "Bits 4:6 - Comparator 2 Input Minus connection configuration bit"]
615 #[inline]
616 pub fn comp2_inmsel(&mut self) -> _COMP2_INMSELW {
617 _COMP2_INMSELW { w: self }
618 }
619 #[doc = "Bits 7:8 - Comparator 2 Input Plus connection configuration bit"]
620 #[inline]
621 pub fn comp2_inpsel(&mut self) -> _COMP2_INPSELW {
622 _COMP2_INPSELW { w: self }
623 }
624 #[doc = "Bit 9 - Windows mode selection bit"]
625 #[inline]
626 pub fn comp2_winmode(&mut self) -> _COMP2_WINMODEW {
627 _COMP2_WINMODEW { w: self }
628 }
629 #[doc = "Bit 15 - Comparator 2 polarity selection bit"]
630 #[inline]
631 pub fn comp2_polarity(&mut self) -> _COMP2_POLARITYW {
632 _COMP2_POLARITYW { w: self }
633 }
634 #[doc = "Bits 16:17 - Comparator 2 hysteresis selection bits"]
635 #[inline]
636 pub fn comp2_hyst(&mut self) -> _COMP2_HYSTW {
637 _COMP2_HYSTW { w: self }
638 }
639 #[doc = "Bits 18:20 - Comparator 2 blanking source selection bits"]
640 #[inline]
641 pub fn comp2_blanking(&mut self) -> _COMP2_BLANKINGW {
642 _COMP2_BLANKINGW { w: self }
643 }
644 #[doc = "Bit 22 - Scaler bridge enable"]
645 #[inline]
646 pub fn comp2_brgen(&mut self) -> _COMP2_BRGENW {
647 _COMP2_BRGENW { w: self }
648 }
649 #[doc = "Bit 23 - Voltage scaler enable bit"]
650 #[inline]
651 pub fn comp2_scalen(&mut self) -> _COMP2_SCALENW {
652 _COMP2_SCALENW { w: self }
653 }
654 #[doc = "Bits 25:26 - comparator 2 input minus extended selection bits"]
655 #[inline]
656 pub fn comp2_inmesel(&mut self) -> _COMP2_INMESELW {
657 _COMP2_INMESELW { w: self }
658 }
659 #[doc = "Bit 31 - COMP2_CSR register lock bit"]
660 #[inline]
661 pub fn comp2_lock(&mut self) -> _COMP2_LOCKW {
662 _COMP2_LOCKW { w: self }
663 }
664}