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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
#[doc = "Register `BUCTRL` reader"]
pub struct R(crate::R<BUCTRL_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<BUCTRL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl From<crate::R<BUCTRL_SPEC>> for R {
    #[inline(always)]
    fn from(reader: crate::R<BUCTRL_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `BUCTRL` writer"]
pub struct W(crate::W<BUCTRL_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<BUCTRL_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<BUCTRL_SPEC>> for W {
    #[inline(always)]
    fn from(writer: crate::W<BUCTRL_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `EN` reader - Enable Backup Mode"]
pub type EN_R = crate::BitReader<bool>;
#[doc = "Field `EN` writer - Enable Backup Mode"]
pub type EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
#[doc = "Field `STATEN` reader - Enable Backup Mode Status Export"]
pub type STATEN_R = crate::BitReader<bool>;
#[doc = "Field `STATEN` writer - Enable Backup Mode Status Export"]
pub type STATEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
#[doc = "Field `BUVINPROBEEN` reader - Enable BU_VIN Probing"]
pub type BUVINPROBEEN_R = crate::BitReader<bool>;
#[doc = "Field `BUVINPROBEEN` writer - Enable BU_VIN Probing"]
pub type BUVINPROBEEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
#[doc = "Field `VOUTRES` reader - BU_VOUT Resistor Select"]
pub type VOUTRES_R = crate::FieldReader<u8, VOUTRES_A>;
#[doc = "BU_VOUT Resistor Select\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum VOUTRES_A {
    #[doc = "0: BU_VOUT is not connected"]
    DIS = 0,
    #[doc = "1: Enable weak switch between BU_VOUT and backup domain power supply."]
    WEAK = 1,
    #[doc = "2: Enable medium switch between BU_VOUT and backup domain power supply."]
    MED = 2,
    #[doc = "3: Enable strong switch between BU_VOUT and backup domain power supply."]
    STRONG = 3,
}
impl From<VOUTRES_A> for u8 {
    #[inline(always)]
    fn from(variant: VOUTRES_A) -> Self {
        variant as _
    }
}
impl VOUTRES_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> VOUTRES_A {
        match self.bits {
            0 => VOUTRES_A::DIS,
            1 => VOUTRES_A::WEAK,
            2 => VOUTRES_A::MED,
            3 => VOUTRES_A::STRONG,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `DIS`"]
    #[inline(always)]
    pub fn is_dis(&self) -> bool {
        *self == VOUTRES_A::DIS
    }
    #[doc = "Checks if the value of the field is `WEAK`"]
    #[inline(always)]
    pub fn is_weak(&self) -> bool {
        *self == VOUTRES_A::WEAK
    }
    #[doc = "Checks if the value of the field is `MED`"]
    #[inline(always)]
    pub fn is_med(&self) -> bool {
        *self == VOUTRES_A::MED
    }
    #[doc = "Checks if the value of the field is `STRONG`"]
    #[inline(always)]
    pub fn is_strong(&self) -> bool {
        *self == VOUTRES_A::STRONG
    }
}
#[doc = "Field `VOUTRES` writer - BU_VOUT Resistor Select"]
pub type VOUTRES_W<'a, const O: u8> =
    crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, VOUTRES_A, 2, O>;
impl<'a, const O: u8> VOUTRES_W<'a, O> {
    #[doc = "BU_VOUT is not connected"]
    #[inline(always)]
    pub fn dis(self) -> &'a mut W {
        self.variant(VOUTRES_A::DIS)
    }
    #[doc = "Enable weak switch between BU_VOUT and backup domain power supply."]
    #[inline(always)]
    pub fn weak(self) -> &'a mut W {
        self.variant(VOUTRES_A::WEAK)
    }
    #[doc = "Enable medium switch between BU_VOUT and backup domain power supply."]
    #[inline(always)]
    pub fn med(self) -> &'a mut W {
        self.variant(VOUTRES_A::MED)
    }
    #[doc = "Enable strong switch between BU_VOUT and backup domain power supply."]
    #[inline(always)]
    pub fn strong(self) -> &'a mut W {
        self.variant(VOUTRES_A::STRONG)
    }
}
#[doc = "Field `PWRRES` reader - Power Domain Resistor Select"]
pub type PWRRES_R = crate::FieldReader<u8, PWRRES_A>;
#[doc = "Power Domain Resistor Select\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PWRRES_A {
    #[doc = "0: Main power and backup power connected with RES0 series resistance."]
    RES0 = 0,
    #[doc = "1: Main power and backup power connected with RES1 series resistance."]
    RES1 = 1,
    #[doc = "2: Main power and backup power connected with RES2 series resistance."]
    RES2 = 2,
    #[doc = "3: Main power and backup power connected with RES3 series resistance."]
    RES3 = 3,
}
impl From<PWRRES_A> for u8 {
    #[inline(always)]
    fn from(variant: PWRRES_A) -> Self {
        variant as _
    }
}
impl PWRRES_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PWRRES_A {
        match self.bits {
            0 => PWRRES_A::RES0,
            1 => PWRRES_A::RES1,
            2 => PWRRES_A::RES2,
            3 => PWRRES_A::RES3,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `RES0`"]
    #[inline(always)]
    pub fn is_res0(&self) -> bool {
        *self == PWRRES_A::RES0
    }
    #[doc = "Checks if the value of the field is `RES1`"]
    #[inline(always)]
    pub fn is_res1(&self) -> bool {
        *self == PWRRES_A::RES1
    }
    #[doc = "Checks if the value of the field is `RES2`"]
    #[inline(always)]
    pub fn is_res2(&self) -> bool {
        *self == PWRRES_A::RES2
    }
    #[doc = "Checks if the value of the field is `RES3`"]
    #[inline(always)]
    pub fn is_res3(&self) -> bool {
        *self == PWRRES_A::RES3
    }
}
#[doc = "Field `PWRRES` writer - Power Domain Resistor Select"]
pub type PWRRES_W<'a, const O: u8> =
    crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, PWRRES_A, 2, O>;
impl<'a, const O: u8> PWRRES_W<'a, O> {
    #[doc = "Main power and backup power connected with RES0 series resistance."]
    #[inline(always)]
    pub fn res0(self) -> &'a mut W {
        self.variant(PWRRES_A::RES0)
    }
    #[doc = "Main power and backup power connected with RES1 series resistance."]
    #[inline(always)]
    pub fn res1(self) -> &'a mut W {
        self.variant(PWRRES_A::RES1)
    }
    #[doc = "Main power and backup power connected with RES2 series resistance."]
    #[inline(always)]
    pub fn res2(self) -> &'a mut W {
        self.variant(PWRRES_A::RES2)
    }
    #[doc = "Main power and backup power connected with RES3 series resistance."]
    #[inline(always)]
    pub fn res3(self) -> &'a mut W {
        self.variant(PWRRES_A::RES3)
    }
}
#[doc = "Field `BUACTPWRCON` reader - Power Connection Configuration in Backup Mode"]
pub type BUACTPWRCON_R = crate::FieldReader<u8, BUACTPWRCON_A>;
#[doc = "Power Connection Configuration in Backup Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum BUACTPWRCON_A {
    #[doc = "0: No connection."]
    NONE = 0,
    #[doc = "1: Main power and backup power are connected through a diode, allowing current to flow from backup power source to main power source, but not the other way."]
    MAINBU = 1,
    #[doc = "2: Main power and backup power are connected through a diode, allowing current to flow from main power source to backup power source, but not the other way."]
    BUMAIN = 2,
    #[doc = "3: Main power and backup power are connected without diode."]
    NODIODE = 3,
}
impl From<BUACTPWRCON_A> for u8 {
    #[inline(always)]
    fn from(variant: BUACTPWRCON_A) -> Self {
        variant as _
    }
}
impl BUACTPWRCON_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> BUACTPWRCON_A {
        match self.bits {
            0 => BUACTPWRCON_A::NONE,
            1 => BUACTPWRCON_A::MAINBU,
            2 => BUACTPWRCON_A::BUMAIN,
            3 => BUACTPWRCON_A::NODIODE,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `NONE`"]
    #[inline(always)]
    pub fn is_none(&self) -> bool {
        *self == BUACTPWRCON_A::NONE
    }
    #[doc = "Checks if the value of the field is `MAINBU`"]
    #[inline(always)]
    pub fn is_mainbu(&self) -> bool {
        *self == BUACTPWRCON_A::MAINBU
    }
    #[doc = "Checks if the value of the field is `BUMAIN`"]
    #[inline(always)]
    pub fn is_bumain(&self) -> bool {
        *self == BUACTPWRCON_A::BUMAIN
    }
    #[doc = "Checks if the value of the field is `NODIODE`"]
    #[inline(always)]
    pub fn is_nodiode(&self) -> bool {
        *self == BUACTPWRCON_A::NODIODE
    }
}
#[doc = "Field `BUACTPWRCON` writer - Power Connection Configuration in Backup Mode"]
pub type BUACTPWRCON_W<'a, const O: u8> =
    crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, BUACTPWRCON_A, 2, O>;
impl<'a, const O: u8> BUACTPWRCON_W<'a, O> {
    #[doc = "No connection."]
    #[inline(always)]
    pub fn none(self) -> &'a mut W {
        self.variant(BUACTPWRCON_A::NONE)
    }
    #[doc = "Main power and backup power are connected through a diode, allowing current to flow from backup power source to main power source, but not the other way."]
    #[inline(always)]
    pub fn mainbu(self) -> &'a mut W {
        self.variant(BUACTPWRCON_A::MAINBU)
    }
    #[doc = "Main power and backup power are connected through a diode, allowing current to flow from main power source to backup power source, but not the other way."]
    #[inline(always)]
    pub fn bumain(self) -> &'a mut W {
        self.variant(BUACTPWRCON_A::BUMAIN)
    }
    #[doc = "Main power and backup power are connected without diode."]
    #[inline(always)]
    pub fn nodiode(self) -> &'a mut W {
        self.variant(BUACTPWRCON_A::NODIODE)
    }
}
#[doc = "Field `BUINACTPWRCON` reader - Power Connection Configuration When Not in Backup Mode"]
pub type BUINACTPWRCON_R = crate::FieldReader<u8, BUINACTPWRCON_A>;
#[doc = "Power Connection Configuration When Not in Backup Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum BUINACTPWRCON_A {
    #[doc = "0: No connection."]
    NONE = 0,
    #[doc = "1: Main power and backup power are connected through a diode, allowing current to flow from main power source to backup power source, but not the other way."]
    MAINBU = 1,
    #[doc = "2: Main power and backup power are connected through a diode, allowing current to flow from backup power source to main power source, but not the other way."]
    BUMAIN = 2,
    #[doc = "3: Main power and backup power are connected without diode."]
    NODIODE = 3,
}
impl From<BUINACTPWRCON_A> for u8 {
    #[inline(always)]
    fn from(variant: BUINACTPWRCON_A) -> Self {
        variant as _
    }
}
impl BUINACTPWRCON_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> BUINACTPWRCON_A {
        match self.bits {
            0 => BUINACTPWRCON_A::NONE,
            1 => BUINACTPWRCON_A::MAINBU,
            2 => BUINACTPWRCON_A::BUMAIN,
            3 => BUINACTPWRCON_A::NODIODE,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `NONE`"]
    #[inline(always)]
    pub fn is_none(&self) -> bool {
        *self == BUINACTPWRCON_A::NONE
    }
    #[doc = "Checks if the value of the field is `MAINBU`"]
    #[inline(always)]
    pub fn is_mainbu(&self) -> bool {
        *self == BUINACTPWRCON_A::MAINBU
    }
    #[doc = "Checks if the value of the field is `BUMAIN`"]
    #[inline(always)]
    pub fn is_bumain(&self) -> bool {
        *self == BUINACTPWRCON_A::BUMAIN
    }
    #[doc = "Checks if the value of the field is `NODIODE`"]
    #[inline(always)]
    pub fn is_nodiode(&self) -> bool {
        *self == BUINACTPWRCON_A::NODIODE
    }
}
#[doc = "Field `BUINACTPWRCON` writer - Power Connection Configuration When Not in Backup Mode"]
pub type BUINACTPWRCON_W<'a, const O: u8> =
    crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, BUINACTPWRCON_A, 2, O>;
impl<'a, const O: u8> BUINACTPWRCON_W<'a, O> {
    #[doc = "No connection."]
    #[inline(always)]
    pub fn none(self) -> &'a mut W {
        self.variant(BUINACTPWRCON_A::NONE)
    }
    #[doc = "Main power and backup power are connected through a diode, allowing current to flow from main power source to backup power source, but not the other way."]
    #[inline(always)]
    pub fn mainbu(self) -> &'a mut W {
        self.variant(BUINACTPWRCON_A::MAINBU)
    }
    #[doc = "Main power and backup power are connected through a diode, allowing current to flow from backup power source to main power source, but not the other way."]
    #[inline(always)]
    pub fn bumain(self) -> &'a mut W {
        self.variant(BUINACTPWRCON_A::BUMAIN)
    }
    #[doc = "Main power and backup power are connected without diode."]
    #[inline(always)]
    pub fn nodiode(self) -> &'a mut W {
        self.variant(BUINACTPWRCON_A::NODIODE)
    }
}
#[doc = "Field `DISMAXCOMP` reader - Disable MAIN-BU Comparator"]
pub type DISMAXCOMP_R = crate::BitReader<bool>;
#[doc = "Field `DISMAXCOMP` writer - Disable MAIN-BU Comparator"]
pub type DISMAXCOMP_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
impl R {
    #[doc = "Bit 0 - Enable Backup Mode"]
    #[inline(always)]
    pub fn en(&self) -> EN_R {
        EN_R::new((self.bits & 1) != 0)
    }
    #[doc = "Bit 1 - Enable Backup Mode Status Export"]
    #[inline(always)]
    pub fn staten(&self) -> STATEN_R {
        STATEN_R::new(((self.bits >> 1) & 1) != 0)
    }
    #[doc = "Bit 2 - Enable BU_VIN Probing"]
    #[inline(always)]
    pub fn buvinprobeen(&self) -> BUVINPROBEEN_R {
        BUVINPROBEEN_R::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bits 8:9 - BU_VOUT Resistor Select"]
    #[inline(always)]
    pub fn voutres(&self) -> VOUTRES_R {
        VOUTRES_R::new(((self.bits >> 8) & 3) as u8)
    }
    #[doc = "Bits 12:13 - Power Domain Resistor Select"]
    #[inline(always)]
    pub fn pwrres(&self) -> PWRRES_R {
        PWRRES_R::new(((self.bits >> 12) & 3) as u8)
    }
    #[doc = "Bits 16:17 - Power Connection Configuration in Backup Mode"]
    #[inline(always)]
    pub fn buactpwrcon(&self) -> BUACTPWRCON_R {
        BUACTPWRCON_R::new(((self.bits >> 16) & 3) as u8)
    }
    #[doc = "Bits 20:21 - Power Connection Configuration When Not in Backup Mode"]
    #[inline(always)]
    pub fn buinactpwrcon(&self) -> BUINACTPWRCON_R {
        BUINACTPWRCON_R::new(((self.bits >> 20) & 3) as u8)
    }
    #[doc = "Bit 31 - Disable MAIN-BU Comparator"]
    #[inline(always)]
    pub fn dismaxcomp(&self) -> DISMAXCOMP_R {
        DISMAXCOMP_R::new(((self.bits >> 31) & 1) != 0)
    }
}
impl W {
    #[doc = "Bit 0 - Enable Backup Mode"]
    #[inline(always)]
    #[must_use]
    pub fn en(&mut self) -> EN_W<0> {
        EN_W::new(self)
    }
    #[doc = "Bit 1 - Enable Backup Mode Status Export"]
    #[inline(always)]
    #[must_use]
    pub fn staten(&mut self) -> STATEN_W<1> {
        STATEN_W::new(self)
    }
    #[doc = "Bit 2 - Enable BU_VIN Probing"]
    #[inline(always)]
    #[must_use]
    pub fn buvinprobeen(&mut self) -> BUVINPROBEEN_W<2> {
        BUVINPROBEEN_W::new(self)
    }
    #[doc = "Bits 8:9 - BU_VOUT Resistor Select"]
    #[inline(always)]
    #[must_use]
    pub fn voutres(&mut self) -> VOUTRES_W<8> {
        VOUTRES_W::new(self)
    }
    #[doc = "Bits 12:13 - Power Domain Resistor Select"]
    #[inline(always)]
    #[must_use]
    pub fn pwrres(&mut self) -> PWRRES_W<12> {
        PWRRES_W::new(self)
    }
    #[doc = "Bits 16:17 - Power Connection Configuration in Backup Mode"]
    #[inline(always)]
    #[must_use]
    pub fn buactpwrcon(&mut self) -> BUACTPWRCON_W<16> {
        BUACTPWRCON_W::new(self)
    }
    #[doc = "Bits 20:21 - Power Connection Configuration When Not in Backup Mode"]
    #[inline(always)]
    #[must_use]
    pub fn buinactpwrcon(&mut self) -> BUINACTPWRCON_W<20> {
        BUINACTPWRCON_W::new(self)
    }
    #[doc = "Bit 31 - Disable MAIN-BU Comparator"]
    #[inline(always)]
    #[must_use]
    pub fn dismaxcomp(&mut self) -> DISMAXCOMP_W<31> {
        DISMAXCOMP_W::new(self)
    }
    #[doc = "Writes raw bits to the register."]
    #[inline(always)]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "Backup Power Configuration 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 [buctrl](index.html) module"]
pub struct BUCTRL_SPEC;
impl crate::RegisterSpec for BUCTRL_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [buctrl::R](R) reader structure"]
impl crate::Readable for BUCTRL_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [buctrl::W](W) writer structure"]
impl crate::Writable for BUCTRL_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 BUCTRL to value 0"]
impl crate::Resettable for BUCTRL_SPEC {
    const RESET_VALUE: Self::Ux = 0;
}