efm32hg321_pac/usb/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DMPUAP` reader - DMPU Active Polarity"]
38pub type DMPUAP_R = crate::BitReader<bool>;
39#[doc = "Field `DMPUAP` writer - DMPU Active Polarity"]
40pub type DMPUAP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 1>;
41#[doc = "Low Energy Mode Oscillator Control\n\nValue on reset: 2"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum LEMOSCCTRL_A {
45    #[doc = "0: Low Energy Mode has no effect on neither USBC or USHFRCO."]
46    NONE = 0,
47    #[doc = "1: The USBC clock is gated when Low Energy Mode is active."]
48    GATE = 1,
49    #[doc = "2: The USBC clock is gated, and USHFRCO is suspended (if not selected as HFCLK) when Low Energy Mode is active."]
50    SUSPEND = 2,
51}
52impl From<LEMOSCCTRL_A> for u8 {
53    #[inline(always)]
54    fn from(variant: LEMOSCCTRL_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `LEMOSCCTRL` reader - Low Energy Mode Oscillator Control"]
59pub type LEMOSCCTRL_R = crate::FieldReader<u8, LEMOSCCTRL_A>;
60impl LEMOSCCTRL_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<LEMOSCCTRL_A> {
64        match self.bits {
65            0 => Some(LEMOSCCTRL_A::NONE),
66            1 => Some(LEMOSCCTRL_A::GATE),
67            2 => Some(LEMOSCCTRL_A::SUSPEND),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `NONE`"]
72    #[inline(always)]
73    pub fn is_none(&self) -> bool {
74        *self == LEMOSCCTRL_A::NONE
75    }
76    #[doc = "Checks if the value of the field is `GATE`"]
77    #[inline(always)]
78    pub fn is_gate(&self) -> bool {
79        *self == LEMOSCCTRL_A::GATE
80    }
81    #[doc = "Checks if the value of the field is `SUSPEND`"]
82    #[inline(always)]
83    pub fn is_suspend(&self) -> bool {
84        *self == LEMOSCCTRL_A::SUSPEND
85    }
86}
87#[doc = "Field `LEMOSCCTRL` writer - Low Energy Mode Oscillator Control"]
88pub type LEMOSCCTRL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, LEMOSCCTRL_A, 2, 4>;
89impl<'a> LEMOSCCTRL_W<'a> {
90    #[doc = "Low Energy Mode has no effect on neither USBC or USHFRCO."]
91    #[inline(always)]
92    pub fn none(self) -> &'a mut W {
93        self.variant(LEMOSCCTRL_A::NONE)
94    }
95    #[doc = "The USBC clock is gated when Low Energy Mode is active."]
96    #[inline(always)]
97    pub fn gate(self) -> &'a mut W {
98        self.variant(LEMOSCCTRL_A::GATE)
99    }
100    #[doc = "The USBC clock is gated, and USHFRCO is suspended (if not selected as HFCLK) when Low Energy Mode is active."]
101    #[inline(always)]
102    pub fn suspend(self) -> &'a mut W {
103        self.variant(LEMOSCCTRL_A::SUSPEND)
104    }
105}
106#[doc = "Field `LEMPHYCTRL` reader - Low Energy Mode USB PHY Control"]
107pub type LEMPHYCTRL_R = crate::BitReader<bool>;
108#[doc = "Field `LEMPHYCTRL` writer - Low Energy Mode USB PHY Control"]
109pub type LEMPHYCTRL_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 7>;
110#[doc = "Field `LEMIDLEEN` reader - Low Energy Mode on Bus Idle Enable"]
111pub type LEMIDLEEN_R = crate::BitReader<bool>;
112#[doc = "Field `LEMIDLEEN` writer - Low Energy Mode on Bus Idle Enable"]
113pub type LEMIDLEEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 9>;
114#[doc = "Field `LEMNAKEN` reader - Low Energy Mode on OUT NAK Enable"]
115pub type LEMNAKEN_R = crate::BitReader<bool>;
116#[doc = "Field `LEMNAKEN` writer - Low Energy Mode on OUT NAK Enable"]
117pub type LEMNAKEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 10>;
118#[doc = "Field `LEMADDRMEN` reader - Low Energy Mode on Device Address Mismatch Enable"]
119pub type LEMADDRMEN_R = crate::BitReader<bool>;
120#[doc = "Field `LEMADDRMEN` writer - Low Energy Mode on Device Address Mismatch Enable"]
121pub type LEMADDRMEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 11>;
122#[doc = "Field `VREGDIS` reader - Voltage Regulator Disable"]
123pub type VREGDIS_R = crate::BitReader<bool>;
124#[doc = "Field `VREGDIS` writer - Voltage Regulator Disable"]
125pub type VREGDIS_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 16>;
126#[doc = "Field `VREGOSEN` reader - VREGO Sense Enable"]
127pub type VREGOSEN_R = crate::BitReader<bool>;
128#[doc = "Field `VREGOSEN` writer - VREGO Sense Enable"]
129pub type VREGOSEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 17>;
130#[doc = "Field `BIASPROGEM01` reader - Regulator Bias Programming Value in EM0/1"]
131pub type BIASPROGEM01_R = crate::FieldReader<u8, u8>;
132#[doc = "Field `BIASPROGEM01` writer - Regulator Bias Programming Value in EM0/1"]
133pub type BIASPROGEM01_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 2, 20>;
134#[doc = "Field `BIASPROGEM23` reader - Regulator Bias Programming Value in EM2/3"]
135pub type BIASPROGEM23_R = crate::FieldReader<u8, u8>;
136#[doc = "Field `BIASPROGEM23` writer - Regulator Bias Programming Value in EM2/3"]
137pub type BIASPROGEM23_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 2, 24>;
138impl R {
139    #[doc = "Bit 1 - DMPU Active Polarity"]
140    #[inline(always)]
141    pub fn dmpuap(&self) -> DMPUAP_R {
142        DMPUAP_R::new(((self.bits >> 1) & 1) != 0)
143    }
144    #[doc = "Bits 4:5 - Low Energy Mode Oscillator Control"]
145    #[inline(always)]
146    pub fn lemoscctrl(&self) -> LEMOSCCTRL_R {
147        LEMOSCCTRL_R::new(((self.bits >> 4) & 3) as u8)
148    }
149    #[doc = "Bit 7 - Low Energy Mode USB PHY Control"]
150    #[inline(always)]
151    pub fn lemphyctrl(&self) -> LEMPHYCTRL_R {
152        LEMPHYCTRL_R::new(((self.bits >> 7) & 1) != 0)
153    }
154    #[doc = "Bit 9 - Low Energy Mode on Bus Idle Enable"]
155    #[inline(always)]
156    pub fn lemidleen(&self) -> LEMIDLEEN_R {
157        LEMIDLEEN_R::new(((self.bits >> 9) & 1) != 0)
158    }
159    #[doc = "Bit 10 - Low Energy Mode on OUT NAK Enable"]
160    #[inline(always)]
161    pub fn lemnaken(&self) -> LEMNAKEN_R {
162        LEMNAKEN_R::new(((self.bits >> 10) & 1) != 0)
163    }
164    #[doc = "Bit 11 - Low Energy Mode on Device Address Mismatch Enable"]
165    #[inline(always)]
166    pub fn lemaddrmen(&self) -> LEMADDRMEN_R {
167        LEMADDRMEN_R::new(((self.bits >> 11) & 1) != 0)
168    }
169    #[doc = "Bit 16 - Voltage Regulator Disable"]
170    #[inline(always)]
171    pub fn vregdis(&self) -> VREGDIS_R {
172        VREGDIS_R::new(((self.bits >> 16) & 1) != 0)
173    }
174    #[doc = "Bit 17 - VREGO Sense Enable"]
175    #[inline(always)]
176    pub fn vregosen(&self) -> VREGOSEN_R {
177        VREGOSEN_R::new(((self.bits >> 17) & 1) != 0)
178    }
179    #[doc = "Bits 20:21 - Regulator Bias Programming Value in EM0/1"]
180    #[inline(always)]
181    pub fn biasprogem01(&self) -> BIASPROGEM01_R {
182        BIASPROGEM01_R::new(((self.bits >> 20) & 3) as u8)
183    }
184    #[doc = "Bits 24:25 - Regulator Bias Programming Value in EM2/3"]
185    #[inline(always)]
186    pub fn biasprogem23(&self) -> BIASPROGEM23_R {
187        BIASPROGEM23_R::new(((self.bits >> 24) & 3) as u8)
188    }
189}
190impl W {
191    #[doc = "Bit 1 - DMPU Active Polarity"]
192    #[inline(always)]
193    pub fn dmpuap(&mut self) -> DMPUAP_W {
194        DMPUAP_W::new(self)
195    }
196    #[doc = "Bits 4:5 - Low Energy Mode Oscillator Control"]
197    #[inline(always)]
198    pub fn lemoscctrl(&mut self) -> LEMOSCCTRL_W {
199        LEMOSCCTRL_W::new(self)
200    }
201    #[doc = "Bit 7 - Low Energy Mode USB PHY Control"]
202    #[inline(always)]
203    pub fn lemphyctrl(&mut self) -> LEMPHYCTRL_W {
204        LEMPHYCTRL_W::new(self)
205    }
206    #[doc = "Bit 9 - Low Energy Mode on Bus Idle Enable"]
207    #[inline(always)]
208    pub fn lemidleen(&mut self) -> LEMIDLEEN_W {
209        LEMIDLEEN_W::new(self)
210    }
211    #[doc = "Bit 10 - Low Energy Mode on OUT NAK Enable"]
212    #[inline(always)]
213    pub fn lemnaken(&mut self) -> LEMNAKEN_W {
214        LEMNAKEN_W::new(self)
215    }
216    #[doc = "Bit 11 - Low Energy Mode on Device Address Mismatch Enable"]
217    #[inline(always)]
218    pub fn lemaddrmen(&mut self) -> LEMADDRMEN_W {
219        LEMADDRMEN_W::new(self)
220    }
221    #[doc = "Bit 16 - Voltage Regulator Disable"]
222    #[inline(always)]
223    pub fn vregdis(&mut self) -> VREGDIS_W {
224        VREGDIS_W::new(self)
225    }
226    #[doc = "Bit 17 - VREGO Sense Enable"]
227    #[inline(always)]
228    pub fn vregosen(&mut self) -> VREGOSEN_W {
229        VREGOSEN_W::new(self)
230    }
231    #[doc = "Bits 20:21 - Regulator Bias Programming Value in EM0/1"]
232    #[inline(always)]
233    pub fn biasprogem01(&mut self) -> BIASPROGEM01_W {
234        BIASPROGEM01_W::new(self)
235    }
236    #[doc = "Bits 24:25 - Regulator Bias Programming Value in EM2/3"]
237    #[inline(always)]
238    pub fn biasprogem23(&mut self) -> BIASPROGEM23_W {
239        BIASPROGEM23_W::new(self)
240    }
241    #[doc = "Writes raw bits to the register."]
242    #[inline(always)]
243    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
244        self.0.bits(bits);
245        self
246    }
247}
248#[doc = "System 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 [ctrl](index.html) module"]
249pub struct CTRL_SPEC;
250impl crate::RegisterSpec for CTRL_SPEC {
251    type Ux = u32;
252}
253#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
254impl crate::Readable for CTRL_SPEC {
255    type Reader = R;
256}
257#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
258impl crate::Writable for CTRL_SPEC {
259    type Writer = W;
260}
261#[doc = "`reset()` method sets CTRL to value 0x20"]
262impl crate::Resettable for CTRL_SPEC {
263    #[inline(always)]
264    fn reset_value() -> Self::Ux {
265        0x20
266    }
267}