efm32tg11b_pac/efm32tg11b540/emu/
em4ctrl.rs

1#[doc = "Register `EM4CTRL` reader"]
2pub struct R(crate::R<EM4CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EM4CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EM4CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EM4CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EM4CTRL` writer"]
17pub struct W(crate::W<EM4CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EM4CTRL_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<EM4CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EM4CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EM4STATE` reader - Energy Mode 4 State"]
38pub type EM4STATE_R = crate::BitReader<bool>;
39#[doc = "Field `EM4STATE` writer - Energy Mode 4 State"]
40pub type EM4STATE_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, O>;
41#[doc = "Field `RETAINLFRCO` reader - LFRCO Retain During EM4"]
42pub type RETAINLFRCO_R = crate::BitReader<bool>;
43#[doc = "Field `RETAINLFRCO` writer - LFRCO Retain During EM4"]
44pub type RETAINLFRCO_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, O>;
45#[doc = "Field `RETAINLFXO` reader - LFXO Retain During EM4"]
46pub type RETAINLFXO_R = crate::BitReader<bool>;
47#[doc = "Field `RETAINLFXO` writer - LFXO Retain During EM4"]
48pub type RETAINLFXO_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, O>;
49#[doc = "Field `RETAINULFRCO` reader - ULFRCO Retain During EM4S"]
50pub type RETAINULFRCO_R = crate::BitReader<bool>;
51#[doc = "Field `RETAINULFRCO` writer - ULFRCO Retain During EM4S"]
52pub type RETAINULFRCO_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, O>;
53#[doc = "Field `EM4IORETMODE` reader - EM4 IO Retention Disable"]
54pub type EM4IORETMODE_R = crate::FieldReader<u8, EM4IORETMODE_A>;
55#[doc = "EM4 IO Retention Disable\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum EM4IORETMODE_A {
59    #[doc = "0: No Retention: Pads enter reset state when entering EM4"]
60    DISABLE = 0,
61    #[doc = "1: Retention through EM4: Pads enter reset state when exiting EM4"]
62    EM4EXIT = 1,
63    #[doc = "2: Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
64    SWUNLATCH = 2,
65}
66impl From<EM4IORETMODE_A> for u8 {
67    #[inline(always)]
68    fn from(variant: EM4IORETMODE_A) -> Self {
69        variant as _
70    }
71}
72impl EM4IORETMODE_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<EM4IORETMODE_A> {
76        match self.bits {
77            0 => Some(EM4IORETMODE_A::DISABLE),
78            1 => Some(EM4IORETMODE_A::EM4EXIT),
79            2 => Some(EM4IORETMODE_A::SWUNLATCH),
80            _ => None,
81        }
82    }
83    #[doc = "Checks if the value of the field is `DISABLE`"]
84    #[inline(always)]
85    pub fn is_disable(&self) -> bool {
86        *self == EM4IORETMODE_A::DISABLE
87    }
88    #[doc = "Checks if the value of the field is `EM4EXIT`"]
89    #[inline(always)]
90    pub fn is_em4exit(&self) -> bool {
91        *self == EM4IORETMODE_A::EM4EXIT
92    }
93    #[doc = "Checks if the value of the field is `SWUNLATCH`"]
94    #[inline(always)]
95    pub fn is_swunlatch(&self) -> bool {
96        *self == EM4IORETMODE_A::SWUNLATCH
97    }
98}
99#[doc = "Field `EM4IORETMODE` writer - EM4 IO Retention Disable"]
100pub type EM4IORETMODE_W<'a, const O: u8> =
101    crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, EM4IORETMODE_A, 2, O>;
102impl<'a, const O: u8> EM4IORETMODE_W<'a, O> {
103    #[doc = "No Retention: Pads enter reset state when entering EM4"]
104    #[inline(always)]
105    pub fn disable(self) -> &'a mut W {
106        self.variant(EM4IORETMODE_A::DISABLE)
107    }
108    #[doc = "Retention through EM4: Pads enter reset state when exiting EM4"]
109    #[inline(always)]
110    pub fn em4exit(self) -> &'a mut W {
111        self.variant(EM4IORETMODE_A::EM4EXIT)
112    }
113    #[doc = "Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
114    #[inline(always)]
115    pub fn swunlatch(self) -> &'a mut W {
116        self.variant(EM4IORETMODE_A::SWUNLATCH)
117    }
118}
119#[doc = "Field `EM4ENTRY` writer - Energy Mode 4 Entry"]
120pub type EM4ENTRY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, u8, 2, O>;
121impl R {
122    #[doc = "Bit 0 - Energy Mode 4 State"]
123    #[inline(always)]
124    pub fn em4state(&self) -> EM4STATE_R {
125        EM4STATE_R::new((self.bits & 1) != 0)
126    }
127    #[doc = "Bit 1 - LFRCO Retain During EM4"]
128    #[inline(always)]
129    pub fn retainlfrco(&self) -> RETAINLFRCO_R {
130        RETAINLFRCO_R::new(((self.bits >> 1) & 1) != 0)
131    }
132    #[doc = "Bit 2 - LFXO Retain During EM4"]
133    #[inline(always)]
134    pub fn retainlfxo(&self) -> RETAINLFXO_R {
135        RETAINLFXO_R::new(((self.bits >> 2) & 1) != 0)
136    }
137    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
138    #[inline(always)]
139    pub fn retainulfrco(&self) -> RETAINULFRCO_R {
140        RETAINULFRCO_R::new(((self.bits >> 3) & 1) != 0)
141    }
142    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
143    #[inline(always)]
144    pub fn em4ioretmode(&self) -> EM4IORETMODE_R {
145        EM4IORETMODE_R::new(((self.bits >> 4) & 3) as u8)
146    }
147}
148impl W {
149    #[doc = "Bit 0 - Energy Mode 4 State"]
150    #[inline(always)]
151    #[must_use]
152    pub fn em4state(&mut self) -> EM4STATE_W<0> {
153        EM4STATE_W::new(self)
154    }
155    #[doc = "Bit 1 - LFRCO Retain During EM4"]
156    #[inline(always)]
157    #[must_use]
158    pub fn retainlfrco(&mut self) -> RETAINLFRCO_W<1> {
159        RETAINLFRCO_W::new(self)
160    }
161    #[doc = "Bit 2 - LFXO Retain During EM4"]
162    #[inline(always)]
163    #[must_use]
164    pub fn retainlfxo(&mut self) -> RETAINLFXO_W<2> {
165        RETAINLFXO_W::new(self)
166    }
167    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
168    #[inline(always)]
169    #[must_use]
170    pub fn retainulfrco(&mut self) -> RETAINULFRCO_W<3> {
171        RETAINULFRCO_W::new(self)
172    }
173    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
174    #[inline(always)]
175    #[must_use]
176    pub fn em4ioretmode(&mut self) -> EM4IORETMODE_W<4> {
177        EM4IORETMODE_W::new(self)
178    }
179    #[doc = "Bits 16:17 - Energy Mode 4 Entry"]
180    #[inline(always)]
181    #[must_use]
182    pub fn em4entry(&mut self) -> EM4ENTRY_W<16> {
183        EM4ENTRY_W::new(self)
184    }
185    #[doc = "Writes raw bits to the register."]
186    #[inline(always)]
187    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
188        self.0.bits(bits);
189        self
190    }
191}
192#[doc = "EM4 Control 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 [em4ctrl](index.html) module"]
193pub struct EM4CTRL_SPEC;
194impl crate::RegisterSpec for EM4CTRL_SPEC {
195    type Ux = u32;
196}
197#[doc = "`read()` method returns [em4ctrl::R](R) reader structure"]
198impl crate::Readable for EM4CTRL_SPEC {
199    type Reader = R;
200}
201#[doc = "`write(|w| ..)` method takes [em4ctrl::W](W) writer structure"]
202impl crate::Writable for EM4CTRL_SPEC {
203    type Writer = W;
204    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
205    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
206}
207#[doc = "`reset()` method sets EM4CTRL to value 0"]
208impl crate::Resettable for EM4CTRL_SPEC {
209    const RESET_VALUE: Self::Ux = 0;
210}