ra2a1 0.2.0

Peripheral access API for ra2a1 microcontrollers (generated using svd2rust)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#[doc = "Register `ADCMPCR` reader"]
pub struct R(crate::R<ADCMPCR_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<ADCMPCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl From<crate::R<ADCMPCR_SPEC>> for R {
    #[inline(always)]
    fn from(reader: crate::R<ADCMPCR_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `ADCMPCR` writer"]
pub struct W(crate::W<ADCMPCR_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<ADCMPCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl From<crate::W<ADCMPCR_SPEC>> for W {
    #[inline(always)]
    fn from(writer: crate::W<ADCMPCR_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `CMPAB` reader - Window A/B Composite Conditions SettingNOTE: These bits are valid when both window A and window B are enabled (CMPAE = 1 and CMPBE = 1)."]
pub type CMPAB_R = crate::FieldReader<u8, CMPAB_A>;
#[doc = "Window A/B Composite Conditions SettingNOTE: These bits are valid when both window A and window B are enabled (CMPAE = 1 and CMPBE = 1).\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum CMPAB_A {
    #[doc = "0: ADC160_WCMPM is output when window A comparison conditions are met OR window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    _00 = 0,
    #[doc = "1: ADC160_WCMPM is output when window A comparison conditions are met EXOR window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    _01 = 1,
    #[doc = "2: ADC160_WCMPM is output when window A comparison conditions are met and window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    _10 = 2,
    #[doc = "3: Setting prohibited."]
    _11 = 3,
}
impl From<CMPAB_A> for u8 {
    #[inline(always)]
    fn from(variant: CMPAB_A) -> Self {
        variant as _
    }
}
impl CMPAB_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CMPAB_A {
        match self.bits {
            0 => CMPAB_A::_00,
            1 => CMPAB_A::_01,
            2 => CMPAB_A::_10,
            3 => CMPAB_A::_11,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `_00`"]
    #[inline(always)]
    pub fn is_00(&self) -> bool {
        *self == CMPAB_A::_00
    }
    #[doc = "Checks if the value of the field is `_01`"]
    #[inline(always)]
    pub fn is_01(&self) -> bool {
        *self == CMPAB_A::_01
    }
    #[doc = "Checks if the value of the field is `_10`"]
    #[inline(always)]
    pub fn is_10(&self) -> bool {
        *self == CMPAB_A::_10
    }
    #[doc = "Checks if the value of the field is `_11`"]
    #[inline(always)]
    pub fn is_11(&self) -> bool {
        *self == CMPAB_A::_11
    }
}
#[doc = "Field `CMPAB` writer - Window A/B Composite Conditions SettingNOTE: These bits are valid when both window A and window B are enabled (CMPAE = 1 and CMPBE = 1)."]
pub type CMPAB_W<'a, const O: u8> =
    crate::FieldWriterSafe<'a, u16, ADCMPCR_SPEC, u8, CMPAB_A, 2, O>;
impl<'a, const O: u8> CMPAB_W<'a, O> {
    #[doc = "ADC160_WCMPM is output when window A comparison conditions are met OR window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    #[inline(always)]
    pub fn _00(self) -> &'a mut W {
        self.variant(CMPAB_A::_00)
    }
    #[doc = "ADC160_WCMPM is output when window A comparison conditions are met EXOR window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    #[inline(always)]
    pub fn _01(self) -> &'a mut W {
        self.variant(CMPAB_A::_01)
    }
    #[doc = "ADC160_WCMPM is output when window A comparison conditions are met and window B comparison conditions are met. ADC160_WCMPUM is output in other cases."]
    #[inline(always)]
    pub fn _10(self) -> &'a mut W {
        self.variant(CMPAB_A::_10)
    }
    #[doc = "Setting prohibited."]
    #[inline(always)]
    pub fn _11(self) -> &'a mut W {
        self.variant(CMPAB_A::_11)
    }
}
#[doc = "Field `CMPBE` reader - Compare Window B Operation Enable"]
pub type CMPBE_R = crate::BitReader<CMPBE_A>;
#[doc = "Compare Window B Operation Enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CMPBE_A {
    #[doc = "0: Compare window B operation is disabled. ADC160_WCMPM and ADC160_WCMPUM outputs are disabled."]
    _0 = 0,
    #[doc = "1: Compare window B operation is enabled."]
    _1 = 1,
}
impl From<CMPBE_A> for bool {
    #[inline(always)]
    fn from(variant: CMPBE_A) -> Self {
        variant as u8 != 0
    }
}
impl CMPBE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CMPBE_A {
        match self.bits {
            false => CMPBE_A::_0,
            true => CMPBE_A::_1,
        }
    }
    #[doc = "Checks if the value of the field is `_0`"]
    #[inline(always)]
    pub fn is_0(&self) -> bool {
        *self == CMPBE_A::_0
    }
    #[doc = "Checks if the value of the field is `_1`"]
    #[inline(always)]
    pub fn is_1(&self) -> bool {
        *self == CMPBE_A::_1
    }
}
#[doc = "Field `CMPBE` writer - Compare Window B Operation Enable"]
pub type CMPBE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPCR_SPEC, CMPBE_A, O>;
impl<'a, const O: u8> CMPBE_W<'a, O> {
    #[doc = "Compare window B operation is disabled. ADC160_WCMPM and ADC160_WCMPUM outputs are disabled."]
    #[inline(always)]
    pub fn _0(self) -> &'a mut W {
        self.variant(CMPBE_A::_0)
    }
    #[doc = "Compare window B operation is enabled."]
    #[inline(always)]
    pub fn _1(self) -> &'a mut W {
        self.variant(CMPBE_A::_1)
    }
}
#[doc = "Field `CMPAE` reader - Compare Window A Operation Enable"]
pub type CMPAE_R = crate::BitReader<CMPAE_A>;
#[doc = "Compare Window A Operation Enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CMPAE_A {
    #[doc = "0: Compare window A operation is disabled. ADC160_WCMPM and ADC160_WCMPUM outputs are disabled."]
    _0 = 0,
    #[doc = "1: Compare window A operation is enabled."]
    _1 = 1,
}
impl From<CMPAE_A> for bool {
    #[inline(always)]
    fn from(variant: CMPAE_A) -> Self {
        variant as u8 != 0
    }
}
impl CMPAE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CMPAE_A {
        match self.bits {
            false => CMPAE_A::_0,
            true => CMPAE_A::_1,
        }
    }
    #[doc = "Checks if the value of the field is `_0`"]
    #[inline(always)]
    pub fn is_0(&self) -> bool {
        *self == CMPAE_A::_0
    }
    #[doc = "Checks if the value of the field is `_1`"]
    #[inline(always)]
    pub fn is_1(&self) -> bool {
        *self == CMPAE_A::_1
    }
}
#[doc = "Field `CMPAE` writer - Compare Window A Operation Enable"]
pub type CMPAE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPCR_SPEC, CMPAE_A, O>;
impl<'a, const O: u8> CMPAE_W<'a, O> {
    #[doc = "Compare window A operation is disabled. ADC160_WCMPM and ADC160_WCMPUM outputs are disabled."]
    #[inline(always)]
    pub fn _0(self) -> &'a mut W {
        self.variant(CMPAE_A::_0)
    }
    #[doc = "Compare window A operation is enabled."]
    #[inline(always)]
    pub fn _1(self) -> &'a mut W {
        self.variant(CMPAE_A::_1)
    }
}
#[doc = "Field `CMPBIE` reader - Compare B Interrupt Enable"]
pub type CMPBIE_R = crate::BitReader<CMPBIE_A>;
#[doc = "Compare B Interrupt Enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CMPBIE_A {
    #[doc = "0: ADC160_CMPBI interrupt is disabled when comparison conditions (window B) are met."]
    _0 = 0,
    #[doc = "1: ADC160_CMPBI interrupt is enabled when comparison conditions (window B) are met."]
    _1 = 1,
}
impl From<CMPBIE_A> for bool {
    #[inline(always)]
    fn from(variant: CMPBIE_A) -> Self {
        variant as u8 != 0
    }
}
impl CMPBIE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CMPBIE_A {
        match self.bits {
            false => CMPBIE_A::_0,
            true => CMPBIE_A::_1,
        }
    }
    #[doc = "Checks if the value of the field is `_0`"]
    #[inline(always)]
    pub fn is_0(&self) -> bool {
        *self == CMPBIE_A::_0
    }
    #[doc = "Checks if the value of the field is `_1`"]
    #[inline(always)]
    pub fn is_1(&self) -> bool {
        *self == CMPBIE_A::_1
    }
}
#[doc = "Field `CMPBIE` writer - Compare B Interrupt Enable"]
pub type CMPBIE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPCR_SPEC, CMPBIE_A, O>;
impl<'a, const O: u8> CMPBIE_W<'a, O> {
    #[doc = "ADC160_CMPBI interrupt is disabled when comparison conditions (window B) are met."]
    #[inline(always)]
    pub fn _0(self) -> &'a mut W {
        self.variant(CMPBIE_A::_0)
    }
    #[doc = "ADC160_CMPBI interrupt is enabled when comparison conditions (window B) are met."]
    #[inline(always)]
    pub fn _1(self) -> &'a mut W {
        self.variant(CMPBIE_A::_1)
    }
}
#[doc = "Field `WCMPE` reader - Window Function Setting"]
pub type WCMPE_R = crate::BitReader<WCMPE_A>;
#[doc = "Window Function Setting\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WCMPE_A {
    #[doc = "0: Window function is disabled. Window A and window B operate as a comparator to comparator the single value on the lower side with the A/D conversion result."]
    _0 = 0,
    #[doc = "1: Window function is enabled. Window A and window B operate as a comparator to comparator the two values on the upper and lower sides with the A/D conversion result."]
    _1 = 1,
}
impl From<WCMPE_A> for bool {
    #[inline(always)]
    fn from(variant: WCMPE_A) -> Self {
        variant as u8 != 0
    }
}
impl WCMPE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> WCMPE_A {
        match self.bits {
            false => WCMPE_A::_0,
            true => WCMPE_A::_1,
        }
    }
    #[doc = "Checks if the value of the field is `_0`"]
    #[inline(always)]
    pub fn is_0(&self) -> bool {
        *self == WCMPE_A::_0
    }
    #[doc = "Checks if the value of the field is `_1`"]
    #[inline(always)]
    pub fn is_1(&self) -> bool {
        *self == WCMPE_A::_1
    }
}
#[doc = "Field `WCMPE` writer - Window Function Setting"]
pub type WCMPE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPCR_SPEC, WCMPE_A, O>;
impl<'a, const O: u8> WCMPE_W<'a, O> {
    #[doc = "Window function is disabled. Window A and window B operate as a comparator to comparator the single value on the lower side with the A/D conversion result."]
    #[inline(always)]
    pub fn _0(self) -> &'a mut W {
        self.variant(WCMPE_A::_0)
    }
    #[doc = "Window function is enabled. Window A and window B operate as a comparator to comparator the two values on the upper and lower sides with the A/D conversion result."]
    #[inline(always)]
    pub fn _1(self) -> &'a mut W {
        self.variant(WCMPE_A::_1)
    }
}
#[doc = "Field `CMPAIE` reader - Compare A Interrupt Enable"]
pub type CMPAIE_R = crate::BitReader<CMPAIE_A>;
#[doc = "Compare A Interrupt Enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CMPAIE_A {
    #[doc = "0: ADC160_CMPAI interrupt is disabled when comparison conditions (window A) are met."]
    _0 = 0,
    #[doc = "1: ADC160_CMPAI interrupt is enabled when comparison conditions (window A) are met."]
    _1 = 1,
}
impl From<CMPAIE_A> for bool {
    #[inline(always)]
    fn from(variant: CMPAIE_A) -> Self {
        variant as u8 != 0
    }
}
impl CMPAIE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CMPAIE_A {
        match self.bits {
            false => CMPAIE_A::_0,
            true => CMPAIE_A::_1,
        }
    }
    #[doc = "Checks if the value of the field is `_0`"]
    #[inline(always)]
    pub fn is_0(&self) -> bool {
        *self == CMPAIE_A::_0
    }
    #[doc = "Checks if the value of the field is `_1`"]
    #[inline(always)]
    pub fn is_1(&self) -> bool {
        *self == CMPAIE_A::_1
    }
}
#[doc = "Field `CMPAIE` writer - Compare A Interrupt Enable"]
pub type CMPAIE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCMPCR_SPEC, CMPAIE_A, O>;
impl<'a, const O: u8> CMPAIE_W<'a, O> {
    #[doc = "ADC160_CMPAI interrupt is disabled when comparison conditions (window A) are met."]
    #[inline(always)]
    pub fn _0(self) -> &'a mut W {
        self.variant(CMPAIE_A::_0)
    }
    #[doc = "ADC160_CMPAI interrupt is enabled when comparison conditions (window A) are met."]
    #[inline(always)]
    pub fn _1(self) -> &'a mut W {
        self.variant(CMPAIE_A::_1)
    }
}
impl R {
    #[doc = "Bits 0:1 - Window A/B Composite Conditions SettingNOTE: These bits are valid when both window A and window B are enabled (CMPAE = 1 and CMPBE = 1)."]
    #[inline(always)]
    pub fn cmpab(&self) -> CMPAB_R {
        CMPAB_R::new((self.bits & 3) as u8)
    }
    #[doc = "Bit 9 - Compare Window B Operation Enable"]
    #[inline(always)]
    pub fn cmpbe(&self) -> CMPBE_R {
        CMPBE_R::new(((self.bits >> 9) & 1) != 0)
    }
    #[doc = "Bit 11 - Compare Window A Operation Enable"]
    #[inline(always)]
    pub fn cmpae(&self) -> CMPAE_R {
        CMPAE_R::new(((self.bits >> 11) & 1) != 0)
    }
    #[doc = "Bit 13 - Compare B Interrupt Enable"]
    #[inline(always)]
    pub fn cmpbie(&self) -> CMPBIE_R {
        CMPBIE_R::new(((self.bits >> 13) & 1) != 0)
    }
    #[doc = "Bit 14 - Window Function Setting"]
    #[inline(always)]
    pub fn wcmpe(&self) -> WCMPE_R {
        WCMPE_R::new(((self.bits >> 14) & 1) != 0)
    }
    #[doc = "Bit 15 - Compare A Interrupt Enable"]
    #[inline(always)]
    pub fn cmpaie(&self) -> CMPAIE_R {
        CMPAIE_R::new(((self.bits >> 15) & 1) != 0)
    }
}
impl W {
    #[doc = "Bits 0:1 - Window A/B Composite Conditions SettingNOTE: These bits are valid when both window A and window B are enabled (CMPAE = 1 and CMPBE = 1)."]
    #[inline(always)]
    #[must_use]
    pub fn cmpab(&mut self) -> CMPAB_W<0> {
        CMPAB_W::new(self)
    }
    #[doc = "Bit 9 - Compare Window B Operation Enable"]
    #[inline(always)]
    #[must_use]
    pub fn cmpbe(&mut self) -> CMPBE_W<9> {
        CMPBE_W::new(self)
    }
    #[doc = "Bit 11 - Compare Window A Operation Enable"]
    #[inline(always)]
    #[must_use]
    pub fn cmpae(&mut self) -> CMPAE_W<11> {
        CMPAE_W::new(self)
    }
    #[doc = "Bit 13 - Compare B Interrupt Enable"]
    #[inline(always)]
    #[must_use]
    pub fn cmpbie(&mut self) -> CMPBIE_W<13> {
        CMPBIE_W::new(self)
    }
    #[doc = "Bit 14 - Window Function Setting"]
    #[inline(always)]
    #[must_use]
    pub fn wcmpe(&mut self) -> WCMPE_W<14> {
        WCMPE_W::new(self)
    }
    #[doc = "Bit 15 - Compare A Interrupt Enable"]
    #[inline(always)]
    #[must_use]
    pub fn cmpaie(&mut self) -> CMPAIE_W<15> {
        CMPAIE_W::new(self)
    }
    #[doc = "Writes raw bits to the register."]
    #[inline(always)]
    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "A/D Compare Function Control 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 [adcmpcr](index.html) module"]
pub struct ADCMPCR_SPEC;
impl crate::RegisterSpec for ADCMPCR_SPEC {
    type Ux = u16;
}
#[doc = "`read()` method returns [adcmpcr::R](R) reader structure"]
impl crate::Readable for ADCMPCR_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [adcmpcr::W](W) writer structure"]
impl crate::Writable for ADCMPCR_SPEC {
    type Writer = W;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets ADCMPCR to value 0"]
impl crate::Resettable for ADCMPCR_SPEC {
    const RESET_VALUE: Self::Ux = 0;
}