Skip to main content

mcxa_pac/flexpwm0/
sm2octrl.rs

1#[doc = "Register `SM2OCTRL` reader"]
2pub type R = crate::R<Sm2octrlSpec>;
3#[doc = "Register `SM2OCTRL` writer"]
4pub type W = crate::W<Sm2octrlSpec>;
5#[doc = "PWM_X Fault State\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum Pwmxfs {
10    #[doc = "0: Output is forced to logic 0 state prior to consideration of output polarity control."]
11    Logic0 = 0,
12    #[doc = "1: Output is forced to logic 1 state prior to consideration of output polarity control."]
13    Logic1 = 1,
14    #[doc = "2: Output is put in a high-impedance state."]
15    Tristated2 = 2,
16    #[doc = "3: Output is put in a high-impedance state."]
17    Tristated3 = 3,
18}
19impl From<Pwmxfs> for u8 {
20    #[inline(always)]
21    fn from(variant: Pwmxfs) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for Pwmxfs {
26    type Ux = u8;
27}
28impl crate::IsEnum for Pwmxfs {}
29#[doc = "Field `PWMXFS` reader - PWM_X Fault State"]
30pub type PwmxfsR = crate::FieldReader<Pwmxfs>;
31impl PwmxfsR {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> Pwmxfs {
35        match self.bits {
36            0 => Pwmxfs::Logic0,
37            1 => Pwmxfs::Logic1,
38            2 => Pwmxfs::Tristated2,
39            3 => Pwmxfs::Tristated3,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
44    #[inline(always)]
45    pub fn is_logic_0(&self) -> bool {
46        *self == Pwmxfs::Logic0
47    }
48    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
49    #[inline(always)]
50    pub fn is_logic_1(&self) -> bool {
51        *self == Pwmxfs::Logic1
52    }
53    #[doc = "Output is put in a high-impedance state."]
54    #[inline(always)]
55    pub fn is_tristated_2(&self) -> bool {
56        *self == Pwmxfs::Tristated2
57    }
58    #[doc = "Output is put in a high-impedance state."]
59    #[inline(always)]
60    pub fn is_tristated_3(&self) -> bool {
61        *self == Pwmxfs::Tristated3
62    }
63}
64#[doc = "Field `PWMXFS` writer - PWM_X Fault State"]
65pub type PwmxfsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Pwmxfs, crate::Safe>;
66impl<'a, REG> PwmxfsW<'a, REG>
67where
68    REG: crate::Writable + crate::RegisterSpec,
69    REG::Ux: From<u8>,
70{
71    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
72    #[inline(always)]
73    pub fn logic_0(self) -> &'a mut crate::W<REG> {
74        self.variant(Pwmxfs::Logic0)
75    }
76    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
77    #[inline(always)]
78    pub fn logic_1(self) -> &'a mut crate::W<REG> {
79        self.variant(Pwmxfs::Logic1)
80    }
81    #[doc = "Output is put in a high-impedance state."]
82    #[inline(always)]
83    pub fn tristated_2(self) -> &'a mut crate::W<REG> {
84        self.variant(Pwmxfs::Tristated2)
85    }
86    #[doc = "Output is put in a high-impedance state."]
87    #[inline(always)]
88    pub fn tristated_3(self) -> &'a mut crate::W<REG> {
89        self.variant(Pwmxfs::Tristated3)
90    }
91}
92#[doc = "PWM_B Fault State\n\nValue on reset: 0"]
93#[cfg_attr(feature = "defmt", derive(defmt::Format))]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum Pwmbfs {
97    #[doc = "0: Output is forced to logic 0 state prior to consideration of output polarity control."]
98    Logic0 = 0,
99    #[doc = "1: Output is forced to logic 1 state prior to consideration of output polarity control."]
100    Logic1 = 1,
101    #[doc = "2: Output is put in a high-impedance state."]
102    Tristated2 = 2,
103    #[doc = "3: Output is put in a high-impedance state."]
104    Tristated3 = 3,
105}
106impl From<Pwmbfs> for u8 {
107    #[inline(always)]
108    fn from(variant: Pwmbfs) -> Self {
109        variant as _
110    }
111}
112impl crate::FieldSpec for Pwmbfs {
113    type Ux = u8;
114}
115impl crate::IsEnum for Pwmbfs {}
116#[doc = "Field `PWMBFS` reader - PWM_B Fault State"]
117pub type PwmbfsR = crate::FieldReader<Pwmbfs>;
118impl PwmbfsR {
119    #[doc = "Get enumerated values variant"]
120    #[inline(always)]
121    pub const fn variant(&self) -> Pwmbfs {
122        match self.bits {
123            0 => Pwmbfs::Logic0,
124            1 => Pwmbfs::Logic1,
125            2 => Pwmbfs::Tristated2,
126            3 => Pwmbfs::Tristated3,
127            _ => unreachable!(),
128        }
129    }
130    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
131    #[inline(always)]
132    pub fn is_logic_0(&self) -> bool {
133        *self == Pwmbfs::Logic0
134    }
135    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
136    #[inline(always)]
137    pub fn is_logic_1(&self) -> bool {
138        *self == Pwmbfs::Logic1
139    }
140    #[doc = "Output is put in a high-impedance state."]
141    #[inline(always)]
142    pub fn is_tristated_2(&self) -> bool {
143        *self == Pwmbfs::Tristated2
144    }
145    #[doc = "Output is put in a high-impedance state."]
146    #[inline(always)]
147    pub fn is_tristated_3(&self) -> bool {
148        *self == Pwmbfs::Tristated3
149    }
150}
151#[doc = "Field `PWMBFS` writer - PWM_B Fault State"]
152pub type PwmbfsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Pwmbfs, crate::Safe>;
153impl<'a, REG> PwmbfsW<'a, REG>
154where
155    REG: crate::Writable + crate::RegisterSpec,
156    REG::Ux: From<u8>,
157{
158    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
159    #[inline(always)]
160    pub fn logic_0(self) -> &'a mut crate::W<REG> {
161        self.variant(Pwmbfs::Logic0)
162    }
163    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
164    #[inline(always)]
165    pub fn logic_1(self) -> &'a mut crate::W<REG> {
166        self.variant(Pwmbfs::Logic1)
167    }
168    #[doc = "Output is put in a high-impedance state."]
169    #[inline(always)]
170    pub fn tristated_2(self) -> &'a mut crate::W<REG> {
171        self.variant(Pwmbfs::Tristated2)
172    }
173    #[doc = "Output is put in a high-impedance state."]
174    #[inline(always)]
175    pub fn tristated_3(self) -> &'a mut crate::W<REG> {
176        self.variant(Pwmbfs::Tristated3)
177    }
178}
179#[doc = "PWM_A Fault State\n\nValue on reset: 0"]
180#[cfg_attr(feature = "defmt", derive(defmt::Format))]
181#[derive(Clone, Copy, Debug, PartialEq, Eq)]
182#[repr(u8)]
183pub enum Pwmafs {
184    #[doc = "0: Output is forced to logic 0 state prior to consideration of output polarity control."]
185    Logic0 = 0,
186    #[doc = "1: Output is forced to logic 1 state prior to consideration of output polarity control."]
187    Logic1 = 1,
188    #[doc = "2: Output is put in a high-impedance state."]
189    Tristated2 = 2,
190    #[doc = "3: Output is put in a high-impedance state."]
191    Tristated3 = 3,
192}
193impl From<Pwmafs> for u8 {
194    #[inline(always)]
195    fn from(variant: Pwmafs) -> Self {
196        variant as _
197    }
198}
199impl crate::FieldSpec for Pwmafs {
200    type Ux = u8;
201}
202impl crate::IsEnum for Pwmafs {}
203#[doc = "Field `PWMAFS` reader - PWM_A Fault State"]
204pub type PwmafsR = crate::FieldReader<Pwmafs>;
205impl PwmafsR {
206    #[doc = "Get enumerated values variant"]
207    #[inline(always)]
208    pub const fn variant(&self) -> Pwmafs {
209        match self.bits {
210            0 => Pwmafs::Logic0,
211            1 => Pwmafs::Logic1,
212            2 => Pwmafs::Tristated2,
213            3 => Pwmafs::Tristated3,
214            _ => unreachable!(),
215        }
216    }
217    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
218    #[inline(always)]
219    pub fn is_logic_0(&self) -> bool {
220        *self == Pwmafs::Logic0
221    }
222    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
223    #[inline(always)]
224    pub fn is_logic_1(&self) -> bool {
225        *self == Pwmafs::Logic1
226    }
227    #[doc = "Output is put in a high-impedance state."]
228    #[inline(always)]
229    pub fn is_tristated_2(&self) -> bool {
230        *self == Pwmafs::Tristated2
231    }
232    #[doc = "Output is put in a high-impedance state."]
233    #[inline(always)]
234    pub fn is_tristated_3(&self) -> bool {
235        *self == Pwmafs::Tristated3
236    }
237}
238#[doc = "Field `PWMAFS` writer - PWM_A Fault State"]
239pub type PwmafsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Pwmafs, crate::Safe>;
240impl<'a, REG> PwmafsW<'a, REG>
241where
242    REG: crate::Writable + crate::RegisterSpec,
243    REG::Ux: From<u8>,
244{
245    #[doc = "Output is forced to logic 0 state prior to consideration of output polarity control."]
246    #[inline(always)]
247    pub fn logic_0(self) -> &'a mut crate::W<REG> {
248        self.variant(Pwmafs::Logic0)
249    }
250    #[doc = "Output is forced to logic 1 state prior to consideration of output polarity control."]
251    #[inline(always)]
252    pub fn logic_1(self) -> &'a mut crate::W<REG> {
253        self.variant(Pwmafs::Logic1)
254    }
255    #[doc = "Output is put in a high-impedance state."]
256    #[inline(always)]
257    pub fn tristated_2(self) -> &'a mut crate::W<REG> {
258        self.variant(Pwmafs::Tristated2)
259    }
260    #[doc = "Output is put in a high-impedance state."]
261    #[inline(always)]
262    pub fn tristated_3(self) -> &'a mut crate::W<REG> {
263        self.variant(Pwmafs::Tristated3)
264    }
265}
266#[doc = "PWM_X Output Polarity\n\nValue on reset: 0"]
267#[cfg_attr(feature = "defmt", derive(defmt::Format))]
268#[derive(Clone, Copy, Debug, PartialEq, Eq)]
269pub enum Polx {
270    #[doc = "0: PWM_X output not inverted. A high level on the PWM_X pin represents the \"on\" or \"active\" state."]
271    NotInverted = 0,
272    #[doc = "1: PWM_X output inverted. A low level on the PWM_X pin represents the \"on\" or \"active\" state."]
273    Inverted = 1,
274}
275impl From<Polx> for bool {
276    #[inline(always)]
277    fn from(variant: Polx) -> Self {
278        variant as u8 != 0
279    }
280}
281#[doc = "Field `POLX` reader - PWM_X Output Polarity"]
282pub type PolxR = crate::BitReader<Polx>;
283impl PolxR {
284    #[doc = "Get enumerated values variant"]
285    #[inline(always)]
286    pub const fn variant(&self) -> Polx {
287        match self.bits {
288            false => Polx::NotInverted,
289            true => Polx::Inverted,
290        }
291    }
292    #[doc = "PWM_X output not inverted. A high level on the PWM_X pin represents the \"on\" or \"active\" state."]
293    #[inline(always)]
294    pub fn is_not_inverted(&self) -> bool {
295        *self == Polx::NotInverted
296    }
297    #[doc = "PWM_X output inverted. A low level on the PWM_X pin represents the \"on\" or \"active\" state."]
298    #[inline(always)]
299    pub fn is_inverted(&self) -> bool {
300        *self == Polx::Inverted
301    }
302}
303#[doc = "Field `POLX` writer - PWM_X Output Polarity"]
304pub type PolxW<'a, REG> = crate::BitWriter<'a, REG, Polx>;
305impl<'a, REG> PolxW<'a, REG>
306where
307    REG: crate::Writable + crate::RegisterSpec,
308{
309    #[doc = "PWM_X output not inverted. A high level on the PWM_X pin represents the \"on\" or \"active\" state."]
310    #[inline(always)]
311    pub fn not_inverted(self) -> &'a mut crate::W<REG> {
312        self.variant(Polx::NotInverted)
313    }
314    #[doc = "PWM_X output inverted. A low level on the PWM_X pin represents the \"on\" or \"active\" state."]
315    #[inline(always)]
316    pub fn inverted(self) -> &'a mut crate::W<REG> {
317        self.variant(Polx::Inverted)
318    }
319}
320#[doc = "PWM_B Output Polarity\n\nValue on reset: 0"]
321#[cfg_attr(feature = "defmt", derive(defmt::Format))]
322#[derive(Clone, Copy, Debug, PartialEq, Eq)]
323pub enum Polb {
324    #[doc = "0: PWM_B output not inverted. A high level on the PWM_B pin represents the \"on\" or \"active\" state."]
325    NotInverted = 0,
326    #[doc = "1: PWM_B output inverted. A low level on the PWM_B pin represents the \"on\" or \"active\" state."]
327    Inverted = 1,
328}
329impl From<Polb> for bool {
330    #[inline(always)]
331    fn from(variant: Polb) -> Self {
332        variant as u8 != 0
333    }
334}
335#[doc = "Field `POLB` reader - PWM_B Output Polarity"]
336pub type PolbR = crate::BitReader<Polb>;
337impl PolbR {
338    #[doc = "Get enumerated values variant"]
339    #[inline(always)]
340    pub const fn variant(&self) -> Polb {
341        match self.bits {
342            false => Polb::NotInverted,
343            true => Polb::Inverted,
344        }
345    }
346    #[doc = "PWM_B output not inverted. A high level on the PWM_B pin represents the \"on\" or \"active\" state."]
347    #[inline(always)]
348    pub fn is_not_inverted(&self) -> bool {
349        *self == Polb::NotInverted
350    }
351    #[doc = "PWM_B output inverted. A low level on the PWM_B pin represents the \"on\" or \"active\" state."]
352    #[inline(always)]
353    pub fn is_inverted(&self) -> bool {
354        *self == Polb::Inverted
355    }
356}
357#[doc = "Field `POLB` writer - PWM_B Output Polarity"]
358pub type PolbW<'a, REG> = crate::BitWriter<'a, REG, Polb>;
359impl<'a, REG> PolbW<'a, REG>
360where
361    REG: crate::Writable + crate::RegisterSpec,
362{
363    #[doc = "PWM_B output not inverted. A high level on the PWM_B pin represents the \"on\" or \"active\" state."]
364    #[inline(always)]
365    pub fn not_inverted(self) -> &'a mut crate::W<REG> {
366        self.variant(Polb::NotInverted)
367    }
368    #[doc = "PWM_B output inverted. A low level on the PWM_B pin represents the \"on\" or \"active\" state."]
369    #[inline(always)]
370    pub fn inverted(self) -> &'a mut crate::W<REG> {
371        self.variant(Polb::Inverted)
372    }
373}
374#[doc = "PWM_A Output Polarity\n\nValue on reset: 0"]
375#[cfg_attr(feature = "defmt", derive(defmt::Format))]
376#[derive(Clone, Copy, Debug, PartialEq, Eq)]
377pub enum Pola {
378    #[doc = "0: PWM_A output not inverted. A high level on the PWM_A pin represents the \"on\" or \"active\" state."]
379    NotInverted = 0,
380    #[doc = "1: PWM_A output inverted. A low level on the PWM_A pin represents the \"on\" or \"active\" state."]
381    Inverted = 1,
382}
383impl From<Pola> for bool {
384    #[inline(always)]
385    fn from(variant: Pola) -> Self {
386        variant as u8 != 0
387    }
388}
389#[doc = "Field `POLA` reader - PWM_A Output Polarity"]
390pub type PolaR = crate::BitReader<Pola>;
391impl PolaR {
392    #[doc = "Get enumerated values variant"]
393    #[inline(always)]
394    pub const fn variant(&self) -> Pola {
395        match self.bits {
396            false => Pola::NotInverted,
397            true => Pola::Inverted,
398        }
399    }
400    #[doc = "PWM_A output not inverted. A high level on the PWM_A pin represents the \"on\" or \"active\" state."]
401    #[inline(always)]
402    pub fn is_not_inverted(&self) -> bool {
403        *self == Pola::NotInverted
404    }
405    #[doc = "PWM_A output inverted. A low level on the PWM_A pin represents the \"on\" or \"active\" state."]
406    #[inline(always)]
407    pub fn is_inverted(&self) -> bool {
408        *self == Pola::Inverted
409    }
410}
411#[doc = "Field `POLA` writer - PWM_A Output Polarity"]
412pub type PolaW<'a, REG> = crate::BitWriter<'a, REG, Pola>;
413impl<'a, REG> PolaW<'a, REG>
414where
415    REG: crate::Writable + crate::RegisterSpec,
416{
417    #[doc = "PWM_A output not inverted. A high level on the PWM_A pin represents the \"on\" or \"active\" state."]
418    #[inline(always)]
419    pub fn not_inverted(self) -> &'a mut crate::W<REG> {
420        self.variant(Pola::NotInverted)
421    }
422    #[doc = "PWM_A output inverted. A low level on the PWM_A pin represents the \"on\" or \"active\" state."]
423    #[inline(always)]
424    pub fn inverted(self) -> &'a mut crate::W<REG> {
425        self.variant(Pola::Inverted)
426    }
427}
428#[doc = "Field `PWMX_IN` reader - PWM_X Input"]
429pub type PwmxInR = crate::BitReader;
430#[doc = "Field `PWMB_IN` reader - PWM_B Input"]
431pub type PwmbInR = crate::BitReader;
432#[doc = "Field `PWMA_IN` reader - PWM_A Input"]
433pub type PwmaInR = crate::BitReader;
434impl R {
435    #[doc = "Bits 0:1 - PWM_X Fault State"]
436    #[inline(always)]
437    pub fn pwmxfs(&self) -> PwmxfsR {
438        PwmxfsR::new((self.bits & 3) as u8)
439    }
440    #[doc = "Bits 2:3 - PWM_B Fault State"]
441    #[inline(always)]
442    pub fn pwmbfs(&self) -> PwmbfsR {
443        PwmbfsR::new(((self.bits >> 2) & 3) as u8)
444    }
445    #[doc = "Bits 4:5 - PWM_A Fault State"]
446    #[inline(always)]
447    pub fn pwmafs(&self) -> PwmafsR {
448        PwmafsR::new(((self.bits >> 4) & 3) as u8)
449    }
450    #[doc = "Bit 8 - PWM_X Output Polarity"]
451    #[inline(always)]
452    pub fn polx(&self) -> PolxR {
453        PolxR::new(((self.bits >> 8) & 1) != 0)
454    }
455    #[doc = "Bit 9 - PWM_B Output Polarity"]
456    #[inline(always)]
457    pub fn polb(&self) -> PolbR {
458        PolbR::new(((self.bits >> 9) & 1) != 0)
459    }
460    #[doc = "Bit 10 - PWM_A Output Polarity"]
461    #[inline(always)]
462    pub fn pola(&self) -> PolaR {
463        PolaR::new(((self.bits >> 10) & 1) != 0)
464    }
465    #[doc = "Bit 13 - PWM_X Input"]
466    #[inline(always)]
467    pub fn pwmx_in(&self) -> PwmxInR {
468        PwmxInR::new(((self.bits >> 13) & 1) != 0)
469    }
470    #[doc = "Bit 14 - PWM_B Input"]
471    #[inline(always)]
472    pub fn pwmb_in(&self) -> PwmbInR {
473        PwmbInR::new(((self.bits >> 14) & 1) != 0)
474    }
475    #[doc = "Bit 15 - PWM_A Input"]
476    #[inline(always)]
477    pub fn pwma_in(&self) -> PwmaInR {
478        PwmaInR::new(((self.bits >> 15) & 1) != 0)
479    }
480}
481#[cfg(feature = "debug")]
482impl core::fmt::Debug for R {
483    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
484        f.debug_struct("SM2OCTRL")
485            .field("pwmxfs", &self.pwmxfs())
486            .field("pwmbfs", &self.pwmbfs())
487            .field("pwmafs", &self.pwmafs())
488            .field("polx", &self.polx())
489            .field("polb", &self.polb())
490            .field("pola", &self.pola())
491            .field("pwmx_in", &self.pwmx_in())
492            .field("pwmb_in", &self.pwmb_in())
493            .field("pwma_in", &self.pwma_in())
494            .finish()
495    }
496}
497impl W {
498    #[doc = "Bits 0:1 - PWM_X Fault State"]
499    #[inline(always)]
500    pub fn pwmxfs(&mut self) -> PwmxfsW<'_, Sm2octrlSpec> {
501        PwmxfsW::new(self, 0)
502    }
503    #[doc = "Bits 2:3 - PWM_B Fault State"]
504    #[inline(always)]
505    pub fn pwmbfs(&mut self) -> PwmbfsW<'_, Sm2octrlSpec> {
506        PwmbfsW::new(self, 2)
507    }
508    #[doc = "Bits 4:5 - PWM_A Fault State"]
509    #[inline(always)]
510    pub fn pwmafs(&mut self) -> PwmafsW<'_, Sm2octrlSpec> {
511        PwmafsW::new(self, 4)
512    }
513    #[doc = "Bit 8 - PWM_X Output Polarity"]
514    #[inline(always)]
515    pub fn polx(&mut self) -> PolxW<'_, Sm2octrlSpec> {
516        PolxW::new(self, 8)
517    }
518    #[doc = "Bit 9 - PWM_B Output Polarity"]
519    #[inline(always)]
520    pub fn polb(&mut self) -> PolbW<'_, Sm2octrlSpec> {
521        PolbW::new(self, 9)
522    }
523    #[doc = "Bit 10 - PWM_A Output Polarity"]
524    #[inline(always)]
525    pub fn pola(&mut self) -> PolaW<'_, Sm2octrlSpec> {
526        PolaW::new(self, 10)
527    }
528}
529#[doc = "Output Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`sm2octrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sm2octrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
530pub struct Sm2octrlSpec;
531impl crate::RegisterSpec for Sm2octrlSpec {
532    type Ux = u16;
533}
534#[doc = "`read()` method returns [`sm2octrl::R`](R) reader structure"]
535impl crate::Readable for Sm2octrlSpec {}
536#[doc = "`write(|w| ..)` method takes [`sm2octrl::W`](W) writer structure"]
537impl crate::Writable for Sm2octrlSpec {
538    type Safety = crate::Unsafe;
539}
540#[doc = "`reset()` method sets SM2OCTRL to value 0"]
541impl crate::Resettable for Sm2octrlSpec {}