efm32pg22_pac/efm32pg22c200/emu_s/
em4ctrl.rs1#[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 `EM4ENTRY` reader - EM4 entry request"]
38pub type EM4ENTRY_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `EM4ENTRY` writer - EM4 entry request"]
40pub type EM4ENTRY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, u8, 2, O>;
41#[doc = "Field `EM4IORETMODE` reader - EM4 IO retention mode"]
42pub type EM4IORETMODE_R = crate::FieldReader<u8, EM4IORETMODE_A>;
43#[doc = "EM4 IO retention mode\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum EM4IORETMODE_A {
47 #[doc = "0: No Retention: Pads enter reset state when entering EM4"]
48 DISABLE = 0,
49 #[doc = "1: Retention through EM4: Pads enter reset state when exiting EM4"]
50 EM4EXIT = 1,
51 #[doc = "2: Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
52 SWUNLATCH = 2,
53}
54impl From<EM4IORETMODE_A> for u8 {
55 #[inline(always)]
56 fn from(variant: EM4IORETMODE_A) -> Self {
57 variant as _
58 }
59}
60impl EM4IORETMODE_R {
61 #[doc = "Get enumerated values variant"]
62 #[inline(always)]
63 pub fn variant(&self) -> Option<EM4IORETMODE_A> {
64 match self.bits {
65 0 => Some(EM4IORETMODE_A::DISABLE),
66 1 => Some(EM4IORETMODE_A::EM4EXIT),
67 2 => Some(EM4IORETMODE_A::SWUNLATCH),
68 _ => None,
69 }
70 }
71 #[doc = "Checks if the value of the field is `DISABLE`"]
72 #[inline(always)]
73 pub fn is_disable(&self) -> bool {
74 *self == EM4IORETMODE_A::DISABLE
75 }
76 #[doc = "Checks if the value of the field is `EM4EXIT`"]
77 #[inline(always)]
78 pub fn is_em4exit(&self) -> bool {
79 *self == EM4IORETMODE_A::EM4EXIT
80 }
81 #[doc = "Checks if the value of the field is `SWUNLATCH`"]
82 #[inline(always)]
83 pub fn is_swunlatch(&self) -> bool {
84 *self == EM4IORETMODE_A::SWUNLATCH
85 }
86}
87#[doc = "Field `EM4IORETMODE` writer - EM4 IO retention mode"]
88pub type EM4IORETMODE_W<'a, const O: u8> =
89 crate::FieldWriter<'a, u32, EM4CTRL_SPEC, u8, EM4IORETMODE_A, 2, O>;
90impl<'a, const O: u8> EM4IORETMODE_W<'a, O> {
91 #[doc = "No Retention: Pads enter reset state when entering EM4"]
92 #[inline(always)]
93 pub fn disable(self) -> &'a mut W {
94 self.variant(EM4IORETMODE_A::DISABLE)
95 }
96 #[doc = "Retention through EM4: Pads enter reset state when exiting EM4"]
97 #[inline(always)]
98 pub fn em4exit(self) -> &'a mut W {
99 self.variant(EM4IORETMODE_A::EM4EXIT)
100 }
101 #[doc = "Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
102 #[inline(always)]
103 pub fn swunlatch(self) -> &'a mut W {
104 self.variant(EM4IORETMODE_A::SWUNLATCH)
105 }
106}
107#[doc = "Field `BOD3SENSEEM4WU` reader - Set BOD3SENSE as EM4 wakeup"]
108pub type BOD3SENSEEM4WU_R = crate::BitReader<bool>;
109#[doc = "Field `BOD3SENSEEM4WU` writer - Set BOD3SENSE as EM4 wakeup"]
110pub type BOD3SENSEEM4WU_W<'a, const O: u8> = crate::BitWriter<'a, u32, EM4CTRL_SPEC, bool, O>;
111impl R {
112 #[doc = "Bits 0:1 - EM4 entry request"]
113 #[inline(always)]
114 pub fn em4entry(&self) -> EM4ENTRY_R {
115 EM4ENTRY_R::new((self.bits & 3) as u8)
116 }
117 #[doc = "Bits 4:5 - EM4 IO retention mode"]
118 #[inline(always)]
119 pub fn em4ioretmode(&self) -> EM4IORETMODE_R {
120 EM4IORETMODE_R::new(((self.bits >> 4) & 3) as u8)
121 }
122 #[doc = "Bit 8 - Set BOD3SENSE as EM4 wakeup"]
123 #[inline(always)]
124 pub fn bod3senseem4wu(&self) -> BOD3SENSEEM4WU_R {
125 BOD3SENSEEM4WU_R::new(((self.bits >> 8) & 1) != 0)
126 }
127}
128impl W {
129 #[doc = "Bits 0:1 - EM4 entry request"]
130 #[inline(always)]
131 #[must_use]
132 pub fn em4entry(&mut self) -> EM4ENTRY_W<0> {
133 EM4ENTRY_W::new(self)
134 }
135 #[doc = "Bits 4:5 - EM4 IO retention mode"]
136 #[inline(always)]
137 #[must_use]
138 pub fn em4ioretmode(&mut self) -> EM4IORETMODE_W<4> {
139 EM4IORETMODE_W::new(self)
140 }
141 #[doc = "Bit 8 - Set BOD3SENSE as EM4 wakeup"]
142 #[inline(always)]
143 #[must_use]
144 pub fn bod3senseem4wu(&mut self) -> BOD3SENSEEM4WU_W<8> {
145 BOD3SENSEEM4WU_W::new(self)
146 }
147 #[doc = "Writes raw bits to the register."]
148 #[inline(always)]
149 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
150 self.0.bits(bits);
151 self
152 }
153}
154#[doc = "No Description\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"]
155pub struct EM4CTRL_SPEC;
156impl crate::RegisterSpec for EM4CTRL_SPEC {
157 type Ux = u32;
158}
159#[doc = "`read()` method returns [em4ctrl::R](R) reader structure"]
160impl crate::Readable for EM4CTRL_SPEC {
161 type Reader = R;
162}
163#[doc = "`write(|w| ..)` method takes [em4ctrl::W](W) writer structure"]
164impl crate::Writable for EM4CTRL_SPEC {
165 type Writer = W;
166 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
167 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
168}
169#[doc = "`reset()` method sets EM4CTRL to value 0"]
170impl crate::Resettable for EM4CTRL_SPEC {
171 const RESET_VALUE: Self::Ux = 0;
172}