xmc4400/hrpwm0/
csgcfg.rs

1#[doc = "Register `CSGCFG` reader"]
2pub type R = crate::R<CSGCFG_SPEC>;
3#[doc = "Register `CSGCFG` writer"]
4pub type W = crate::W<CSGCFG_SPEC>;
5#[doc = "CSG0 Power Mode\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum C0PM_A {
9    #[doc = "0: CSG0 unit is powered OFF"]
10    VALUE1 = 0,
11    #[doc = "1: CSG0 unit is set in Low Speed Mode"]
12    VALUE2 = 1,
13    #[doc = "3: CSG0 unit is set in High Speed Mode"]
14    VALUE4 = 3,
15}
16impl From<C0PM_A> for u8 {
17    #[inline(always)]
18    fn from(variant: C0PM_A) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for C0PM_A {
23    type Ux = u8;
24}
25impl crate::IsEnum for C0PM_A {}
26#[doc = "Field `C0PM` reader - CSG0 Power Mode"]
27pub type C0PM_R = crate::FieldReader<C0PM_A>;
28impl C0PM_R {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<C0PM_A> {
32        match self.bits {
33            0 => Some(C0PM_A::VALUE1),
34            1 => Some(C0PM_A::VALUE2),
35            3 => Some(C0PM_A::VALUE4),
36            _ => None,
37        }
38    }
39    #[doc = "CSG0 unit is powered OFF"]
40    #[inline(always)]
41    pub fn is_value1(&self) -> bool {
42        *self == C0PM_A::VALUE1
43    }
44    #[doc = "CSG0 unit is set in Low Speed Mode"]
45    #[inline(always)]
46    pub fn is_value2(&self) -> bool {
47        *self == C0PM_A::VALUE2
48    }
49    #[doc = "CSG0 unit is set in High Speed Mode"]
50    #[inline(always)]
51    pub fn is_value4(&self) -> bool {
52        *self == C0PM_A::VALUE4
53    }
54}
55#[doc = "Field `C0PM` writer - CSG0 Power Mode"]
56pub type C0PM_W<'a, REG> = crate::FieldWriter<'a, REG, 2, C0PM_A>;
57impl<'a, REG> C0PM_W<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "CSG0 unit is powered OFF"]
63    #[inline(always)]
64    pub fn value1(self) -> &'a mut crate::W<REG> {
65        self.variant(C0PM_A::VALUE1)
66    }
67    #[doc = "CSG0 unit is set in Low Speed Mode"]
68    #[inline(always)]
69    pub fn value2(self) -> &'a mut crate::W<REG> {
70        self.variant(C0PM_A::VALUE2)
71    }
72    #[doc = "CSG0 unit is set in High Speed Mode"]
73    #[inline(always)]
74    pub fn value4(self) -> &'a mut crate::W<REG> {
75        self.variant(C0PM_A::VALUE4)
76    }
77}
78#[doc = "CSG1 Power Mode\n\nValue on reset: 0"]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80#[repr(u8)]
81pub enum C1PM_A {
82    #[doc = "0: CSG1 unit is powered OFF"]
83    VALUE1 = 0,
84    #[doc = "1: CSG1 unit is set in Low Speed Mode"]
85    VALUE2 = 1,
86    #[doc = "3: CSG1 unit is set in High Speed Mode"]
87    VALUE4 = 3,
88}
89impl From<C1PM_A> for u8 {
90    #[inline(always)]
91    fn from(variant: C1PM_A) -> Self {
92        variant as _
93    }
94}
95impl crate::FieldSpec for C1PM_A {
96    type Ux = u8;
97}
98impl crate::IsEnum for C1PM_A {}
99#[doc = "Field `C1PM` reader - CSG1 Power Mode"]
100pub type C1PM_R = crate::FieldReader<C1PM_A>;
101impl C1PM_R {
102    #[doc = "Get enumerated values variant"]
103    #[inline(always)]
104    pub const fn variant(&self) -> Option<C1PM_A> {
105        match self.bits {
106            0 => Some(C1PM_A::VALUE1),
107            1 => Some(C1PM_A::VALUE2),
108            3 => Some(C1PM_A::VALUE4),
109            _ => None,
110        }
111    }
112    #[doc = "CSG1 unit is powered OFF"]
113    #[inline(always)]
114    pub fn is_value1(&self) -> bool {
115        *self == C1PM_A::VALUE1
116    }
117    #[doc = "CSG1 unit is set in Low Speed Mode"]
118    #[inline(always)]
119    pub fn is_value2(&self) -> bool {
120        *self == C1PM_A::VALUE2
121    }
122    #[doc = "CSG1 unit is set in High Speed Mode"]
123    #[inline(always)]
124    pub fn is_value4(&self) -> bool {
125        *self == C1PM_A::VALUE4
126    }
127}
128#[doc = "Field `C1PM` writer - CSG1 Power Mode"]
129pub type C1PM_W<'a, REG> = crate::FieldWriter<'a, REG, 2, C1PM_A>;
130impl<'a, REG> C1PM_W<'a, REG>
131where
132    REG: crate::Writable + crate::RegisterSpec,
133    REG::Ux: From<u8>,
134{
135    #[doc = "CSG1 unit is powered OFF"]
136    #[inline(always)]
137    pub fn value1(self) -> &'a mut crate::W<REG> {
138        self.variant(C1PM_A::VALUE1)
139    }
140    #[doc = "CSG1 unit is set in Low Speed Mode"]
141    #[inline(always)]
142    pub fn value2(self) -> &'a mut crate::W<REG> {
143        self.variant(C1PM_A::VALUE2)
144    }
145    #[doc = "CSG1 unit is set in High Speed Mode"]
146    #[inline(always)]
147    pub fn value4(self) -> &'a mut crate::W<REG> {
148        self.variant(C1PM_A::VALUE4)
149    }
150}
151#[doc = "CSG2 Power Mode\n\nValue on reset: 0"]
152#[derive(Clone, Copy, Debug, PartialEq, Eq)]
153#[repr(u8)]
154pub enum C2PM_A {
155    #[doc = "0: CSG2 unit is powered OFF"]
156    VALUE1 = 0,
157    #[doc = "1: CSG2 unit is set in Low Speed Mode"]
158    VALUE2 = 1,
159    #[doc = "3: CSG2 unit is set in High Speed Mode"]
160    VALUE4 = 3,
161}
162impl From<C2PM_A> for u8 {
163    #[inline(always)]
164    fn from(variant: C2PM_A) -> Self {
165        variant as _
166    }
167}
168impl crate::FieldSpec for C2PM_A {
169    type Ux = u8;
170}
171impl crate::IsEnum for C2PM_A {}
172#[doc = "Field `C2PM` reader - CSG2 Power Mode"]
173pub type C2PM_R = crate::FieldReader<C2PM_A>;
174impl C2PM_R {
175    #[doc = "Get enumerated values variant"]
176    #[inline(always)]
177    pub const fn variant(&self) -> Option<C2PM_A> {
178        match self.bits {
179            0 => Some(C2PM_A::VALUE1),
180            1 => Some(C2PM_A::VALUE2),
181            3 => Some(C2PM_A::VALUE4),
182            _ => None,
183        }
184    }
185    #[doc = "CSG2 unit is powered OFF"]
186    #[inline(always)]
187    pub fn is_value1(&self) -> bool {
188        *self == C2PM_A::VALUE1
189    }
190    #[doc = "CSG2 unit is set in Low Speed Mode"]
191    #[inline(always)]
192    pub fn is_value2(&self) -> bool {
193        *self == C2PM_A::VALUE2
194    }
195    #[doc = "CSG2 unit is set in High Speed Mode"]
196    #[inline(always)]
197    pub fn is_value4(&self) -> bool {
198        *self == C2PM_A::VALUE4
199    }
200}
201#[doc = "Field `C2PM` writer - CSG2 Power Mode"]
202pub type C2PM_W<'a, REG> = crate::FieldWriter<'a, REG, 2, C2PM_A>;
203impl<'a, REG> C2PM_W<'a, REG>
204where
205    REG: crate::Writable + crate::RegisterSpec,
206    REG::Ux: From<u8>,
207{
208    #[doc = "CSG2 unit is powered OFF"]
209    #[inline(always)]
210    pub fn value1(self) -> &'a mut crate::W<REG> {
211        self.variant(C2PM_A::VALUE1)
212    }
213    #[doc = "CSG2 unit is set in Low Speed Mode"]
214    #[inline(always)]
215    pub fn value2(self) -> &'a mut crate::W<REG> {
216        self.variant(C2PM_A::VALUE2)
217    }
218    #[doc = "CSG2 unit is set in High Speed Mode"]
219    #[inline(always)]
220    pub fn value4(self) -> &'a mut crate::W<REG> {
221        self.variant(C2PM_A::VALUE4)
222    }
223}
224#[doc = "Field `C0CD` reader - CSG0 Clock disable"]
225pub type C0CD_R = crate::BitReader;
226#[doc = "Field `C0CD` writer - CSG0 Clock disable"]
227pub type C0CD_W<'a, REG> = crate::BitWriter<'a, REG>;
228#[doc = "Field `C1CD` reader - CSG1 Clock disable"]
229pub type C1CD_R = crate::BitReader;
230#[doc = "Field `C1CD` writer - CSG1 Clock disable"]
231pub type C1CD_W<'a, REG> = crate::BitWriter<'a, REG>;
232#[doc = "Field `C2CD` reader - CSG2 Clock disable"]
233pub type C2CD_R = crate::BitReader;
234#[doc = "Field `C2CD` writer - CSG2 Clock disable"]
235pub type C2CD_W<'a, REG> = crate::BitWriter<'a, REG>;
236impl R {
237    #[doc = "Bits 0:1 - CSG0 Power Mode"]
238    #[inline(always)]
239    pub fn c0pm(&self) -> C0PM_R {
240        C0PM_R::new((self.bits & 3) as u8)
241    }
242    #[doc = "Bits 2:3 - CSG1 Power Mode"]
243    #[inline(always)]
244    pub fn c1pm(&self) -> C1PM_R {
245        C1PM_R::new(((self.bits >> 2) & 3) as u8)
246    }
247    #[doc = "Bits 4:5 - CSG2 Power Mode"]
248    #[inline(always)]
249    pub fn c2pm(&self) -> C2PM_R {
250        C2PM_R::new(((self.bits >> 4) & 3) as u8)
251    }
252    #[doc = "Bit 16 - CSG0 Clock disable"]
253    #[inline(always)]
254    pub fn c0cd(&self) -> C0CD_R {
255        C0CD_R::new(((self.bits >> 16) & 1) != 0)
256    }
257    #[doc = "Bit 17 - CSG1 Clock disable"]
258    #[inline(always)]
259    pub fn c1cd(&self) -> C1CD_R {
260        C1CD_R::new(((self.bits >> 17) & 1) != 0)
261    }
262    #[doc = "Bit 18 - CSG2 Clock disable"]
263    #[inline(always)]
264    pub fn c2cd(&self) -> C2CD_R {
265        C2CD_R::new(((self.bits >> 18) & 1) != 0)
266    }
267}
268impl W {
269    #[doc = "Bits 0:1 - CSG0 Power Mode"]
270    #[inline(always)]
271    pub fn c0pm(&mut self) -> C0PM_W<CSGCFG_SPEC> {
272        C0PM_W::new(self, 0)
273    }
274    #[doc = "Bits 2:3 - CSG1 Power Mode"]
275    #[inline(always)]
276    pub fn c1pm(&mut self) -> C1PM_W<CSGCFG_SPEC> {
277        C1PM_W::new(self, 2)
278    }
279    #[doc = "Bits 4:5 - CSG2 Power Mode"]
280    #[inline(always)]
281    pub fn c2pm(&mut self) -> C2PM_W<CSGCFG_SPEC> {
282        C2PM_W::new(self, 4)
283    }
284    #[doc = "Bit 16 - CSG0 Clock disable"]
285    #[inline(always)]
286    pub fn c0cd(&mut self) -> C0CD_W<CSGCFG_SPEC> {
287        C0CD_W::new(self, 16)
288    }
289    #[doc = "Bit 17 - CSG1 Clock disable"]
290    #[inline(always)]
291    pub fn c1cd(&mut self) -> C1CD_W<CSGCFG_SPEC> {
292        C1CD_W::new(self, 17)
293    }
294    #[doc = "Bit 18 - CSG2 Clock disable"]
295    #[inline(always)]
296    pub fn c2cd(&mut self) -> C2CD_W<CSGCFG_SPEC> {
297        C2CD_W::new(self, 18)
298    }
299}
300#[doc = "Global CSG configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`csgcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`csgcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
301pub struct CSGCFG_SPEC;
302impl crate::RegisterSpec for CSGCFG_SPEC {
303    type Ux = u32;
304}
305#[doc = "`read()` method returns [`csgcfg::R`](R) reader structure"]
306impl crate::Readable for CSGCFG_SPEC {}
307#[doc = "`write(|w| ..)` method takes [`csgcfg::W`](W) writer structure"]
308impl crate::Writable for CSGCFG_SPEC {
309    type Safety = crate::Unsafe;
310    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
311    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
312}
313#[doc = "`reset()` method sets CSGCFG to value 0"]
314impl crate::Resettable for CSGCFG_SPEC {
315    const RESET_VALUE: u32 = 0;
316}