atsam4s16c_pac/adc/
emr.rs

1#[doc = "Register `EMR` reader"]
2pub struct R(crate::R<EMR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EMR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EMR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EMR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EMR` writer"]
17pub struct W(crate::W<EMR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EMR_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<EMR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EMR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CMPMODE` reader - Comparison Mode"]
38pub type CMPMODE_R = crate::FieldReader<u8, CMPMODE_A>;
39#[doc = "Comparison Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMPMODE_A {
43    #[doc = "0: Generates an event when the converted data is lower than the low threshold of the window."]
44    LOW = 0,
45    #[doc = "1: Generates an event when the converted data is higher than the high threshold of the window."]
46    HIGH = 1,
47    #[doc = "2: Generates an event when the converted data is in the comparison window."]
48    IN = 2,
49    #[doc = "3: Generates an event when the converted data is out of the comparison window."]
50    OUT = 3,
51}
52impl From<CMPMODE_A> for u8 {
53    #[inline(always)]
54    fn from(variant: CMPMODE_A) -> Self {
55        variant as _
56    }
57}
58impl CMPMODE_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> CMPMODE_A {
62        match self.bits {
63            0 => CMPMODE_A::LOW,
64            1 => CMPMODE_A::HIGH,
65            2 => CMPMODE_A::IN,
66            3 => CMPMODE_A::OUT,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `LOW`"]
71    #[inline(always)]
72    pub fn is_low(&self) -> bool {
73        *self == CMPMODE_A::LOW
74    }
75    #[doc = "Checks if the value of the field is `HIGH`"]
76    #[inline(always)]
77    pub fn is_high(&self) -> bool {
78        *self == CMPMODE_A::HIGH
79    }
80    #[doc = "Checks if the value of the field is `IN`"]
81    #[inline(always)]
82    pub fn is_in(&self) -> bool {
83        *self == CMPMODE_A::IN
84    }
85    #[doc = "Checks if the value of the field is `OUT`"]
86    #[inline(always)]
87    pub fn is_out(&self) -> bool {
88        *self == CMPMODE_A::OUT
89    }
90}
91#[doc = "Field `CMPMODE` writer - Comparison Mode"]
92pub type CMPMODE_W<'a, const O: u8> =
93    crate::FieldWriterSafe<'a, u32, EMR_SPEC, u8, CMPMODE_A, 2, O>;
94impl<'a, const O: u8> CMPMODE_W<'a, O> {
95    #[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
96    #[inline(always)]
97    pub fn low(self) -> &'a mut W {
98        self.variant(CMPMODE_A::LOW)
99    }
100    #[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
101    #[inline(always)]
102    pub fn high(self) -> &'a mut W {
103        self.variant(CMPMODE_A::HIGH)
104    }
105    #[doc = "Generates an event when the converted data is in the comparison window."]
106    #[inline(always)]
107    pub fn in_(self) -> &'a mut W {
108        self.variant(CMPMODE_A::IN)
109    }
110    #[doc = "Generates an event when the converted data is out of the comparison window."]
111    #[inline(always)]
112    pub fn out(self) -> &'a mut W {
113        self.variant(CMPMODE_A::OUT)
114    }
115}
116#[doc = "Field `CMPSEL` reader - Comparison Selected Channel"]
117pub type CMPSEL_R = crate::FieldReader<u8, u8>;
118#[doc = "Field `CMPSEL` writer - Comparison Selected Channel"]
119pub type CMPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EMR_SPEC, u8, u8, 4, O>;
120#[doc = "Field `CMPALL` reader - Compare All Channels"]
121pub type CMPALL_R = crate::BitReader<bool>;
122#[doc = "Field `CMPALL` writer - Compare All Channels"]
123pub type CMPALL_W<'a, const O: u8> = crate::BitWriter<'a, u32, EMR_SPEC, bool, O>;
124#[doc = "Field `TAG` reader - Tag of the ADC_LDCR"]
125pub type TAG_R = crate::BitReader<bool>;
126#[doc = "Field `TAG` writer - Tag of the ADC_LDCR"]
127pub type TAG_W<'a, const O: u8> = crate::BitWriter<'a, u32, EMR_SPEC, bool, O>;
128impl R {
129    #[doc = "Bits 0:1 - Comparison Mode"]
130    #[inline(always)]
131    pub fn cmpmode(&self) -> CMPMODE_R {
132        CMPMODE_R::new((self.bits & 3) as u8)
133    }
134    #[doc = "Bits 4:7 - Comparison Selected Channel"]
135    #[inline(always)]
136    pub fn cmpsel(&self) -> CMPSEL_R {
137        CMPSEL_R::new(((self.bits >> 4) & 0x0f) as u8)
138    }
139    #[doc = "Bit 9 - Compare All Channels"]
140    #[inline(always)]
141    pub fn cmpall(&self) -> CMPALL_R {
142        CMPALL_R::new(((self.bits >> 9) & 1) != 0)
143    }
144    #[doc = "Bit 24 - Tag of the ADC_LDCR"]
145    #[inline(always)]
146    pub fn tag(&self) -> TAG_R {
147        TAG_R::new(((self.bits >> 24) & 1) != 0)
148    }
149}
150impl W {
151    #[doc = "Bits 0:1 - Comparison Mode"]
152    #[inline(always)]
153    #[must_use]
154    pub fn cmpmode(&mut self) -> CMPMODE_W<0> {
155        CMPMODE_W::new(self)
156    }
157    #[doc = "Bits 4:7 - Comparison Selected Channel"]
158    #[inline(always)]
159    #[must_use]
160    pub fn cmpsel(&mut self) -> CMPSEL_W<4> {
161        CMPSEL_W::new(self)
162    }
163    #[doc = "Bit 9 - Compare All Channels"]
164    #[inline(always)]
165    #[must_use]
166    pub fn cmpall(&mut self) -> CMPALL_W<9> {
167        CMPALL_W::new(self)
168    }
169    #[doc = "Bit 24 - Tag of the ADC_LDCR"]
170    #[inline(always)]
171    #[must_use]
172    pub fn tag(&mut self) -> TAG_W<24> {
173        TAG_W::new(self)
174    }
175    #[doc = "Writes raw bits to the register."]
176    #[inline(always)]
177    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
178        self.0.bits(bits);
179        self
180    }
181}
182#[doc = "Extended Mode Register\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 [emr](index.html) module"]
183pub struct EMR_SPEC;
184impl crate::RegisterSpec for EMR_SPEC {
185    type Ux = u32;
186}
187#[doc = "`read()` method returns [emr::R](R) reader structure"]
188impl crate::Readable for EMR_SPEC {
189    type Reader = R;
190}
191#[doc = "`write(|w| ..)` method takes [emr::W](W) writer structure"]
192impl crate::Writable for EMR_SPEC {
193    type Writer = W;
194    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
195    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
196}
197#[doc = "`reset()` method sets EMR to value 0"]
198impl crate::Resettable for EMR_SPEC {
199    const RESET_VALUE: Self::Ux = 0;
200}