efm32wg230_pac/emu/
buact.rs

1#[doc = "Register `BUACT` reader"]
2pub struct R(crate::R<BUACT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<BUACT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<BUACT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<BUACT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `BUACT` writer"]
17pub struct W(crate::W<BUACT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<BUACT_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<BUACT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<BUACT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BUEXTHRES` reader - "]
38pub type BUEXTHRES_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `BUEXTHRES` writer - "]
40pub type BUEXTHRES_W<'a> = crate::FieldWriter<'a, u32, BUACT_SPEC, u8, u8, 3, 0>;
41#[doc = "Field `BUEXRANGE` reader - "]
42pub type BUEXRANGE_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `BUEXRANGE` writer - "]
44pub type BUEXRANGE_W<'a> = crate::FieldWriter<'a, u32, BUACT_SPEC, u8, u8, 2, 3>;
45#[doc = "Power connection configuration when in Backup mode\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum PWRCON_A {
49    #[doc = "0: No connection."]
50    NONE = 0,
51    #[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."]
52    BUMAIN = 1,
53    #[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."]
54    MAINBU = 2,
55    #[doc = "3: Main power and backup power are connected without diode."]
56    NODIODE = 3,
57}
58impl From<PWRCON_A> for u8 {
59    #[inline(always)]
60    fn from(variant: PWRCON_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `PWRCON` reader - Power connection configuration when in Backup mode"]
65pub type PWRCON_R = crate::FieldReader<u8, PWRCON_A>;
66impl PWRCON_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> PWRCON_A {
70        match self.bits {
71            0 => PWRCON_A::NONE,
72            1 => PWRCON_A::BUMAIN,
73            2 => PWRCON_A::MAINBU,
74            3 => PWRCON_A::NODIODE,
75            _ => unreachable!(),
76        }
77    }
78    #[doc = "Checks if the value of the field is `NONE`"]
79    #[inline(always)]
80    pub fn is_none(&self) -> bool {
81        *self == PWRCON_A::NONE
82    }
83    #[doc = "Checks if the value of the field is `BUMAIN`"]
84    #[inline(always)]
85    pub fn is_bumain(&self) -> bool {
86        *self == PWRCON_A::BUMAIN
87    }
88    #[doc = "Checks if the value of the field is `MAINBU`"]
89    #[inline(always)]
90    pub fn is_mainbu(&self) -> bool {
91        *self == PWRCON_A::MAINBU
92    }
93    #[doc = "Checks if the value of the field is `NODIODE`"]
94    #[inline(always)]
95    pub fn is_nodiode(&self) -> bool {
96        *self == PWRCON_A::NODIODE
97    }
98}
99#[doc = "Field `PWRCON` writer - Power connection configuration when in Backup mode"]
100pub type PWRCON_W<'a> = crate::FieldWriterSafe<'a, u32, BUACT_SPEC, u8, PWRCON_A, 2, 5>;
101impl<'a> PWRCON_W<'a> {
102    #[doc = "No connection."]
103    #[inline(always)]
104    pub fn none(self) -> &'a mut W {
105        self.variant(PWRCON_A::NONE)
106    }
107    #[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."]
108    #[inline(always)]
109    pub fn bumain(self) -> &'a mut W {
110        self.variant(PWRCON_A::BUMAIN)
111    }
112    #[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."]
113    #[inline(always)]
114    pub fn mainbu(self) -> &'a mut W {
115        self.variant(PWRCON_A::MAINBU)
116    }
117    #[doc = "Main power and backup power are connected without diode."]
118    #[inline(always)]
119    pub fn nodiode(self) -> &'a mut W {
120        self.variant(PWRCON_A::NODIODE)
121    }
122}
123impl R {
124    #[doc = "Bits 0:2"]
125    #[inline(always)]
126    pub fn buexthres(&self) -> BUEXTHRES_R {
127        BUEXTHRES_R::new((self.bits & 7) as u8)
128    }
129    #[doc = "Bits 3:4"]
130    #[inline(always)]
131    pub fn buexrange(&self) -> BUEXRANGE_R {
132        BUEXRANGE_R::new(((self.bits >> 3) & 3) as u8)
133    }
134    #[doc = "Bits 5:6 - Power connection configuration when in Backup mode"]
135    #[inline(always)]
136    pub fn pwrcon(&self) -> PWRCON_R {
137        PWRCON_R::new(((self.bits >> 5) & 3) as u8)
138    }
139}
140impl W {
141    #[doc = "Bits 0:2"]
142    #[inline(always)]
143    pub fn buexthres(&mut self) -> BUEXTHRES_W {
144        BUEXTHRES_W::new(self)
145    }
146    #[doc = "Bits 3:4"]
147    #[inline(always)]
148    pub fn buexrange(&mut self) -> BUEXRANGE_W {
149        BUEXRANGE_W::new(self)
150    }
151    #[doc = "Bits 5:6 - Power connection configuration when in Backup mode"]
152    #[inline(always)]
153    pub fn pwrcon(&mut self) -> PWRCON_W {
154        PWRCON_W::new(self)
155    }
156    #[doc = "Writes raw bits to the register."]
157    #[inline(always)]
158    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
159        self.0.bits(bits);
160        self
161    }
162}
163#[doc = "Backup mode active 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 [buact](index.html) module"]
164pub struct BUACT_SPEC;
165impl crate::RegisterSpec for BUACT_SPEC {
166    type Ux = u32;
167}
168#[doc = "`read()` method returns [buact::R](R) reader structure"]
169impl crate::Readable for BUACT_SPEC {
170    type Reader = R;
171}
172#[doc = "`write(|w| ..)` method takes [buact::W](W) writer structure"]
173impl crate::Writable for BUACT_SPEC {
174    type Writer = W;
175}
176#[doc = "`reset()` method sets BUACT to value 0x0b"]
177impl crate::Resettable for BUACT_SPEC {
178    #[inline(always)]
179    fn reset_value() -> Self::Ux {
180        0x0b
181    }
182}