1#[doc = "Reader of register CR1"]
2pub type R = crate::R<u8, super::CR1>;
3#[doc = "Writer for register CR1"]
4pub type W = crate::W<u8, super::CR1>;
5#[doc = "Register CR1 `reset()`'s with value 0"]
6impl crate::ResetValue for super::CR1 {
7 type Type = u8;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Comparator Module Enable\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum EN_A {
16 #[doc = "0: Analog Comparator is disabled."]
17 _0 = 0,
18 #[doc = "1: Analog Comparator is enabled."]
19 _1 = 1,
20}
21impl From<EN_A> for bool {
22 #[inline(always)]
23 fn from(variant: EN_A) -> Self {
24 variant as u8 != 0
25 }
26}
27#[doc = "Reader of field `EN`"]
28pub type EN_R = crate::R<bool, EN_A>;
29impl EN_R {
30 #[doc = r"Get enumerated values variant"]
31 #[inline(always)]
32 pub fn variant(&self) -> EN_A {
33 match self.bits {
34 false => EN_A::_0,
35 true => EN_A::_1,
36 }
37 }
38 #[doc = "Checks if the value of the field is `_0`"]
39 #[inline(always)]
40 pub fn is_0(&self) -> bool {
41 *self == EN_A::_0
42 }
43 #[doc = "Checks if the value of the field is `_1`"]
44 #[inline(always)]
45 pub fn is_1(&self) -> bool {
46 *self == EN_A::_1
47 }
48}
49#[doc = "Write proxy for field `EN`"]
50pub struct EN_W<'a> {
51 w: &'a mut W,
52}
53impl<'a> EN_W<'a> {
54 #[doc = r"Writes `variant` to the field"]
55 #[inline(always)]
56 pub fn variant(self, variant: EN_A) -> &'a mut W {
57 {
58 self.bit(variant.into())
59 }
60 }
61 #[doc = "Analog Comparator is disabled."]
62 #[inline(always)]
63 pub fn _0(self) -> &'a mut W {
64 self.variant(EN_A::_0)
65 }
66 #[doc = "Analog Comparator is enabled."]
67 #[inline(always)]
68 pub fn _1(self) -> &'a mut W {
69 self.variant(EN_A::_1)
70 }
71 #[doc = r"Sets the field bit"]
72 #[inline(always)]
73 pub fn set_bit(self) -> &'a mut W {
74 self.bit(true)
75 }
76 #[doc = r"Clears the field bit"]
77 #[inline(always)]
78 pub fn clear_bit(self) -> &'a mut W {
79 self.bit(false)
80 }
81 #[doc = r"Writes raw bits to the field"]
82 #[inline(always)]
83 pub fn bit(self, value: bool) -> &'a mut W {
84 self.w.bits = (self.w.bits & !0x01) | ((value as u8) & 0x01);
85 self.w
86 }
87}
88#[doc = "Comparator Output Pin Enable\n\nValue on reset: 0"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90pub enum OPE_A {
91 #[doc = "0: CMPO is not available on the associated CMPO output pin. If the comparator does not own the pin, this field has no effect."]
92 _0 = 0,
93 #[doc = "1: CMPO is available on the associated CMPO output pin. The comparator output (CMPO) is driven out on the associated CMPO output pin if the comparator owns the pin. If the comparator does not own the field, this bit has no effect."]
94 _1 = 1,
95}
96impl From<OPE_A> for bool {
97 #[inline(always)]
98 fn from(variant: OPE_A) -> Self {
99 variant as u8 != 0
100 }
101}
102#[doc = "Reader of field `OPE`"]
103pub type OPE_R = crate::R<bool, OPE_A>;
104impl OPE_R {
105 #[doc = r"Get enumerated values variant"]
106 #[inline(always)]
107 pub fn variant(&self) -> OPE_A {
108 match self.bits {
109 false => OPE_A::_0,
110 true => OPE_A::_1,
111 }
112 }
113 #[doc = "Checks if the value of the field is `_0`"]
114 #[inline(always)]
115 pub fn is_0(&self) -> bool {
116 *self == OPE_A::_0
117 }
118 #[doc = "Checks if the value of the field is `_1`"]
119 #[inline(always)]
120 pub fn is_1(&self) -> bool {
121 *self == OPE_A::_1
122 }
123}
124#[doc = "Write proxy for field `OPE`"]
125pub struct OPE_W<'a> {
126 w: &'a mut W,
127}
128impl<'a> OPE_W<'a> {
129 #[doc = r"Writes `variant` to the field"]
130 #[inline(always)]
131 pub fn variant(self, variant: OPE_A) -> &'a mut W {
132 {
133 self.bit(variant.into())
134 }
135 }
136 #[doc = "CMPO is not available on the associated CMPO output pin. If the comparator does not own the pin, this field has no effect."]
137 #[inline(always)]
138 pub fn _0(self) -> &'a mut W {
139 self.variant(OPE_A::_0)
140 }
141 #[doc = "CMPO is available on the associated CMPO output pin. The comparator output (CMPO) is driven out on the associated CMPO output pin if the comparator owns the pin. If the comparator does not own the field, this bit has no effect."]
142 #[inline(always)]
143 pub fn _1(self) -> &'a mut W {
144 self.variant(OPE_A::_1)
145 }
146 #[doc = r"Sets the field bit"]
147 #[inline(always)]
148 pub fn set_bit(self) -> &'a mut W {
149 self.bit(true)
150 }
151 #[doc = r"Clears the field bit"]
152 #[inline(always)]
153 pub fn clear_bit(self) -> &'a mut W {
154 self.bit(false)
155 }
156 #[doc = r"Writes raw bits to the field"]
157 #[inline(always)]
158 pub fn bit(self, value: bool) -> &'a mut W {
159 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
160 self.w
161 }
162}
163#[doc = "Comparator Output Select\n\nValue on reset: 0"]
164#[derive(Clone, Copy, Debug, PartialEq)]
165pub enum COS_A {
166 #[doc = "0: Set the filtered comparator output (CMPO) to equal COUT."]
167 _0 = 0,
168 #[doc = "1: Set the unfiltered comparator output (CMPO) to equal COUTA."]
169 _1 = 1,
170}
171impl From<COS_A> for bool {
172 #[inline(always)]
173 fn from(variant: COS_A) -> Self {
174 variant as u8 != 0
175 }
176}
177#[doc = "Reader of field `COS`"]
178pub type COS_R = crate::R<bool, COS_A>;
179impl COS_R {
180 #[doc = r"Get enumerated values variant"]
181 #[inline(always)]
182 pub fn variant(&self) -> COS_A {
183 match self.bits {
184 false => COS_A::_0,
185 true => COS_A::_1,
186 }
187 }
188 #[doc = "Checks if the value of the field is `_0`"]
189 #[inline(always)]
190 pub fn is_0(&self) -> bool {
191 *self == COS_A::_0
192 }
193 #[doc = "Checks if the value of the field is `_1`"]
194 #[inline(always)]
195 pub fn is_1(&self) -> bool {
196 *self == COS_A::_1
197 }
198}
199#[doc = "Write proxy for field `COS`"]
200pub struct COS_W<'a> {
201 w: &'a mut W,
202}
203impl<'a> COS_W<'a> {
204 #[doc = r"Writes `variant` to the field"]
205 #[inline(always)]
206 pub fn variant(self, variant: COS_A) -> &'a mut W {
207 {
208 self.bit(variant.into())
209 }
210 }
211 #[doc = "Set the filtered comparator output (CMPO) to equal COUT."]
212 #[inline(always)]
213 pub fn _0(self) -> &'a mut W {
214 self.variant(COS_A::_0)
215 }
216 #[doc = "Set the unfiltered comparator output (CMPO) to equal COUTA."]
217 #[inline(always)]
218 pub fn _1(self) -> &'a mut W {
219 self.variant(COS_A::_1)
220 }
221 #[doc = r"Sets the field bit"]
222 #[inline(always)]
223 pub fn set_bit(self) -> &'a mut W {
224 self.bit(true)
225 }
226 #[doc = r"Clears the field bit"]
227 #[inline(always)]
228 pub fn clear_bit(self) -> &'a mut W {
229 self.bit(false)
230 }
231 #[doc = r"Writes raw bits to the field"]
232 #[inline(always)]
233 pub fn bit(self, value: bool) -> &'a mut W {
234 self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u8) & 0x01) << 2);
235 self.w
236 }
237}
238#[doc = "Comparator INVERT\n\nValue on reset: 0"]
239#[derive(Clone, Copy, Debug, PartialEq)]
240pub enum INV_A {
241 #[doc = "0: Does not invert the comparator output."]
242 _0 = 0,
243 #[doc = "1: Inverts the comparator output."]
244 _1 = 1,
245}
246impl From<INV_A> for bool {
247 #[inline(always)]
248 fn from(variant: INV_A) -> Self {
249 variant as u8 != 0
250 }
251}
252#[doc = "Reader of field `INV`"]
253pub type INV_R = crate::R<bool, INV_A>;
254impl INV_R {
255 #[doc = r"Get enumerated values variant"]
256 #[inline(always)]
257 pub fn variant(&self) -> INV_A {
258 match self.bits {
259 false => INV_A::_0,
260 true => INV_A::_1,
261 }
262 }
263 #[doc = "Checks if the value of the field is `_0`"]
264 #[inline(always)]
265 pub fn is_0(&self) -> bool {
266 *self == INV_A::_0
267 }
268 #[doc = "Checks if the value of the field is `_1`"]
269 #[inline(always)]
270 pub fn is_1(&self) -> bool {
271 *self == INV_A::_1
272 }
273}
274#[doc = "Write proxy for field `INV`"]
275pub struct INV_W<'a> {
276 w: &'a mut W,
277}
278impl<'a> INV_W<'a> {
279 #[doc = r"Writes `variant` to the field"]
280 #[inline(always)]
281 pub fn variant(self, variant: INV_A) -> &'a mut W {
282 {
283 self.bit(variant.into())
284 }
285 }
286 #[doc = "Does not invert the comparator output."]
287 #[inline(always)]
288 pub fn _0(self) -> &'a mut W {
289 self.variant(INV_A::_0)
290 }
291 #[doc = "Inverts the comparator output."]
292 #[inline(always)]
293 pub fn _1(self) -> &'a mut W {
294 self.variant(INV_A::_1)
295 }
296 #[doc = r"Sets the field bit"]
297 #[inline(always)]
298 pub fn set_bit(self) -> &'a mut W {
299 self.bit(true)
300 }
301 #[doc = r"Clears the field bit"]
302 #[inline(always)]
303 pub fn clear_bit(self) -> &'a mut W {
304 self.bit(false)
305 }
306 #[doc = r"Writes raw bits to the field"]
307 #[inline(always)]
308 pub fn bit(self, value: bool) -> &'a mut W {
309 self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u8) & 0x01) << 3);
310 self.w
311 }
312}
313#[doc = "Power Mode Select\n\nValue on reset: 0"]
314#[derive(Clone, Copy, Debug, PartialEq)]
315pub enum PMODE_A {
316 #[doc = "0: Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower output propagation delay and lower current consumption."]
317 _0 = 0,
318 #[doc = "1: High-Speed (HS) Comparison mode selected. In this mode, CMP has faster output propagation delay and higher current consumption."]
319 _1 = 1,
320}
321impl From<PMODE_A> for bool {
322 #[inline(always)]
323 fn from(variant: PMODE_A) -> Self {
324 variant as u8 != 0
325 }
326}
327#[doc = "Reader of field `PMODE`"]
328pub type PMODE_R = crate::R<bool, PMODE_A>;
329impl PMODE_R {
330 #[doc = r"Get enumerated values variant"]
331 #[inline(always)]
332 pub fn variant(&self) -> PMODE_A {
333 match self.bits {
334 false => PMODE_A::_0,
335 true => PMODE_A::_1,
336 }
337 }
338 #[doc = "Checks if the value of the field is `_0`"]
339 #[inline(always)]
340 pub fn is_0(&self) -> bool {
341 *self == PMODE_A::_0
342 }
343 #[doc = "Checks if the value of the field is `_1`"]
344 #[inline(always)]
345 pub fn is_1(&self) -> bool {
346 *self == PMODE_A::_1
347 }
348}
349#[doc = "Write proxy for field `PMODE`"]
350pub struct PMODE_W<'a> {
351 w: &'a mut W,
352}
353impl<'a> PMODE_W<'a> {
354 #[doc = r"Writes `variant` to the field"]
355 #[inline(always)]
356 pub fn variant(self, variant: PMODE_A) -> &'a mut W {
357 {
358 self.bit(variant.into())
359 }
360 }
361 #[doc = "Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower output propagation delay and lower current consumption."]
362 #[inline(always)]
363 pub fn _0(self) -> &'a mut W {
364 self.variant(PMODE_A::_0)
365 }
366 #[doc = "High-Speed (HS) Comparison mode selected. In this mode, CMP has faster output propagation delay and higher current consumption."]
367 #[inline(always)]
368 pub fn _1(self) -> &'a mut W {
369 self.variant(PMODE_A::_1)
370 }
371 #[doc = r"Sets the field bit"]
372 #[inline(always)]
373 pub fn set_bit(self) -> &'a mut W {
374 self.bit(true)
375 }
376 #[doc = r"Clears the field bit"]
377 #[inline(always)]
378 pub fn clear_bit(self) -> &'a mut W {
379 self.bit(false)
380 }
381 #[doc = r"Writes raw bits to the field"]
382 #[inline(always)]
383 pub fn bit(self, value: bool) -> &'a mut W {
384 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u8) & 0x01) << 4);
385 self.w
386 }
387}
388#[doc = "Windowing Enable\n\nValue on reset: 0"]
389#[derive(Clone, Copy, Debug, PartialEq)]
390pub enum WE_A {
391 #[doc = "0: Windowing mode is not selected."]
392 _0 = 0,
393 #[doc = "1: Windowing mode is selected."]
394 _1 = 1,
395}
396impl From<WE_A> for bool {
397 #[inline(always)]
398 fn from(variant: WE_A) -> Self {
399 variant as u8 != 0
400 }
401}
402#[doc = "Reader of field `WE`"]
403pub type WE_R = crate::R<bool, WE_A>;
404impl WE_R {
405 #[doc = r"Get enumerated values variant"]
406 #[inline(always)]
407 pub fn variant(&self) -> WE_A {
408 match self.bits {
409 false => WE_A::_0,
410 true => WE_A::_1,
411 }
412 }
413 #[doc = "Checks if the value of the field is `_0`"]
414 #[inline(always)]
415 pub fn is_0(&self) -> bool {
416 *self == WE_A::_0
417 }
418 #[doc = "Checks if the value of the field is `_1`"]
419 #[inline(always)]
420 pub fn is_1(&self) -> bool {
421 *self == WE_A::_1
422 }
423}
424#[doc = "Write proxy for field `WE`"]
425pub struct WE_W<'a> {
426 w: &'a mut W,
427}
428impl<'a> WE_W<'a> {
429 #[doc = r"Writes `variant` to the field"]
430 #[inline(always)]
431 pub fn variant(self, variant: WE_A) -> &'a mut W {
432 {
433 self.bit(variant.into())
434 }
435 }
436 #[doc = "Windowing mode is not selected."]
437 #[inline(always)]
438 pub fn _0(self) -> &'a mut W {
439 self.variant(WE_A::_0)
440 }
441 #[doc = "Windowing mode is selected."]
442 #[inline(always)]
443 pub fn _1(self) -> &'a mut W {
444 self.variant(WE_A::_1)
445 }
446 #[doc = r"Sets the field bit"]
447 #[inline(always)]
448 pub fn set_bit(self) -> &'a mut W {
449 self.bit(true)
450 }
451 #[doc = r"Clears the field bit"]
452 #[inline(always)]
453 pub fn clear_bit(self) -> &'a mut W {
454 self.bit(false)
455 }
456 #[doc = r"Writes raw bits to the field"]
457 #[inline(always)]
458 pub fn bit(self, value: bool) -> &'a mut W {
459 self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
460 self.w
461 }
462}
463#[doc = "Sample Enable\n\nValue on reset: 0"]
464#[derive(Clone, Copy, Debug, PartialEq)]
465pub enum SE_A {
466 #[doc = "0: Sampling mode is not selected."]
467 _0 = 0,
468 #[doc = "1: Sampling mode is selected."]
469 _1 = 1,
470}
471impl From<SE_A> for bool {
472 #[inline(always)]
473 fn from(variant: SE_A) -> Self {
474 variant as u8 != 0
475 }
476}
477#[doc = "Reader of field `SE`"]
478pub type SE_R = crate::R<bool, SE_A>;
479impl SE_R {
480 #[doc = r"Get enumerated values variant"]
481 #[inline(always)]
482 pub fn variant(&self) -> SE_A {
483 match self.bits {
484 false => SE_A::_0,
485 true => SE_A::_1,
486 }
487 }
488 #[doc = "Checks if the value of the field is `_0`"]
489 #[inline(always)]
490 pub fn is_0(&self) -> bool {
491 *self == SE_A::_0
492 }
493 #[doc = "Checks if the value of the field is `_1`"]
494 #[inline(always)]
495 pub fn is_1(&self) -> bool {
496 *self == SE_A::_1
497 }
498}
499#[doc = "Write proxy for field `SE`"]
500pub struct SE_W<'a> {
501 w: &'a mut W,
502}
503impl<'a> SE_W<'a> {
504 #[doc = r"Writes `variant` to the field"]
505 #[inline(always)]
506 pub fn variant(self, variant: SE_A) -> &'a mut W {
507 {
508 self.bit(variant.into())
509 }
510 }
511 #[doc = "Sampling mode is not selected."]
512 #[inline(always)]
513 pub fn _0(self) -> &'a mut W {
514 self.variant(SE_A::_0)
515 }
516 #[doc = "Sampling mode is selected."]
517 #[inline(always)]
518 pub fn _1(self) -> &'a mut W {
519 self.variant(SE_A::_1)
520 }
521 #[doc = r"Sets the field bit"]
522 #[inline(always)]
523 pub fn set_bit(self) -> &'a mut W {
524 self.bit(true)
525 }
526 #[doc = r"Clears the field bit"]
527 #[inline(always)]
528 pub fn clear_bit(self) -> &'a mut W {
529 self.bit(false)
530 }
531 #[doc = r"Writes raw bits to the field"]
532 #[inline(always)]
533 pub fn bit(self, value: bool) -> &'a mut W {
534 self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
535 self.w
536 }
537}
538impl R {
539 #[doc = "Bit 0 - Comparator Module Enable"]
540 #[inline(always)]
541 pub fn en(&self) -> EN_R {
542 EN_R::new((self.bits & 0x01) != 0)
543 }
544 #[doc = "Bit 1 - Comparator Output Pin Enable"]
545 #[inline(always)]
546 pub fn ope(&self) -> OPE_R {
547 OPE_R::new(((self.bits >> 1) & 0x01) != 0)
548 }
549 #[doc = "Bit 2 - Comparator Output Select"]
550 #[inline(always)]
551 pub fn cos(&self) -> COS_R {
552 COS_R::new(((self.bits >> 2) & 0x01) != 0)
553 }
554 #[doc = "Bit 3 - Comparator INVERT"]
555 #[inline(always)]
556 pub fn inv(&self) -> INV_R {
557 INV_R::new(((self.bits >> 3) & 0x01) != 0)
558 }
559 #[doc = "Bit 4 - Power Mode Select"]
560 #[inline(always)]
561 pub fn pmode(&self) -> PMODE_R {
562 PMODE_R::new(((self.bits >> 4) & 0x01) != 0)
563 }
564 #[doc = "Bit 6 - Windowing Enable"]
565 #[inline(always)]
566 pub fn we(&self) -> WE_R {
567 WE_R::new(((self.bits >> 6) & 0x01) != 0)
568 }
569 #[doc = "Bit 7 - Sample Enable"]
570 #[inline(always)]
571 pub fn se(&self) -> SE_R {
572 SE_R::new(((self.bits >> 7) & 0x01) != 0)
573 }
574}
575impl W {
576 #[doc = "Bit 0 - Comparator Module Enable"]
577 #[inline(always)]
578 pub fn en(&mut self) -> EN_W {
579 EN_W { w: self }
580 }
581 #[doc = "Bit 1 - Comparator Output Pin Enable"]
582 #[inline(always)]
583 pub fn ope(&mut self) -> OPE_W {
584 OPE_W { w: self }
585 }
586 #[doc = "Bit 2 - Comparator Output Select"]
587 #[inline(always)]
588 pub fn cos(&mut self) -> COS_W {
589 COS_W { w: self }
590 }
591 #[doc = "Bit 3 - Comparator INVERT"]
592 #[inline(always)]
593 pub fn inv(&mut self) -> INV_W {
594 INV_W { w: self }
595 }
596 #[doc = "Bit 4 - Power Mode Select"]
597 #[inline(always)]
598 pub fn pmode(&mut self) -> PMODE_W {
599 PMODE_W { w: self }
600 }
601 #[doc = "Bit 6 - Windowing Enable"]
602 #[inline(always)]
603 pub fn we(&mut self) -> WE_W {
604 WE_W { w: self }
605 }
606 #[doc = "Bit 7 - Sample Enable"]
607 #[inline(always)]
608 pub fn se(&mut self) -> SE_W {
609 SE_W { w: self }
610 }
611}