ra4e1/adc120/
adcmplr1.rs

1#[doc = "Register `ADCMPLR1` reader"]
2pub struct R(crate::R<ADCMPLR1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ADCMPLR1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ADCMPLR1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ADCMPLR1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ADCMPLR1` writer"]
17pub struct W(crate::W<ADCMPLR1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ADCMPLR1_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<ADCMPLR1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ADCMPLR1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CMPLCHA16` reader - Compare Window A Comparison Condition Select 16"]
38pub type CMPLCHA16_R = crate::BitReader<CMPLCHA16_A>;
39#[doc = "Compare Window A Comparison Condition Select 16\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum CMPLCHA16_A {
42    #[doc = "0: When window function is disabled (ADCMPCR.WCMPE = 0): ADCMPDR0 value > A/D-converted value When window function is enabled (ADCMPCR.WCMPE = 1): A/D-converted value < ADCMPDR0 value, or ADCMPDR1 value < A/D-converted value"]
43    _0 = 0,
44    #[doc = "1: When window function is disabled (ADCMPCR.WCMPE = 0): ADCMPDR0 value < A/D-converted value When window function is enabled (ADCMPCR.WCMPE = 1): ADCMPDR0 value < A/D-converted value < ADCMPDR1 value"]
45    _1 = 1,
46}
47impl From<CMPLCHA16_A> for bool {
48    #[inline(always)]
49    fn from(variant: CMPLCHA16_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl CMPLCHA16_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> CMPLCHA16_A {
57        match self.bits {
58            false => CMPLCHA16_A::_0,
59            true => CMPLCHA16_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == CMPLCHA16_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == CMPLCHA16_A::_1
71    }
72}
73#[doc = "Field `CMPLCHA16` writer - Compare Window A Comparison Condition Select 16"]
74pub type CMPLCHA16_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPLR1_SPEC, CMPLCHA16_A, O>;
75impl<'a, const O: u8> CMPLCHA16_W<'a, O> {
76    #[doc = "When window function is disabled (ADCMPCR.WCMPE = 0): ADCMPDR0 value > A/D-converted value When window function is enabled (ADCMPCR.WCMPE = 1): A/D-converted value < ADCMPDR0 value, or ADCMPDR1 value < A/D-converted value"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(CMPLCHA16_A::_0)
80    }
81    #[doc = "When window function is disabled (ADCMPCR.WCMPE = 0): ADCMPDR0 value < A/D-converted value When window function is enabled (ADCMPCR.WCMPE = 1): ADCMPDR0 value < A/D-converted value < ADCMPDR1 value"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(CMPLCHA16_A::_1)
85    }
86}
87impl R {
88    #[doc = "Bit 0 - Compare Window A Comparison Condition Select 16"]
89    #[inline(always)]
90    pub fn cmplcha16(&self) -> CMPLCHA16_R {
91        CMPLCHA16_R::new((self.bits & 1) != 0)
92    }
93}
94impl W {
95    #[doc = "Bit 0 - Compare Window A Comparison Condition Select 16"]
96    #[inline(always)]
97    #[must_use]
98    pub fn cmplcha16(&mut self) -> CMPLCHA16_W<0> {
99        CMPLCHA16_W::new(self)
100    }
101    #[doc = "Writes raw bits to the register."]
102    #[inline(always)]
103    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
104        self.0.bits(bits);
105        self
106    }
107}
108#[doc = "A/D Compare Function Window A Comparison Condition Setting Register 1\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [adcmplr1](index.html) module"]
109pub struct ADCMPLR1_SPEC;
110impl crate::RegisterSpec for ADCMPLR1_SPEC {
111    type Ux = u16;
112}
113#[doc = "`read()` method returns [adcmplr1::R](R) reader structure"]
114impl crate::Readable for ADCMPLR1_SPEC {
115    type Reader = R;
116}
117#[doc = "`write(|w| ..)` method takes [adcmplr1::W](W) writer structure"]
118impl crate::Writable for ADCMPLR1_SPEC {
119    type Writer = W;
120    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
121    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
122}
123#[doc = "`reset()` method sets ADCMPLR1 to value 0"]
124impl crate::Resettable for ADCMPLR1_SPEC {
125    const RESET_VALUE: Self::Ux = 0;
126}