ra6m2/adc121/
adcmpbnsr.rs1#[doc = "Register `ADCMPBNSR` reader"]
2pub struct R(crate::R<ADCMPBNSR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<ADCMPBNSR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<ADCMPBNSR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<ADCMPBNSR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `ADCMPBNSR` writer"]
17pub struct W(crate::W<ADCMPBNSR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<ADCMPBNSR_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<ADCMPBNSR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<ADCMPBNSR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CMPCHB` reader - Compare window B channel selection bit.The channel that compares it on the condition of compare window B is selected."]
38pub type CMPCHB_R = crate::FieldReader<u8, CMPCHB_A>;
39#[doc = "Compare window B channel selection bit.The channel that compares it on the condition of compare window B is selected.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMPCHB_A {
43 #[doc = "0: AN100"]
44 _0X00 = 0,
45 #[doc = "1: AN101"]
46 _0X01 = 1,
47 #[doc = "2: AN102"]
48 _0X02 = 2,
49 #[doc = "3: AN103"]
50 _0X03 = 3,
51 #[doc = "5: AN105"]
52 _0X05 = 5,
53 #[doc = "6: AN106"]
54 _0X06 = 6,
55 #[doc = "7: AN107"]
56 _0X07 = 7,
57 #[doc = "16: AN116"]
58 _0X10 = 16,
59 #[doc = "17: AN117"]
60 _0X11 = 17,
61 #[doc = "18: AN118"]
62 _0X12 = 18,
63 #[doc = "19: AN119"]
64 _0X13 = 19,
65 #[doc = "32: Temperature sensor"]
66 _0X20 = 32,
67 #[doc = "33: Internal reference voltage"]
68 _0X21 = 33,
69 #[doc = "63: No channel is selected"]
70 _0X3F = 63,
71}
72impl From<CMPCHB_A> for u8 {
73 #[inline(always)]
74 fn from(variant: CMPCHB_A) -> Self {
75 variant as _
76 }
77}
78impl CMPCHB_R {
79 #[doc = "Get enumerated values variant"]
80 #[inline(always)]
81 pub fn variant(&self) -> Option<CMPCHB_A> {
82 match self.bits {
83 0 => Some(CMPCHB_A::_0X00),
84 1 => Some(CMPCHB_A::_0X01),
85 2 => Some(CMPCHB_A::_0X02),
86 3 => Some(CMPCHB_A::_0X03),
87 5 => Some(CMPCHB_A::_0X05),
88 6 => Some(CMPCHB_A::_0X06),
89 7 => Some(CMPCHB_A::_0X07),
90 16 => Some(CMPCHB_A::_0X10),
91 17 => Some(CMPCHB_A::_0X11),
92 18 => Some(CMPCHB_A::_0X12),
93 19 => Some(CMPCHB_A::_0X13),
94 32 => Some(CMPCHB_A::_0X20),
95 33 => Some(CMPCHB_A::_0X21),
96 63 => Some(CMPCHB_A::_0X3F),
97 _ => None,
98 }
99 }
100 #[doc = "Checks if the value of the field is `_0X00`"]
101 #[inline(always)]
102 pub fn is_0x00(&self) -> bool {
103 *self == CMPCHB_A::_0X00
104 }
105 #[doc = "Checks if the value of the field is `_0X01`"]
106 #[inline(always)]
107 pub fn is_0x01(&self) -> bool {
108 *self == CMPCHB_A::_0X01
109 }
110 #[doc = "Checks if the value of the field is `_0X02`"]
111 #[inline(always)]
112 pub fn is_0x02(&self) -> bool {
113 *self == CMPCHB_A::_0X02
114 }
115 #[doc = "Checks if the value of the field is `_0X03`"]
116 #[inline(always)]
117 pub fn is_0x03(&self) -> bool {
118 *self == CMPCHB_A::_0X03
119 }
120 #[doc = "Checks if the value of the field is `_0X05`"]
121 #[inline(always)]
122 pub fn is_0x05(&self) -> bool {
123 *self == CMPCHB_A::_0X05
124 }
125 #[doc = "Checks if the value of the field is `_0X06`"]
126 #[inline(always)]
127 pub fn is_0x06(&self) -> bool {
128 *self == CMPCHB_A::_0X06
129 }
130 #[doc = "Checks if the value of the field is `_0X07`"]
131 #[inline(always)]
132 pub fn is_0x07(&self) -> bool {
133 *self == CMPCHB_A::_0X07
134 }
135 #[doc = "Checks if the value of the field is `_0X10`"]
136 #[inline(always)]
137 pub fn is_0x10(&self) -> bool {
138 *self == CMPCHB_A::_0X10
139 }
140 #[doc = "Checks if the value of the field is `_0X11`"]
141 #[inline(always)]
142 pub fn is_0x11(&self) -> bool {
143 *self == CMPCHB_A::_0X11
144 }
145 #[doc = "Checks if the value of the field is `_0X12`"]
146 #[inline(always)]
147 pub fn is_0x12(&self) -> bool {
148 *self == CMPCHB_A::_0X12
149 }
150 #[doc = "Checks if the value of the field is `_0X13`"]
151 #[inline(always)]
152 pub fn is_0x13(&self) -> bool {
153 *self == CMPCHB_A::_0X13
154 }
155 #[doc = "Checks if the value of the field is `_0X20`"]
156 #[inline(always)]
157 pub fn is_0x20(&self) -> bool {
158 *self == CMPCHB_A::_0X20
159 }
160 #[doc = "Checks if the value of the field is `_0X21`"]
161 #[inline(always)]
162 pub fn is_0x21(&self) -> bool {
163 *self == CMPCHB_A::_0X21
164 }
165 #[doc = "Checks if the value of the field is `_0X3F`"]
166 #[inline(always)]
167 pub fn is_0x3f(&self) -> bool {
168 *self == CMPCHB_A::_0X3F
169 }
170}
171#[doc = "Field `CMPCHB` writer - Compare window B channel selection bit.The channel that compares it on the condition of compare window B is selected."]
172pub type CMPCHB_W<'a, const O: u8> = crate::FieldWriter<'a, u8, ADCMPBNSR_SPEC, u8, CMPCHB_A, 6, O>;
173impl<'a, const O: u8> CMPCHB_W<'a, O> {
174 #[doc = "AN100"]
175 #[inline(always)]
176 pub fn _0x00(self) -> &'a mut W {
177 self.variant(CMPCHB_A::_0X00)
178 }
179 #[doc = "AN101"]
180 #[inline(always)]
181 pub fn _0x01(self) -> &'a mut W {
182 self.variant(CMPCHB_A::_0X01)
183 }
184 #[doc = "AN102"]
185 #[inline(always)]
186 pub fn _0x02(self) -> &'a mut W {
187 self.variant(CMPCHB_A::_0X02)
188 }
189 #[doc = "AN103"]
190 #[inline(always)]
191 pub fn _0x03(self) -> &'a mut W {
192 self.variant(CMPCHB_A::_0X03)
193 }
194 #[doc = "AN105"]
195 #[inline(always)]
196 pub fn _0x05(self) -> &'a mut W {
197 self.variant(CMPCHB_A::_0X05)
198 }
199 #[doc = "AN106"]
200 #[inline(always)]
201 pub fn _0x06(self) -> &'a mut W {
202 self.variant(CMPCHB_A::_0X06)
203 }
204 #[doc = "AN107"]
205 #[inline(always)]
206 pub fn _0x07(self) -> &'a mut W {
207 self.variant(CMPCHB_A::_0X07)
208 }
209 #[doc = "AN116"]
210 #[inline(always)]
211 pub fn _0x10(self) -> &'a mut W {
212 self.variant(CMPCHB_A::_0X10)
213 }
214 #[doc = "AN117"]
215 #[inline(always)]
216 pub fn _0x11(self) -> &'a mut W {
217 self.variant(CMPCHB_A::_0X11)
218 }
219 #[doc = "AN118"]
220 #[inline(always)]
221 pub fn _0x12(self) -> &'a mut W {
222 self.variant(CMPCHB_A::_0X12)
223 }
224 #[doc = "AN119"]
225 #[inline(always)]
226 pub fn _0x13(self) -> &'a mut W {
227 self.variant(CMPCHB_A::_0X13)
228 }
229 #[doc = "Temperature sensor"]
230 #[inline(always)]
231 pub fn _0x20(self) -> &'a mut W {
232 self.variant(CMPCHB_A::_0X20)
233 }
234 #[doc = "Internal reference voltage"]
235 #[inline(always)]
236 pub fn _0x21(self) -> &'a mut W {
237 self.variant(CMPCHB_A::_0X21)
238 }
239 #[doc = "No channel is selected"]
240 #[inline(always)]
241 pub fn _0x3f(self) -> &'a mut W {
242 self.variant(CMPCHB_A::_0X3F)
243 }
244}
245#[doc = "Field `CMPLB` reader - Compare window B Compare condition setting bit."]
246pub type CMPLB_R = crate::BitReader<CMPLB_A>;
247#[doc = "Compare window B Compare condition setting bit.\n\nValue on reset: 0"]
248#[derive(Clone, Copy, Debug, PartialEq, Eq)]
249pub enum CMPLB_A {
250 #[doc = "0: CMPLLB value > A/D converted value (ADCMPCR.WCMPE=0) / A/D converted value < CMPLLB value or CMPULB value < A/D converted value (ADCMPCR.WCMPE=1)"]
251 _0 = 0,
252 #[doc = "1: CMPLLB value < A/D converted value(ADCMPCR.WCMPE=0) / CMPLLB value < A/D converted value < CMPULB value (ADCMPCR.WCMPE=1)"]
253 _1 = 1,
254}
255impl From<CMPLB_A> for bool {
256 #[inline(always)]
257 fn from(variant: CMPLB_A) -> Self {
258 variant as u8 != 0
259 }
260}
261impl CMPLB_R {
262 #[doc = "Get enumerated values variant"]
263 #[inline(always)]
264 pub fn variant(&self) -> CMPLB_A {
265 match self.bits {
266 false => CMPLB_A::_0,
267 true => CMPLB_A::_1,
268 }
269 }
270 #[doc = "Checks if the value of the field is `_0`"]
271 #[inline(always)]
272 pub fn is_0(&self) -> bool {
273 *self == CMPLB_A::_0
274 }
275 #[doc = "Checks if the value of the field is `_1`"]
276 #[inline(always)]
277 pub fn is_1(&self) -> bool {
278 *self == CMPLB_A::_1
279 }
280}
281#[doc = "Field `CMPLB` writer - Compare window B Compare condition setting bit."]
282pub type CMPLB_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCMPBNSR_SPEC, CMPLB_A, O>;
283impl<'a, const O: u8> CMPLB_W<'a, O> {
284 #[doc = "CMPLLB value > A/D converted value (ADCMPCR.WCMPE=0) / A/D converted value < CMPLLB value or CMPULB value < A/D converted value (ADCMPCR.WCMPE=1)"]
285 #[inline(always)]
286 pub fn _0(self) -> &'a mut W {
287 self.variant(CMPLB_A::_0)
288 }
289 #[doc = "CMPLLB value < A/D converted value(ADCMPCR.WCMPE=0) / CMPLLB value < A/D converted value < CMPULB value (ADCMPCR.WCMPE=1)"]
290 #[inline(always)]
291 pub fn _1(self) -> &'a mut W {
292 self.variant(CMPLB_A::_1)
293 }
294}
295impl R {
296 #[doc = "Bits 0:5 - Compare window B channel selection bit.The channel that compares it on the condition of compare window B is selected."]
297 #[inline(always)]
298 pub fn cmpchb(&self) -> CMPCHB_R {
299 CMPCHB_R::new(self.bits & 0x3f)
300 }
301 #[doc = "Bit 7 - Compare window B Compare condition setting bit."]
302 #[inline(always)]
303 pub fn cmplb(&self) -> CMPLB_R {
304 CMPLB_R::new(((self.bits >> 7) & 1) != 0)
305 }
306}
307impl W {
308 #[doc = "Bits 0:5 - Compare window B channel selection bit.The channel that compares it on the condition of compare window B is selected."]
309 #[inline(always)]
310 #[must_use]
311 pub fn cmpchb(&mut self) -> CMPCHB_W<0> {
312 CMPCHB_W::new(self)
313 }
314 #[doc = "Bit 7 - Compare window B Compare condition setting bit."]
315 #[inline(always)]
316 #[must_use]
317 pub fn cmplb(&mut self) -> CMPLB_W<7> {
318 CMPLB_W::new(self)
319 }
320 #[doc = "Writes raw bits to the register."]
321 #[inline(always)]
322 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
323 self.0.bits(bits);
324 self
325 }
326}
327#[doc = "A/D Compare Function Window B Channel Selection 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 [adcmpbnsr](index.html) module"]
328pub struct ADCMPBNSR_SPEC;
329impl crate::RegisterSpec for ADCMPBNSR_SPEC {
330 type Ux = u8;
331}
332#[doc = "`read()` method returns [adcmpbnsr::R](R) reader structure"]
333impl crate::Readable for ADCMPBNSR_SPEC {
334 type Reader = R;
335}
336#[doc = "`write(|w| ..)` method takes [adcmpbnsr::W](W) writer structure"]
337impl crate::Writable for ADCMPBNSR_SPEC {
338 type Writer = W;
339 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
340 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
341}
342#[doc = "`reset()` method sets ADCMPBNSR to value 0"]
343impl crate::Resettable for ADCMPBNSR_SPEC {
344 const RESET_VALUE: Self::Ux = 0;
345}