efm32tg11b_pac/efm32tg11b540/emu/
buctrl.rs

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