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
#[doc = "Reader of register HFADJ"]
pub type R = crate::R<u32, super::HFADJ>;
#[doc = "Writer for register HFADJ"]
pub type W = crate::W<u32, super::HFADJ>;
#[doc = "Register HFADJ `reset()`'s with value 0"]
impl crate::ResetValue for super::HFADJ {
    type Type = u32;
    #[inline(always)]
    fn reset_value() -> Self::Type {
        0
    }
}
#[doc = "XT warmup period for HFRC adjustment\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HFWARMUP_A {
    #[doc = "0: Autoadjust XT warmup period = 1-2 seconds"]
    _1SEC = 0,
    #[doc = "1: Autoadjust XT warmup period = 2-4 seconds"]
    _2SEC = 1,
}
impl From<HFWARMUP_A> for bool {
    #[inline(always)]
    fn from(variant: HFWARMUP_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `HFWARMUP`"]
pub type HFWARMUP_R = crate::R<bool, HFWARMUP_A>;
impl HFWARMUP_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HFWARMUP_A {
        match self.bits {
            false => HFWARMUP_A::_1SEC,
            true => HFWARMUP_A::_2SEC,
        }
    }
    #[doc = "Checks if the value of the field is `_1SEC`"]
    #[inline(always)]
    pub fn is_1sec(&self) -> bool {
        *self == HFWARMUP_A::_1SEC
    }
    #[doc = "Checks if the value of the field is `_2SEC`"]
    #[inline(always)]
    pub fn is_2sec(&self) -> bool {
        *self == HFWARMUP_A::_2SEC
    }
}
#[doc = "Write proxy for field `HFWARMUP`"]
pub struct HFWARMUP_W<'a> {
    w: &'a mut W,
}
impl<'a> HFWARMUP_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HFWARMUP_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "Autoadjust XT warmup period = 1-2 seconds"]
    #[inline(always)]
    pub fn _1sec(self) -> &'a mut W {
        self.variant(HFWARMUP_A::_1SEC)
    }
    #[doc = "Autoadjust XT warmup period = 2-4 seconds"]
    #[inline(always)]
    pub fn _2sec(self) -> &'a mut W {
        self.variant(HFWARMUP_A::_2SEC)
    }
    #[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 << 19)) | (((value as u32) & 0x01) << 19);
        self.w
    }
}
#[doc = "Reader of field `HFXTADJ`"]
pub type HFXTADJ_R = crate::R<u16, u16>;
#[doc = "Write proxy for field `HFXTADJ`"]
pub struct HFXTADJ_W<'a> {
    w: &'a mut W,
}
impl<'a> HFXTADJ_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u16) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x07ff << 8)) | (((value as u32) & 0x07ff) << 8);
        self.w
    }
}
#[doc = "Repeat period for HFRC adjustment\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum HFADJCK_A {
    #[doc = "0: Autoadjust repeat period = 4 seconds"]
    _4SEC = 0,
    #[doc = "1: Autoadjust repeat period = 16 seconds"]
    _16SEC = 1,
    #[doc = "2: Autoadjust repeat period = 32 seconds"]
    _32SEC = 2,
    #[doc = "3: Autoadjust repeat period = 64 seconds"]
    _64SEC = 3,
    #[doc = "4: Autoadjust repeat period = 128 seconds"]
    _128SEC = 4,
    #[doc = "5: Autoadjust repeat period = 256 seconds"]
    _256SEC = 5,
    #[doc = "6: Autoadjust repeat period = 512 seconds"]
    _512SEC = 6,
    #[doc = "7: Autoadjust repeat period = 1024 seconds"]
    _1024SEC = 7,
}
impl From<HFADJCK_A> for u8 {
    #[inline(always)]
    fn from(variant: HFADJCK_A) -> Self {
        variant as _
    }
}
#[doc = "Reader of field `HFADJCK`"]
pub type HFADJCK_R = crate::R<u8, HFADJCK_A>;
impl HFADJCK_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HFADJCK_A {
        match self.bits {
            0 => HFADJCK_A::_4SEC,
            1 => HFADJCK_A::_16SEC,
            2 => HFADJCK_A::_32SEC,
            3 => HFADJCK_A::_64SEC,
            4 => HFADJCK_A::_128SEC,
            5 => HFADJCK_A::_256SEC,
            6 => HFADJCK_A::_512SEC,
            7 => HFADJCK_A::_1024SEC,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `_4SEC`"]
    #[inline(always)]
    pub fn is_4sec(&self) -> bool {
        *self == HFADJCK_A::_4SEC
    }
    #[doc = "Checks if the value of the field is `_16SEC`"]
    #[inline(always)]
    pub fn is_16sec(&self) -> bool {
        *self == HFADJCK_A::_16SEC
    }
    #[doc = "Checks if the value of the field is `_32SEC`"]
    #[inline(always)]
    pub fn is_32sec(&self) -> bool {
        *self == HFADJCK_A::_32SEC
    }
    #[doc = "Checks if the value of the field is `_64SEC`"]
    #[inline(always)]
    pub fn is_64sec(&self) -> bool {
        *self == HFADJCK_A::_64SEC
    }
    #[doc = "Checks if the value of the field is `_128SEC`"]
    #[inline(always)]
    pub fn is_128sec(&self) -> bool {
        *self == HFADJCK_A::_128SEC
    }
    #[doc = "Checks if the value of the field is `_256SEC`"]
    #[inline(always)]
    pub fn is_256sec(&self) -> bool {
        *self == HFADJCK_A::_256SEC
    }
    #[doc = "Checks if the value of the field is `_512SEC`"]
    #[inline(always)]
    pub fn is_512sec(&self) -> bool {
        *self == HFADJCK_A::_512SEC
    }
    #[doc = "Checks if the value of the field is `_1024SEC`"]
    #[inline(always)]
    pub fn is_1024sec(&self) -> bool {
        *self == HFADJCK_A::_1024SEC
    }
}
#[doc = "Write proxy for field `HFADJCK`"]
pub struct HFADJCK_W<'a> {
    w: &'a mut W,
}
impl<'a> HFADJCK_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HFADJCK_A) -> &'a mut W {
        {
            self.bits(variant.into())
        }
    }
    #[doc = "Autoadjust repeat period = 4 seconds"]
    #[inline(always)]
    pub fn _4sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_4SEC)
    }
    #[doc = "Autoadjust repeat period = 16 seconds"]
    #[inline(always)]
    pub fn _16sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_16SEC)
    }
    #[doc = "Autoadjust repeat period = 32 seconds"]
    #[inline(always)]
    pub fn _32sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_32SEC)
    }
    #[doc = "Autoadjust repeat period = 64 seconds"]
    #[inline(always)]
    pub fn _64sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_64SEC)
    }
    #[doc = "Autoadjust repeat period = 128 seconds"]
    #[inline(always)]
    pub fn _128sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_128SEC)
    }
    #[doc = "Autoadjust repeat period = 256 seconds"]
    #[inline(always)]
    pub fn _256sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_256SEC)
    }
    #[doc = "Autoadjust repeat period = 512 seconds"]
    #[inline(always)]
    pub fn _512sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_512SEC)
    }
    #[doc = "Autoadjust repeat period = 1024 seconds"]
    #[inline(always)]
    pub fn _1024sec(self) -> &'a mut W {
        self.variant(HFADJCK_A::_1024SEC)
    }
    #[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 & !(0x07 << 1)) | (((value as u32) & 0x07) << 1);
        self.w
    }
}
#[doc = "HFRC adjustment control\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HFADJEN_A {
    #[doc = "0: Disable the HFRC adjustment"]
    DIS = 0,
    #[doc = "1: Enable the HFRC adjustment"]
    EN = 1,
}
impl From<HFADJEN_A> for bool {
    #[inline(always)]
    fn from(variant: HFADJEN_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Reader of field `HFADJEN`"]
pub type HFADJEN_R = crate::R<bool, HFADJEN_A>;
impl HFADJEN_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HFADJEN_A {
        match self.bits {
            false => HFADJEN_A::DIS,
            true => HFADJEN_A::EN,
        }
    }
    #[doc = "Checks if the value of the field is `DIS`"]
    #[inline(always)]
    pub fn is_dis(&self) -> bool {
        *self == HFADJEN_A::DIS
    }
    #[doc = "Checks if the value of the field is `EN`"]
    #[inline(always)]
    pub fn is_en(&self) -> bool {
        *self == HFADJEN_A::EN
    }
}
#[doc = "Write proxy for field `HFADJEN`"]
pub struct HFADJEN_W<'a> {
    w: &'a mut W,
}
impl<'a> HFADJEN_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HFADJEN_A) -> &'a mut W {
        {
            self.bit(variant.into())
        }
    }
    #[doc = "Disable the HFRC adjustment"]
    #[inline(always)]
    pub fn dis(self) -> &'a mut W {
        self.variant(HFADJEN_A::DIS)
    }
    #[doc = "Enable the HFRC adjustment"]
    #[inline(always)]
    pub fn en(self) -> &'a mut W {
        self.variant(HFADJEN_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) | ((value as u32) & 0x01);
        self.w
    }
}
impl R {
    #[doc = "Bit 19 - XT warmup period for HFRC adjustment"]
    #[inline(always)]
    pub fn hfwarmup(&self) -> HFWARMUP_R {
        HFWARMUP_R::new(((self.bits >> 19) & 0x01) != 0)
    }
    #[doc = "Bits 8:18 - Target HFRC adjustment value."]
    #[inline(always)]
    pub fn hfxtadj(&self) -> HFXTADJ_R {
        HFXTADJ_R::new(((self.bits >> 8) & 0x07ff) as u16)
    }
    #[doc = "Bits 1:3 - Repeat period for HFRC adjustment"]
    #[inline(always)]
    pub fn hfadjck(&self) -> HFADJCK_R {
        HFADJCK_R::new(((self.bits >> 1) & 0x07) as u8)
    }
    #[doc = "Bit 0 - HFRC adjustment control"]
    #[inline(always)]
    pub fn hfadjen(&self) -> HFADJEN_R {
        HFADJEN_R::new((self.bits & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bit 19 - XT warmup period for HFRC adjustment"]
    #[inline(always)]
    pub fn hfwarmup(&mut self) -> HFWARMUP_W {
        HFWARMUP_W { w: self }
    }
    #[doc = "Bits 8:18 - Target HFRC adjustment value."]
    #[inline(always)]
    pub fn hfxtadj(&mut self) -> HFXTADJ_W {
        HFXTADJ_W { w: self }
    }
    #[doc = "Bits 1:3 - Repeat period for HFRC adjustment"]
    #[inline(always)]
    pub fn hfadjck(&mut self) -> HFADJCK_W {
        HFADJCK_W { w: self }
    }
    #[doc = "Bit 0 - HFRC adjustment control"]
    #[inline(always)]
    pub fn hfadjen(&mut self) -> HFADJEN_W {
        HFADJEN_W { w: self }
    }
}