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
461
462
463
464
465
466
467
#[doc = "Reader of register CFG"]
pub type R = crate::R<u32, super::CFG>;
#[doc = "Writer for register CFG"]
pub type W = crate::W<u32, super::CFG>;
#[doc = "Register CFG `reset()`'s with value 0"]
impl crate::ResetValue for super::CFG {
    type Type = u32;
    #[inline(always)]
    fn reset_value() -> Self::Type {
        0
    }
}
#[doc = "When the reference input NSEL is set to NSEL_DAC, this bitfield selects the voltage level for the negative input to the comparator.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum LVLSEL_A {
    #[doc = "0: Set Reference input to 0.58 Volts."]
    _0P58V = 0,
    #[doc = "1: Set Reference input to 0.77 Volts."]
    _0P77V = 1,
    #[doc = "2: Set Reference input to 0.97 Volts."]
    _0P97V = 2,
    #[doc = "3: Set Reference input to 1.16 Volts."]
    _1P16V = 3,
    #[doc = "4: Set Reference input to 1.35 Volts."]
    _1P35V = 4,
    #[doc = "5: Set Reference input to 1.55 Volts."]
    _1P55V = 5,
    #[doc = "6: Set Reference input to 1.74 Volts."]
    _1P74V = 6,
    #[doc = "7: Set Reference input to 1.93 Volts."]
    _1P93V = 7,
    #[doc = "8: Set Reference input to 2.13 Volts."]
    _2P13V = 8,
    #[doc = "9: Set Reference input to 2.32 Volts."]
    _2P32V = 9,
    #[doc = "10: Set Reference input to 2.51 Volts."]
    _2P51V = 10,
    #[doc = "11: Set Reference input to 2.71 Volts."]
    _2P71V = 11,
    #[doc = "12: Set Reference input to 2.90 Volts."]
    _2P90V = 12,
    #[doc = "13: Set Reference input to 3.09 Volts."]
    _3P09V = 13,
    #[doc = "14: Set Reference input to 3.29 Volts."]
    _3P29V = 14,
    #[doc = "15: Set Reference input to 3.48 Volts."]
    _3P48V = 15,
}
impl From<LVLSEL_A> for u8 {
    #[inline(always)]
    fn from(variant: LVLSEL_A) -> Self {
        variant as _
    }
}
#[doc = "Reader of field `LVLSEL`"]
pub type LVLSEL_R = crate::R<u8, LVLSEL_A>;
impl LVLSEL_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> LVLSEL_A {
        match self.bits {
            0 => LVLSEL_A::_0P58V,
            1 => LVLSEL_A::_0P77V,
            2 => LVLSEL_A::_0P97V,
            3 => LVLSEL_A::_1P16V,
            4 => LVLSEL_A::_1P35V,
            5 => LVLSEL_A::_1P55V,
            6 => LVLSEL_A::_1P74V,
            7 => LVLSEL_A::_1P93V,
            8 => LVLSEL_A::_2P13V,
            9 => LVLSEL_A::_2P32V,
            10 => LVLSEL_A::_2P51V,
            11 => LVLSEL_A::_2P71V,
            12 => LVLSEL_A::_2P90V,
            13 => LVLSEL_A::_3P09V,
            14 => LVLSEL_A::_3P29V,
            15 => LVLSEL_A::_3P48V,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `_0P58V`"]
    #[inline(always)]
    pub fn is_0p58v(&self) -> bool {
        *self == LVLSEL_A::_0P58V
    }
    #[doc = "Checks if the value of the field is `_0P77V`"]
    #[inline(always)]
    pub fn is_0p77v(&self) -> bool {
        *self == LVLSEL_A::_0P77V
    }
    #[doc = "Checks if the value of the field is `_0P97V`"]
    #[inline(always)]
    pub fn is_0p97v(&self) -> bool {
        *self == LVLSEL_A::_0P97V
    }
    #[doc = "Checks if the value of the field is `_1P16V`"]
    #[inline(always)]
    pub fn is_1p16v(&self) -> bool {
        *self == LVLSEL_A::_1P16V
    }
    #[doc = "Checks if the value of the field is `_1P35V`"]
    #[inline(always)]
    pub fn is_1p35v(&self) -> bool {
        *self == LVLSEL_A::_1P35V
    }
    #[doc = "Checks if the value of the field is `_1P55V`"]
    #[inline(always)]
    pub fn is_1p55v(&self) -> bool {
        *self == LVLSEL_A::_1P55V
    }
    #[doc = "Checks if the value of the field is `_1P74V`"]
    #[inline(always)]
    pub fn is_1p74v(&self) -> bool {
        *self == LVLSEL_A::_1P74V
    }
    #[doc = "Checks if the value of the field is `_1P93V`"]
    #[inline(always)]
    pub fn is_1p93v(&self) -> bool {
        *self == LVLSEL_A::_1P93V
    }
    #[doc = "Checks if the value of the field is `_2P13V`"]
    #[inline(always)]
    pub fn is_2p13v(&self) -> bool {
        *self == LVLSEL_A::_2P13V
    }
    #[doc = "Checks if the value of the field is `_2P32V`"]
    #[inline(always)]
    pub fn is_2p32v(&self) -> bool {
        *self == LVLSEL_A::_2P32V
    }
    #[doc = "Checks if the value of the field is `_2P51V`"]
    #[inline(always)]
    pub fn is_2p51v(&self) -> bool {
        *self == LVLSEL_A::_2P51V
    }
    #[doc = "Checks if the value of the field is `_2P71V`"]
    #[inline(always)]
    pub fn is_2p71v(&self) -> bool {
        *self == LVLSEL_A::_2P71V
    }
    #[doc = "Checks if the value of the field is `_2P90V`"]
    #[inline(always)]
    pub fn is_2p90v(&self) -> bool {
        *self == LVLSEL_A::_2P90V
    }
    #[doc = "Checks if the value of the field is `_3P09V`"]
    #[inline(always)]
    pub fn is_3p09v(&self) -> bool {
        *self == LVLSEL_A::_3P09V
    }
    #[doc = "Checks if the value of the field is `_3P29V`"]
    #[inline(always)]
    pub fn is_3p29v(&self) -> bool {
        *self == LVLSEL_A::_3P29V
    }
    #[doc = "Checks if the value of the field is `_3P48V`"]
    #[inline(always)]
    pub fn is_3p48v(&self) -> bool {
        *self == LVLSEL_A::_3P48V
    }
}
#[doc = "Write proxy for field `LVLSEL`"]
pub struct LVLSEL_W<'a> {
    w: &'a mut W,
}
impl<'a> LVLSEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: LVLSEL_A) -> &'a mut W {
        {
            self.bits(variant.into())
        }
    }
    #[doc = "Set Reference input to 0.58 Volts."]
    #[inline(always)]
    pub fn _0p58v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_0P58V)
    }
    #[doc = "Set Reference input to 0.77 Volts."]
    #[inline(always)]
    pub fn _0p77v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_0P77V)
    }
    #[doc = "Set Reference input to 0.97 Volts."]
    #[inline(always)]
    pub fn _0p97v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_0P97V)
    }
    #[doc = "Set Reference input to 1.16 Volts."]
    #[inline(always)]
    pub fn _1p16v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_1P16V)
    }
    #[doc = "Set Reference input to 1.35 Volts."]
    #[inline(always)]
    pub fn _1p35v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_1P35V)
    }
    #[doc = "Set Reference input to 1.55 Volts."]
    #[inline(always)]
    pub fn _1p55v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_1P55V)
    }
    #[doc = "Set Reference input to 1.74 Volts."]
    #[inline(always)]
    pub fn _1p74v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_1P74V)
    }
    #[doc = "Set Reference input to 1.93 Volts."]
    #[inline(always)]
    pub fn _1p93v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_1P93V)
    }
    #[doc = "Set Reference input to 2.13 Volts."]
    #[inline(always)]
    pub fn _2p13v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_2P13V)
    }
    #[doc = "Set Reference input to 2.32 Volts."]
    #[inline(always)]
    pub fn _2p32v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_2P32V)
    }
    #[doc = "Set Reference input to 2.51 Volts."]
    #[inline(always)]
    pub fn _2p51v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_2P51V)
    }
    #[doc = "Set Reference input to 2.71 Volts."]
    #[inline(always)]
    pub fn _2p71v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_2P71V)
    }
    #[doc = "Set Reference input to 2.90 Volts."]
    #[inline(always)]
    pub fn _2p90v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_2P90V)
    }
    #[doc = "Set Reference input to 3.09 Volts."]
    #[inline(always)]
    pub fn _3p09v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_3P09V)
    }
    #[doc = "Set Reference input to 3.29 Volts."]
    #[inline(always)]
    pub fn _3p29v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_3P29V)
    }
    #[doc = "Set Reference input to 3.48 Volts."]
    #[inline(always)]
    pub fn _3p48v(self) -> &'a mut W {
        self.variant(LVLSEL_A::_3P48V)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
        self.w
    }
}
#[doc = "This bitfield selects the negative input to the comparator.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum NSEL_A {
    #[doc = "0: Use external reference 1 for reference input."]
    VREFEXT1 = 0,
    #[doc = "1: Use external reference 2 for reference input."]
    VREFEXT2 = 1,
    #[doc = "3: Use external reference 3 for reference input."]
    VREFEXT3 = 3,
}
impl From<NSEL_A> for u8 {
    #[inline(always)]
    fn from(variant: NSEL_A) -> Self {
        variant as _
    }
}
#[doc = "Reader of field `NSEL`"]
pub type NSEL_R = crate::R<u8, NSEL_A>;
impl NSEL_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> crate::Variant<u8, NSEL_A> {
        use crate::Variant::*;
        match self.bits {
            0 => Val(NSEL_A::VREFEXT1),
            1 => Val(NSEL_A::VREFEXT2),
            3 => Val(NSEL_A::VREFEXT3),
            i => Res(i),
        }
    }
    #[doc = "Checks if the value of the field is `VREFEXT1`"]
    #[inline(always)]
    pub fn is_vrefext1(&self) -> bool {
        *self == NSEL_A::VREFEXT1
    }
    #[doc = "Checks if the value of the field is `VREFEXT2`"]
    #[inline(always)]
    pub fn is_vrefext2(&self) -> bool {
        *self == NSEL_A::VREFEXT2
    }
    #[doc = "Checks if the value of the field is `VREFEXT3`"]
    #[inline(always)]
    pub fn is_vrefext3(&self) -> bool {
        *self == NSEL_A::VREFEXT3
    }
}
#[doc = "Write proxy for field `NSEL`"]
pub struct NSEL_W<'a> {
    w: &'a mut W,
}
impl<'a> NSEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: NSEL_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "Use external reference 1 for reference input."]
    #[inline(always)]
    pub fn vrefext1(self) -> &'a mut W {
        self.variant(NSEL_A::VREFEXT1)
    }
    #[doc = "Use external reference 2 for reference input."]
    #[inline(always)]
    pub fn vrefext2(self) -> &'a mut W {
        self.variant(NSEL_A::VREFEXT2)
    }
    #[doc = "Use external reference 3 for reference input."]
    #[inline(always)]
    pub fn vrefext3(self) -> &'a mut W {
        self.variant(NSEL_A::VREFEXT3)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
        self.w
    }
}
#[doc = "This bitfield selects the positive input to the comparator.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum PSEL_A {
    #[doc = "0: Use VDDADJ for the positive input."]
    VDDADJ = 0,
    #[doc = "1: Use the temperature sensor output for the positive input."]
    VTEMP = 1,
    #[doc = "2: Use external voltage 1 for positive input."]
    VEXT1 = 2,
    #[doc = "3: Use external voltage 1 for positive input."]
    VEXT2 = 3,
}
impl From<PSEL_A> for u8 {
    #[inline(always)]
    fn from(variant: PSEL_A) -> Self {
        variant as _
    }
}
#[doc = "Reader of field `PSEL`"]
pub type PSEL_R = crate::R<u8, PSEL_A>;
impl PSEL_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PSEL_A {
        match self.bits {
            0 => PSEL_A::VDDADJ,
            1 => PSEL_A::VTEMP,
            2 => PSEL_A::VEXT1,
            3 => PSEL_A::VEXT2,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `VDDADJ`"]
    #[inline(always)]
    pub fn is_vddadj(&self) -> bool {
        *self == PSEL_A::VDDADJ
    }
    #[doc = "Checks if the value of the field is `VTEMP`"]
    #[inline(always)]
    pub fn is_vtemp(&self) -> bool {
        *self == PSEL_A::VTEMP
    }
    #[doc = "Checks if the value of the field is `VEXT1`"]
    #[inline(always)]
    pub fn is_vext1(&self) -> bool {
        *self == PSEL_A::VEXT1
    }
    #[doc = "Checks if the value of the field is `VEXT2`"]
    #[inline(always)]
    pub fn is_vext2(&self) -> bool {
        *self == PSEL_A::VEXT2
    }
}
#[doc = "Write proxy for field `PSEL`"]
pub struct PSEL_W<'a> {
    w: &'a mut W,
}
impl<'a> PSEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: PSEL_A) -> &'a mut W {
        {
            self.bits(variant.into())
        }
    }
    #[doc = "Use VDDADJ for the positive input."]
    #[inline(always)]
    pub fn vddadj(self) -> &'a mut W {
        self.variant(PSEL_A::VDDADJ)
    }
    #[doc = "Use the temperature sensor output for the positive input."]
    #[inline(always)]
    pub fn vtemp(self) -> &'a mut W {
        self.variant(PSEL_A::VTEMP)
    }
    #[doc = "Use external voltage 1 for positive input."]
    #[inline(always)]
    pub fn vext1(self) -> &'a mut W {
        self.variant(PSEL_A::VEXT1)
    }
    #[doc = "Use external voltage 1 for positive input."]
    #[inline(always)]
    pub fn vext2(self) -> &'a mut W {
        self.variant(PSEL_A::VEXT2)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
        self.w
    }
}
impl R {
    #[doc = "Bits 16:19 - When the reference input NSEL is set to NSEL_DAC, this bitfield selects the voltage level for the negative input to the comparator."]
    #[inline(always)]
    pub fn lvlsel(&self) -> LVLSEL_R {
        LVLSEL_R::new(((self.bits >> 16) & 0x0f) as u8)
    }
    #[doc = "Bits 8:9 - This bitfield selects the negative input to the comparator."]
    #[inline(always)]
    pub fn nsel(&self) -> NSEL_R {
        NSEL_R::new(((self.bits >> 8) & 0x03) as u8)
    }
    #[doc = "Bits 0:1 - This bitfield selects the positive input to the comparator."]
    #[inline(always)]
    pub fn psel(&self) -> PSEL_R {
        PSEL_R::new((self.bits & 0x03) as u8)
    }
}
impl W {
    #[doc = "Bits 16:19 - When the reference input NSEL is set to NSEL_DAC, this bitfield selects the voltage level for the negative input to the comparator."]
    #[inline(always)]
    pub fn lvlsel(&mut self) -> LVLSEL_W {
        LVLSEL_W { w: self }
    }
    #[doc = "Bits 8:9 - This bitfield selects the negative input to the comparator."]
    #[inline(always)]
    pub fn nsel(&mut self) -> NSEL_W {
        NSEL_W { w: self }
    }
    #[doc = "Bits 0:1 - This bitfield selects the positive input to the comparator."]
    #[inline(always)]
    pub fn psel(&mut self) -> PSEL_W {
        PSEL_W { w: self }
    }
}