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
468
469
470
471
#[doc = "Reader of register OCTRL"]
pub type R = crate::R<u32, super::OCTRL>;
#[doc = "Writer for register OCTRL"]
pub type W = crate::W<u32, super::OCTRL>;
#[doc = "Register OCTRL `reset()`'s with value 0"]
impl crate::ResetValue for super::OCTRL {
    type Type = u32;
    #[inline(always)]
    fn reset_value() -> Self::Type {
        0
    }
}
#[doc = "Autocalibration control\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum ACAL_A {
    #[doc = "0: Disable Autocalibration"]
    DIS = 0,
    #[doc = "2: Autocalibrate every 1024 seconds"]
    _1024SEC = 2,
    #[doc = "3: Autocalibrate every 512 seconds"]
    _512SEC = 3,
    #[doc = "6: Frequency measurement using XT"]
    XTFREQ = 6,
    #[doc = "7: Frequency measurement using external clock"]
    EXTFREQ = 7,
}
impl From<ACAL_A> for u8 {
    #[inline(always)]
    fn from(variant: ACAL_A) -> Self {
        variant as _
    }
}
#[doc = "Reader of field `ACAL`"]
pub type ACAL_R = crate::R<u8, ACAL_A>;
impl ACAL_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> crate::Variant<u8, ACAL_A> {
        use crate::Variant::*;
        match self.bits {
            0 => Val(ACAL_A::DIS),
            2 => Val(ACAL_A::_1024SEC),
            3 => Val(ACAL_A::_512SEC),
            6 => Val(ACAL_A::XTFREQ),
            7 => Val(ACAL_A::EXTFREQ),
            i => Res(i),
        }
    }
    #[doc = "Checks if the value of the field is `DIS`"]
    #[inline(always)]
    pub fn is_dis(&self) -> bool {
        *self == ACAL_A::DIS
    }
    #[doc = "Checks if the value of the field is `_1024SEC`"]
    #[inline(always)]
    pub fn is_1024sec(&self) -> bool {
        *self == ACAL_A::_1024SEC
    }
    #[doc = "Checks if the value of the field is `_512SEC`"]
    #[inline(always)]
    pub fn is_512sec(&self) -> bool {
        *self == ACAL_A::_512SEC
    }
    #[doc = "Checks if the value of the field is `XTFREQ`"]
    #[inline(always)]
    pub fn is_xtfreq(&self) -> bool {
        *self == ACAL_A::XTFREQ
    }
    #[doc = "Checks if the value of the field is `EXTFREQ`"]
    #[inline(always)]
    pub fn is_extfreq(&self) -> bool {
        *self == ACAL_A::EXTFREQ
    }
}
#[doc = "Write proxy for field `ACAL`"]
pub struct ACAL_W<'a> {
    w: &'a mut W,
}
impl<'a> ACAL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: ACAL_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "Disable Autocalibration"]
    #[inline(always)]
    pub fn dis(self) -> &'a mut W {
        self.variant(ACAL_A::DIS)
    }
    #[doc = "Autocalibrate every 1024 seconds"]
    #[inline(always)]
    pub fn _1024sec(self) -> &'a mut W {
        self.variant(ACAL_A::_1024SEC)
    }
    #[doc = "Autocalibrate every 512 seconds"]
    #[inline(always)]
    pub fn _512sec(self) -> &'a mut W {
        self.variant(ACAL_A::_512SEC)
    }
    #[doc = "Frequency measurement using XT"]
    #[inline(always)]
    pub fn xtfreq(self) -> &'a mut W {
        self.variant(ACAL_A::XTFREQ)
    }
    #[doc = "Frequency measurement using external clock"]
    #[inline(always)]
    pub fn extfreq(self) -> &'a mut W {
        self.variant(ACAL_A::EXTFREQ)
    }
    #[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 & !(0x07 << 8)) | (((value as u32) & 0x07) << 8);
        self.w
    }
}
#[doc = "Selects the RTC oscillator (1 => LFRC, 0 => XT)\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OSEL_A {
    #[doc = "0: RTC uses the XT"]
    RTC_XT = 0,
    #[doc = "1: RTC uses the LFRC"]
    RTC_LFRC = 1,
}
impl From<OSEL_A> for bool {
    #[inline(always)]
    fn from(variant: OSEL_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `OSEL`"]
pub type OSEL_R = crate::R<bool, OSEL_A>;
impl OSEL_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OSEL_A {
        match self.bits {
            false => OSEL_A::RTC_XT,
            true => OSEL_A::RTC_LFRC,
        }
    }
    #[doc = "Checks if the value of the field is `RTC_XT`"]
    #[inline(always)]
    pub fn is_rtc_xt(&self) -> bool {
        *self == OSEL_A::RTC_XT
    }
    #[doc = "Checks if the value of the field is `RTC_LFRC`"]
    #[inline(always)]
    pub fn is_rtc_lfrc(&self) -> bool {
        *self == OSEL_A::RTC_LFRC
    }
}
#[doc = "Write proxy for field `OSEL`"]
pub struct OSEL_W<'a> {
    w: &'a mut W,
}
impl<'a> OSEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OSEL_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "RTC uses the XT"]
    #[inline(always)]
    pub fn rtc_xt(self) -> &'a mut W {
        self.variant(OSEL_A::RTC_XT)
    }
    #[doc = "RTC uses the LFRC"]
    #[inline(always)]
    pub fn rtc_lfrc(self) -> &'a mut W {
        self.variant(OSEL_A::RTC_LFRC)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
        self.w
    }
}
#[doc = "Oscillator switch on failure function\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum FOS_A {
    #[doc = "0: Disable the oscillator switch on failure function"]
    DIS = 0,
    #[doc = "1: Enable the oscillator switch on failure function"]
    EN = 1,
}
impl From<FOS_A> for bool {
    #[inline(always)]
    fn from(variant: FOS_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `FOS`"]
pub type FOS_R = crate::R<bool, FOS_A>;
impl FOS_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> FOS_A {
        match self.bits {
            false => FOS_A::DIS,
            true => FOS_A::EN,
        }
    }
    #[doc = "Checks if the value of the field is `DIS`"]
    #[inline(always)]
    pub fn is_dis(&self) -> bool {
        *self == FOS_A::DIS
    }
    #[doc = "Checks if the value of the field is `EN`"]
    #[inline(always)]
    pub fn is_en(&self) -> bool {
        *self == FOS_A::EN
    }
}
#[doc = "Write proxy for field `FOS`"]
pub struct FOS_W<'a> {
    w: &'a mut W,
}
impl<'a> FOS_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: FOS_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "Disable the oscillator switch on failure function"]
    #[inline(always)]
    pub fn dis(self) -> &'a mut W {
        self.variant(FOS_A::DIS)
    }
    #[doc = "Enable the oscillator switch on failure function"]
    #[inline(always)]
    pub fn en(self) -> &'a mut W {
        self.variant(FOS_A::EN)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
        self.w
    }
}
#[doc = "Stop the LFRC Oscillator to the RTC\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STOPRC_A {
    #[doc = "0: Enable the LFRC Oscillator to drive the RTC"]
    EN = 0,
    #[doc = "1: Stop the LFRC Oscillator when driving the RTC"]
    STOP = 1,
}
impl From<STOPRC_A> for bool {
    #[inline(always)]
    fn from(variant: STOPRC_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `STOPRC`"]
pub type STOPRC_R = crate::R<bool, STOPRC_A>;
impl STOPRC_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> STOPRC_A {
        match self.bits {
            false => STOPRC_A::EN,
            true => STOPRC_A::STOP,
        }
    }
    #[doc = "Checks if the value of the field is `EN`"]
    #[inline(always)]
    pub fn is_en(&self) -> bool {
        *self == STOPRC_A::EN
    }
    #[doc = "Checks if the value of the field is `STOP`"]
    #[inline(always)]
    pub fn is_stop(&self) -> bool {
        *self == STOPRC_A::STOP
    }
}
#[doc = "Write proxy for field `STOPRC`"]
pub struct STOPRC_W<'a> {
    w: &'a mut W,
}
impl<'a> STOPRC_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: STOPRC_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "Enable the LFRC Oscillator to drive the RTC"]
    #[inline(always)]
    pub fn en(self) -> &'a mut W {
        self.variant(STOPRC_A::EN)
    }
    #[doc = "Stop the LFRC Oscillator when driving the RTC"]
    #[inline(always)]
    pub fn stop(self) -> &'a mut W {
        self.variant(STOPRC_A::STOP)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
        self.w
    }
}
#[doc = "Stop the XT Oscillator to the RTC\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STOPXT_A {
    #[doc = "0: Enable the XT Oscillator to drive the RTC"]
    EN = 0,
    #[doc = "1: Stop the XT Oscillator when driving the RTC"]
    STOP = 1,
}
impl From<STOPXT_A> for bool {
    #[inline(always)]
    fn from(variant: STOPXT_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `STOPXT`"]
pub type STOPXT_R = crate::R<bool, STOPXT_A>;
impl STOPXT_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> STOPXT_A {
        match self.bits {
            false => STOPXT_A::EN,
            true => STOPXT_A::STOP,
        }
    }
    #[doc = "Checks if the value of the field is `EN`"]
    #[inline(always)]
    pub fn is_en(&self) -> bool {
        *self == STOPXT_A::EN
    }
    #[doc = "Checks if the value of the field is `STOP`"]
    #[inline(always)]
    pub fn is_stop(&self) -> bool {
        *self == STOPXT_A::STOP
    }
}
#[doc = "Write proxy for field `STOPXT`"]
pub struct STOPXT_W<'a> {
    w: &'a mut W,
}
impl<'a> STOPXT_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: STOPXT_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "Enable the XT Oscillator to drive the RTC"]
    #[inline(always)]
    pub fn en(self) -> &'a mut W {
        self.variant(STOPXT_A::EN)
    }
    #[doc = "Stop the XT Oscillator when driving the RTC"]
    #[inline(always)]
    pub fn stop(self) -> &'a mut W {
        self.variant(STOPXT_A::STOP)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
        self.w
    }
}
impl R {
    #[doc = "Bits 8:10 - Autocalibration control"]
    #[inline(always)]
    pub fn acal(&self) -> ACAL_R {
        ACAL_R::new(((self.bits >> 8) & 0x07) as u8)
    }
    #[doc = "Bit 7 - Selects the RTC oscillator (1 => LFRC, 0 => XT)"]
    #[inline(always)]
    pub fn osel(&self) -> OSEL_R {
        OSEL_R::new(((self.bits >> 7) & 0x01) != 0)
    }
    #[doc = "Bit 6 - Oscillator switch on failure function"]
    #[inline(always)]
    pub fn fos(&self) -> FOS_R {
        FOS_R::new(((self.bits >> 6) & 0x01) != 0)
    }
    #[doc = "Bit 1 - Stop the LFRC Oscillator to the RTC"]
    #[inline(always)]
    pub fn stoprc(&self) -> STOPRC_R {
        STOPRC_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bit 0 - Stop the XT Oscillator to the RTC"]
    #[inline(always)]
    pub fn stopxt(&self) -> STOPXT_R {
        STOPXT_R::new((self.bits & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bits 8:10 - Autocalibration control"]
    #[inline(always)]
    pub fn acal(&mut self) -> ACAL_W {
        ACAL_W { w: self }
    }
    #[doc = "Bit 7 - Selects the RTC oscillator (1 => LFRC, 0 => XT)"]
    #[inline(always)]
    pub fn osel(&mut self) -> OSEL_W {
        OSEL_W { w: self }
    }
    #[doc = "Bit 6 - Oscillator switch on failure function"]
    #[inline(always)]
    pub fn fos(&mut self) -> FOS_W {
        FOS_W { w: self }
    }
    #[doc = "Bit 1 - Stop the LFRC Oscillator to the RTC"]
    #[inline(always)]
    pub fn stoprc(&mut self) -> STOPRC_W {
        STOPRC_W { w: self }
    }
    #[doc = "Bit 0 - Stop the XT Oscillator to the RTC"]
    #[inline(always)]
    pub fn stopxt(&mut self) -> STOPXT_W {
        STOPXT_W { w: self }
    }
}