1#[doc = "Register `BUCTRL` reader"]
2pub struct R(crate::R<BUCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BUCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BUCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BUCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BUCTRL` writer"]
17pub struct W(crate::W<BUCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BUCTRL_SPEC>;
20 #[inline(always)]
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::ops::DerefMut for W {
26 #[inline(always)]
27 fn deref_mut(&mut self) -> &mut Self::Target {
28 &mut self.0
29 }
30}
31impl From<crate::W<BUCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BUCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EN` reader - Enable Backup Mode"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - Enable Backup Mode"]
40pub type EN_W<'a> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 0>;
41#[doc = "Field `STATEN` reader - Enable Backup Mode Status Export"]
42pub type STATEN_R = crate::BitReader<bool>;
43#[doc = "Field `STATEN` writer - Enable Backup Mode Status Export"]
44pub type STATEN_W<'a> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 1>;
45#[doc = "Field `BUVINPROBEEN` reader - Enable BU_VIN Probing"]
46pub type BUVINPROBEEN_R = crate::BitReader<bool>;
47#[doc = "Field `BUVINPROBEEN` writer - Enable BU_VIN Probing"]
48pub type BUVINPROBEEN_W<'a> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 2>;
49#[doc = "BU_VOUT Resistor Select\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[repr(u8)]
52pub enum VOUTRES_A {
53 #[doc = "0: BU_VOUT is not connected"]
54 DIS = 0,
55 #[doc = "1: Enable weak switch between BU_VOUT and backup domain power supply."]
56 WEAK = 1,
57 #[doc = "2: Enable medium switch between BU_VOUT and backup domain power supply."]
58 MED = 2,
59 #[doc = "3: Enable strong switch between BU_VOUT and backup domain power supply."]
60 STRONG = 3,
61}
62impl From<VOUTRES_A> for u8 {
63 #[inline(always)]
64 fn from(variant: VOUTRES_A) -> Self {
65 variant as _
66 }
67}
68#[doc = "Field `VOUTRES` reader - BU_VOUT Resistor Select"]
69pub type VOUTRES_R = crate::FieldReader<u8, VOUTRES_A>;
70impl VOUTRES_R {
71 #[doc = "Get enumerated values variant"]
72 #[inline(always)]
73 pub fn variant(&self) -> VOUTRES_A {
74 match self.bits {
75 0 => VOUTRES_A::DIS,
76 1 => VOUTRES_A::WEAK,
77 2 => VOUTRES_A::MED,
78 3 => VOUTRES_A::STRONG,
79 _ => unreachable!(),
80 }
81 }
82 #[doc = "Checks if the value of the field is `DIS`"]
83 #[inline(always)]
84 pub fn is_dis(&self) -> bool {
85 *self == VOUTRES_A::DIS
86 }
87 #[doc = "Checks if the value of the field is `WEAK`"]
88 #[inline(always)]
89 pub fn is_weak(&self) -> bool {
90 *self == VOUTRES_A::WEAK
91 }
92 #[doc = "Checks if the value of the field is `MED`"]
93 #[inline(always)]
94 pub fn is_med(&self) -> bool {
95 *self == VOUTRES_A::MED
96 }
97 #[doc = "Checks if the value of the field is `STRONG`"]
98 #[inline(always)]
99 pub fn is_strong(&self) -> bool {
100 *self == VOUTRES_A::STRONG
101 }
102}
103#[doc = "Field `VOUTRES` writer - BU_VOUT Resistor Select"]
104pub type VOUTRES_W<'a> = crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, VOUTRES_A, 2, 8>;
105impl<'a> VOUTRES_W<'a> {
106 #[doc = "BU_VOUT is not connected"]
107 #[inline(always)]
108 pub fn dis(self) -> &'a mut W {
109 self.variant(VOUTRES_A::DIS)
110 }
111 #[doc = "Enable weak switch between BU_VOUT and backup domain power supply."]
112 #[inline(always)]
113 pub fn weak(self) -> &'a mut W {
114 self.variant(VOUTRES_A::WEAK)
115 }
116 #[doc = "Enable medium switch between BU_VOUT and backup domain power supply."]
117 #[inline(always)]
118 pub fn med(self) -> &'a mut W {
119 self.variant(VOUTRES_A::MED)
120 }
121 #[doc = "Enable strong switch between BU_VOUT and backup domain power supply."]
122 #[inline(always)]
123 pub fn strong(self) -> &'a mut W {
124 self.variant(VOUTRES_A::STRONG)
125 }
126}
127#[doc = "Power Domain Resistor Select\n\nValue on reset: 0"]
128#[derive(Clone, Copy, Debug, PartialEq)]
129#[repr(u8)]
130pub enum PWRRES_A {
131 #[doc = "0: Main power and backup power connected with RES0 series resistance."]
132 RES0 = 0,
133 #[doc = "1: Main power and backup power connected with RES1 series resistance."]
134 RES1 = 1,
135 #[doc = "2: Main power and backup power connected with RES2 series resistance."]
136 RES2 = 2,
137 #[doc = "3: Main power and backup power connected with RES3 series resistance."]
138 RES3 = 3,
139}
140impl From<PWRRES_A> for u8 {
141 #[inline(always)]
142 fn from(variant: PWRRES_A) -> Self {
143 variant as _
144 }
145}
146#[doc = "Field `PWRRES` reader - Power Domain Resistor Select"]
147pub type PWRRES_R = crate::FieldReader<u8, PWRRES_A>;
148impl PWRRES_R {
149 #[doc = "Get enumerated values variant"]
150 #[inline(always)]
151 pub fn variant(&self) -> PWRRES_A {
152 match self.bits {
153 0 => PWRRES_A::RES0,
154 1 => PWRRES_A::RES1,
155 2 => PWRRES_A::RES2,
156 3 => PWRRES_A::RES3,
157 _ => unreachable!(),
158 }
159 }
160 #[doc = "Checks if the value of the field is `RES0`"]
161 #[inline(always)]
162 pub fn is_res0(&self) -> bool {
163 *self == PWRRES_A::RES0
164 }
165 #[doc = "Checks if the value of the field is `RES1`"]
166 #[inline(always)]
167 pub fn is_res1(&self) -> bool {
168 *self == PWRRES_A::RES1
169 }
170 #[doc = "Checks if the value of the field is `RES2`"]
171 #[inline(always)]
172 pub fn is_res2(&self) -> bool {
173 *self == PWRRES_A::RES2
174 }
175 #[doc = "Checks if the value of the field is `RES3`"]
176 #[inline(always)]
177 pub fn is_res3(&self) -> bool {
178 *self == PWRRES_A::RES3
179 }
180}
181#[doc = "Field `PWRRES` writer - Power Domain Resistor Select"]
182pub type PWRRES_W<'a> = crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, PWRRES_A, 2, 12>;
183impl<'a> PWRRES_W<'a> {
184 #[doc = "Main power and backup power connected with RES0 series resistance."]
185 #[inline(always)]
186 pub fn res0(self) -> &'a mut W {
187 self.variant(PWRRES_A::RES0)
188 }
189 #[doc = "Main power and backup power connected with RES1 series resistance."]
190 #[inline(always)]
191 pub fn res1(self) -> &'a mut W {
192 self.variant(PWRRES_A::RES1)
193 }
194 #[doc = "Main power and backup power connected with RES2 series resistance."]
195 #[inline(always)]
196 pub fn res2(self) -> &'a mut W {
197 self.variant(PWRRES_A::RES2)
198 }
199 #[doc = "Main power and backup power connected with RES3 series resistance."]
200 #[inline(always)]
201 pub fn res3(self) -> &'a mut W {
202 self.variant(PWRRES_A::RES3)
203 }
204}
205#[doc = "Power Connection Configuration in Backup Mode\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207#[repr(u8)]
208pub enum BUACTPWRCON_A {
209 #[doc = "0: No connection."]
210 NONE = 0,
211 #[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."]
212 MAINBU = 1,
213 #[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."]
214 BUMAIN = 2,
215 #[doc = "3: Main power and backup power are connected without diode."]
216 NODIODE = 3,
217}
218impl From<BUACTPWRCON_A> for u8 {
219 #[inline(always)]
220 fn from(variant: BUACTPWRCON_A) -> Self {
221 variant as _
222 }
223}
224#[doc = "Field `BUACTPWRCON` reader - Power Connection Configuration in Backup Mode"]
225pub type BUACTPWRCON_R = crate::FieldReader<u8, BUACTPWRCON_A>;
226impl BUACTPWRCON_R {
227 #[doc = "Get enumerated values variant"]
228 #[inline(always)]
229 pub fn variant(&self) -> BUACTPWRCON_A {
230 match self.bits {
231 0 => BUACTPWRCON_A::NONE,
232 1 => BUACTPWRCON_A::MAINBU,
233 2 => BUACTPWRCON_A::BUMAIN,
234 3 => BUACTPWRCON_A::NODIODE,
235 _ => unreachable!(),
236 }
237 }
238 #[doc = "Checks if the value of the field is `NONE`"]
239 #[inline(always)]
240 pub fn is_none(&self) -> bool {
241 *self == BUACTPWRCON_A::NONE
242 }
243 #[doc = "Checks if the value of the field is `MAINBU`"]
244 #[inline(always)]
245 pub fn is_mainbu(&self) -> bool {
246 *self == BUACTPWRCON_A::MAINBU
247 }
248 #[doc = "Checks if the value of the field is `BUMAIN`"]
249 #[inline(always)]
250 pub fn is_bumain(&self) -> bool {
251 *self == BUACTPWRCON_A::BUMAIN
252 }
253 #[doc = "Checks if the value of the field is `NODIODE`"]
254 #[inline(always)]
255 pub fn is_nodiode(&self) -> bool {
256 *self == BUACTPWRCON_A::NODIODE
257 }
258}
259#[doc = "Field `BUACTPWRCON` writer - Power Connection Configuration in Backup Mode"]
260pub type BUACTPWRCON_W<'a> = crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, BUACTPWRCON_A, 2, 16>;
261impl<'a> BUACTPWRCON_W<'a> {
262 #[doc = "No connection."]
263 #[inline(always)]
264 pub fn none(self) -> &'a mut W {
265 self.variant(BUACTPWRCON_A::NONE)
266 }
267 #[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."]
268 #[inline(always)]
269 pub fn mainbu(self) -> &'a mut W {
270 self.variant(BUACTPWRCON_A::MAINBU)
271 }
272 #[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."]
273 #[inline(always)]
274 pub fn bumain(self) -> &'a mut W {
275 self.variant(BUACTPWRCON_A::BUMAIN)
276 }
277 #[doc = "Main power and backup power are connected without diode."]
278 #[inline(always)]
279 pub fn nodiode(self) -> &'a mut W {
280 self.variant(BUACTPWRCON_A::NODIODE)
281 }
282}
283#[doc = "Power Connection Configuration When Not in Backup Mode\n\nValue on reset: 0"]
284#[derive(Clone, Copy, Debug, PartialEq)]
285#[repr(u8)]
286pub enum BUINACTPWRCON_A {
287 #[doc = "0: No connection."]
288 NONE = 0,
289 #[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."]
290 MAINBU = 1,
291 #[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."]
292 BUMAIN = 2,
293 #[doc = "3: Main power and backup power are connected without diode."]
294 NODIODE = 3,
295}
296impl From<BUINACTPWRCON_A> for u8 {
297 #[inline(always)]
298 fn from(variant: BUINACTPWRCON_A) -> Self {
299 variant as _
300 }
301}
302#[doc = "Field `BUINACTPWRCON` reader - Power Connection Configuration When Not in Backup Mode"]
303pub type BUINACTPWRCON_R = crate::FieldReader<u8, BUINACTPWRCON_A>;
304impl BUINACTPWRCON_R {
305 #[doc = "Get enumerated values variant"]
306 #[inline(always)]
307 pub fn variant(&self) -> BUINACTPWRCON_A {
308 match self.bits {
309 0 => BUINACTPWRCON_A::NONE,
310 1 => BUINACTPWRCON_A::MAINBU,
311 2 => BUINACTPWRCON_A::BUMAIN,
312 3 => BUINACTPWRCON_A::NODIODE,
313 _ => unreachable!(),
314 }
315 }
316 #[doc = "Checks if the value of the field is `NONE`"]
317 #[inline(always)]
318 pub fn is_none(&self) -> bool {
319 *self == BUINACTPWRCON_A::NONE
320 }
321 #[doc = "Checks if the value of the field is `MAINBU`"]
322 #[inline(always)]
323 pub fn is_mainbu(&self) -> bool {
324 *self == BUINACTPWRCON_A::MAINBU
325 }
326 #[doc = "Checks if the value of the field is `BUMAIN`"]
327 #[inline(always)]
328 pub fn is_bumain(&self) -> bool {
329 *self == BUINACTPWRCON_A::BUMAIN
330 }
331 #[doc = "Checks if the value of the field is `NODIODE`"]
332 #[inline(always)]
333 pub fn is_nodiode(&self) -> bool {
334 *self == BUINACTPWRCON_A::NODIODE
335 }
336}
337#[doc = "Field `BUINACTPWRCON` writer - Power Connection Configuration When Not in Backup Mode"]
338pub type BUINACTPWRCON_W<'a> =
339 crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, BUINACTPWRCON_A, 2, 20>;
340impl<'a> BUINACTPWRCON_W<'a> {
341 #[doc = "No connection."]
342 #[inline(always)]
343 pub fn none(self) -> &'a mut W {
344 self.variant(BUINACTPWRCON_A::NONE)
345 }
346 #[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."]
347 #[inline(always)]
348 pub fn mainbu(self) -> &'a mut W {
349 self.variant(BUINACTPWRCON_A::MAINBU)
350 }
351 #[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."]
352 #[inline(always)]
353 pub fn bumain(self) -> &'a mut W {
354 self.variant(BUINACTPWRCON_A::BUMAIN)
355 }
356 #[doc = "Main power and backup power are connected without diode."]
357 #[inline(always)]
358 pub fn nodiode(self) -> &'a mut W {
359 self.variant(BUINACTPWRCON_A::NODIODE)
360 }
361}
362#[doc = "Field `DISMAXCOMP` reader - Disable MAIN-BU Comparator"]
363pub type DISMAXCOMP_R = crate::BitReader<bool>;
364#[doc = "Field `DISMAXCOMP` writer - Disable MAIN-BU Comparator"]
365pub type DISMAXCOMP_W<'a> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 31>;
366impl R {
367 #[doc = "Bit 0 - Enable Backup Mode"]
368 #[inline(always)]
369 pub fn en(&self) -> EN_R {
370 EN_R::new((self.bits & 1) != 0)
371 }
372 #[doc = "Bit 1 - Enable Backup Mode Status Export"]
373 #[inline(always)]
374 pub fn staten(&self) -> STATEN_R {
375 STATEN_R::new(((self.bits >> 1) & 1) != 0)
376 }
377 #[doc = "Bit 2 - Enable BU_VIN Probing"]
378 #[inline(always)]
379 pub fn buvinprobeen(&self) -> BUVINPROBEEN_R {
380 BUVINPROBEEN_R::new(((self.bits >> 2) & 1) != 0)
381 }
382 #[doc = "Bits 8:9 - BU_VOUT Resistor Select"]
383 #[inline(always)]
384 pub fn voutres(&self) -> VOUTRES_R {
385 VOUTRES_R::new(((self.bits >> 8) & 3) as u8)
386 }
387 #[doc = "Bits 12:13 - Power Domain Resistor Select"]
388 #[inline(always)]
389 pub fn pwrres(&self) -> PWRRES_R {
390 PWRRES_R::new(((self.bits >> 12) & 3) as u8)
391 }
392 #[doc = "Bits 16:17 - Power Connection Configuration in Backup Mode"]
393 #[inline(always)]
394 pub fn buactpwrcon(&self) -> BUACTPWRCON_R {
395 BUACTPWRCON_R::new(((self.bits >> 16) & 3) as u8)
396 }
397 #[doc = "Bits 20:21 - Power Connection Configuration When Not in Backup Mode"]
398 #[inline(always)]
399 pub fn buinactpwrcon(&self) -> BUINACTPWRCON_R {
400 BUINACTPWRCON_R::new(((self.bits >> 20) & 3) as u8)
401 }
402 #[doc = "Bit 31 - Disable MAIN-BU Comparator"]
403 #[inline(always)]
404 pub fn dismaxcomp(&self) -> DISMAXCOMP_R {
405 DISMAXCOMP_R::new(((self.bits >> 31) & 1) != 0)
406 }
407}
408impl W {
409 #[doc = "Bit 0 - Enable Backup Mode"]
410 #[inline(always)]
411 pub fn en(&mut self) -> EN_W {
412 EN_W::new(self)
413 }
414 #[doc = "Bit 1 - Enable Backup Mode Status Export"]
415 #[inline(always)]
416 pub fn staten(&mut self) -> STATEN_W {
417 STATEN_W::new(self)
418 }
419 #[doc = "Bit 2 - Enable BU_VIN Probing"]
420 #[inline(always)]
421 pub fn buvinprobeen(&mut self) -> BUVINPROBEEN_W {
422 BUVINPROBEEN_W::new(self)
423 }
424 #[doc = "Bits 8:9 - BU_VOUT Resistor Select"]
425 #[inline(always)]
426 pub fn voutres(&mut self) -> VOUTRES_W {
427 VOUTRES_W::new(self)
428 }
429 #[doc = "Bits 12:13 - Power Domain Resistor Select"]
430 #[inline(always)]
431 pub fn pwrres(&mut self) -> PWRRES_W {
432 PWRRES_W::new(self)
433 }
434 #[doc = "Bits 16:17 - Power Connection Configuration in Backup Mode"]
435 #[inline(always)]
436 pub fn buactpwrcon(&mut self) -> BUACTPWRCON_W {
437 BUACTPWRCON_W::new(self)
438 }
439 #[doc = "Bits 20:21 - Power Connection Configuration When Not in Backup Mode"]
440 #[inline(always)]
441 pub fn buinactpwrcon(&mut self) -> BUINACTPWRCON_W {
442 BUINACTPWRCON_W::new(self)
443 }
444 #[doc = "Bit 31 - Disable MAIN-BU Comparator"]
445 #[inline(always)]
446 pub fn dismaxcomp(&mut self) -> DISMAXCOMP_W {
447 DISMAXCOMP_W::new(self)
448 }
449 #[doc = "Writes raw bits to the register."]
450 #[inline(always)]
451 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
452 self.0.bits(bits);
453 self
454 }
455}
456#[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"]
457pub struct BUCTRL_SPEC;
458impl crate::RegisterSpec for BUCTRL_SPEC {
459 type Ux = u32;
460}
461#[doc = "`read()` method returns [buctrl::R](R) reader structure"]
462impl crate::Readable for BUCTRL_SPEC {
463 type Reader = R;
464}
465#[doc = "`write(|w| ..)` method takes [buctrl::W](W) writer structure"]
466impl crate::Writable for BUCTRL_SPEC {
467 type Writer = W;
468}
469#[doc = "`reset()` method sets BUCTRL to value 0"]
470impl crate::Resettable for BUCTRL_SPEC {
471 #[inline(always)]
472 fn reset_value() -> Self::Ux {
473 0
474 }
475}