efm32pg1b100_pac/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> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, 0>;
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> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, 1>;
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> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, 2>;
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> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, 3>;
53#[doc = "EM4 IO Retention Disable\n\nValue on reset: 0"]
54#[derive(Clone, Copy, Debug, PartialEq)]
55#[repr(u8)]
56pub enum EM4IORETMODE_A {
57    #[doc = "0: No Retention: Pads enter reset state when entering EM4"]
58    DISABLE = 0,
59    #[doc = "1: Retention through EM4: Pads enter reset state when exiting EM4"]
60    EM4EXIT = 1,
61    #[doc = "2: Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
62    SWUNLATCH = 2,
63}
64impl From<EM4IORETMODE_A> for u8 {
65    #[inline(always)]
66    fn from(variant: EM4IORETMODE_A) -> Self {
67        variant as _
68    }
69}
70#[doc = "Field `EM4IORETMODE` reader - EM4 IO Retention Disable"]
71pub type EM4IORETMODE_R = crate::FieldReader<u8, EM4IORETMODE_A>;
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> = crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, EM4IORETMODE_A, 2, 4>;
101impl<'a> EM4IORETMODE_W<'a> {
102    #[doc = "No Retention: Pads enter reset state when entering EM4"]
103    #[inline(always)]
104    pub fn disable(self) -> &'a mut W {
105        self.variant(EM4IORETMODE_A::DISABLE)
106    }
107    #[doc = "Retention through EM4: Pads enter reset state when exiting EM4"]
108    #[inline(always)]
109    pub fn em4exit(self) -> &'a mut W {
110        self.variant(EM4IORETMODE_A::EM4EXIT)
111    }
112    #[doc = "Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
113    #[inline(always)]
114    pub fn swunlatch(self) -> &'a mut W {
115        self.variant(EM4IORETMODE_A::SWUNLATCH)
116    }
117}
118#[doc = "Field `EM4ENTRY` writer - Energy Mode 4 Entry"]
119pub type EM4ENTRY_W<'a> = crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, u8, 2, 16>;
120impl R {
121    #[doc = "Bit 0 - Energy Mode 4 State"]
122    #[inline(always)]
123    pub fn em4state(&self) -> EM4STATE_R {
124        EM4STATE_R::new((self.bits & 1) != 0)
125    }
126    #[doc = "Bit 1 - LFRCO Retain During EM4"]
127    #[inline(always)]
128    pub fn retainlfrco(&self) -> RETAINLFRCO_R {
129        RETAINLFRCO_R::new(((self.bits >> 1) & 1) != 0)
130    }
131    #[doc = "Bit 2 - LFXO Retain During EM4"]
132    #[inline(always)]
133    pub fn retainlfxo(&self) -> RETAINLFXO_R {
134        RETAINLFXO_R::new(((self.bits >> 2) & 1) != 0)
135    }
136    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
137    #[inline(always)]
138    pub fn retainulfrco(&self) -> RETAINULFRCO_R {
139        RETAINULFRCO_R::new(((self.bits >> 3) & 1) != 0)
140    }
141    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
142    #[inline(always)]
143    pub fn em4ioretmode(&self) -> EM4IORETMODE_R {
144        EM4IORETMODE_R::new(((self.bits >> 4) & 3) as u8)
145    }
146}
147impl W {
148    #[doc = "Bit 0 - Energy Mode 4 State"]
149    #[inline(always)]
150    pub fn em4state(&mut self) -> EM4STATE_W {
151        EM4STATE_W::new(self)
152    }
153    #[doc = "Bit 1 - LFRCO Retain During EM4"]
154    #[inline(always)]
155    pub fn retainlfrco(&mut self) -> RETAINLFRCO_W {
156        RETAINLFRCO_W::new(self)
157    }
158    #[doc = "Bit 2 - LFXO Retain During EM4"]
159    #[inline(always)]
160    pub fn retainlfxo(&mut self) -> RETAINLFXO_W {
161        RETAINLFXO_W::new(self)
162    }
163    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
164    #[inline(always)]
165    pub fn retainulfrco(&mut self) -> RETAINULFRCO_W {
166        RETAINULFRCO_W::new(self)
167    }
168    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
169    #[inline(always)]
170    pub fn em4ioretmode(&mut self) -> EM4IORETMODE_W {
171        EM4IORETMODE_W::new(self)
172    }
173    #[doc = "Bits 16:17 - Energy Mode 4 Entry"]
174    #[inline(always)]
175    pub fn em4entry(&mut self) -> EM4ENTRY_W {
176        EM4ENTRY_W::new(self)
177    }
178    #[doc = "Writes raw bits to the register."]
179    #[inline(always)]
180    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
181        self.0.bits(bits);
182        self
183    }
184}
185#[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"]
186pub struct EM4CTRL_SPEC;
187impl crate::RegisterSpec for EM4CTRL_SPEC {
188    type Ux = u32;
189}
190#[doc = "`read()` method returns [em4ctrl::R](R) reader structure"]
191impl crate::Readable for EM4CTRL_SPEC {
192    type Reader = R;
193}
194#[doc = "`write(|w| ..)` method takes [em4ctrl::W](W) writer structure"]
195impl crate::Writable for EM4CTRL_SPEC {
196    type Writer = W;
197}
198#[doc = "`reset()` method sets EM4CTRL to value 0"]
199impl crate::Resettable for EM4CTRL_SPEC {
200    #[inline(always)]
201    fn reset_value() -> Self::Ux {
202        0
203    }
204}