mcxa_pac/flexpwm0/
mctrl.rs1#[doc = "Register `MCTRL` reader"]
2pub type R = crate::R<MctrlSpec>;
3#[doc = "Register `MCTRL` writer"]
4pub type W = crate::W<MctrlSpec>;
5#[doc = "Load Okay\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 Ldok {
10 #[doc = "0: Do not load new values."]
11 Disabled = 0,
12 #[doc = "1: Load prescaler, modulus, and PWM values of the corresponding submodule."]
13 Enabled = 1,
14}
15impl From<Ldok> for u8 {
16 #[inline(always)]
17 fn from(variant: Ldok) -> Self {
18 variant as _
19 }
20}
21impl crate::FieldSpec for Ldok {
22 type Ux = u8;
23}
24impl crate::IsEnum for Ldok {}
25#[doc = "Field `LDOK` reader - Load Okay"]
26pub type LdokR = crate::FieldReader<Ldok>;
27impl LdokR {
28 #[doc = "Get enumerated values variant"]
29 #[inline(always)]
30 pub const fn variant(&self) -> Option<Ldok> {
31 match self.bits {
32 0 => Some(Ldok::Disabled),
33 1 => Some(Ldok::Enabled),
34 _ => None,
35 }
36 }
37 #[doc = "Do not load new values."]
38 #[inline(always)]
39 pub fn is_disabled(&self) -> bool {
40 *self == Ldok::Disabled
41 }
42 #[doc = "Load prescaler, modulus, and PWM values of the corresponding submodule."]
43 #[inline(always)]
44 pub fn is_enabled(&self) -> bool {
45 *self == Ldok::Enabled
46 }
47}
48#[doc = "Field `LDOK` writer - Load Okay"]
49pub type LdokW<'a, REG> = crate::FieldWriter<'a, REG, 4, Ldok>;
50impl<'a, REG> LdokW<'a, REG>
51where
52 REG: crate::Writable + crate::RegisterSpec,
53 REG::Ux: From<u8>,
54{
55 #[doc = "Do not load new values."]
56 #[inline(always)]
57 pub fn disabled(self) -> &'a mut crate::W<REG> {
58 self.variant(Ldok::Disabled)
59 }
60 #[doc = "Load prescaler, modulus, and PWM values of the corresponding submodule."]
61 #[inline(always)]
62 pub fn enabled(self) -> &'a mut crate::W<REG> {
63 self.variant(Ldok::Enabled)
64 }
65}
66#[doc = "Field `CLDOK` reader - Clear Load Okay"]
67pub type CldokR = crate::FieldReader;
68#[doc = "Field `CLDOK` writer - Clear Load Okay"]
69pub type CldokW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
70#[doc = "Run\n\nValue on reset: 0"]
71#[cfg_attr(feature = "defmt", derive(defmt::Format))]
72#[derive(Clone, Copy, Debug, PartialEq, Eq)]
73#[repr(u8)]
74pub enum Run {
75 #[doc = "0: PWM counter is stopped, but PWM outputs hold the current state."]
76 Disabled = 0,
77 #[doc = "1: PWM counter is started in the corresponding submodule."]
78 Enabled = 1,
79}
80impl From<Run> for u8 {
81 #[inline(always)]
82 fn from(variant: Run) -> Self {
83 variant as _
84 }
85}
86impl crate::FieldSpec for Run {
87 type Ux = u8;
88}
89impl crate::IsEnum for Run {}
90#[doc = "Field `RUN` reader - Run"]
91pub type RunR = crate::FieldReader<Run>;
92impl RunR {
93 #[doc = "Get enumerated values variant"]
94 #[inline(always)]
95 pub const fn variant(&self) -> Option<Run> {
96 match self.bits {
97 0 => Some(Run::Disabled),
98 1 => Some(Run::Enabled),
99 _ => None,
100 }
101 }
102 #[doc = "PWM counter is stopped, but PWM outputs hold the current state."]
103 #[inline(always)]
104 pub fn is_disabled(&self) -> bool {
105 *self == Run::Disabled
106 }
107 #[doc = "PWM counter is started in the corresponding submodule."]
108 #[inline(always)]
109 pub fn is_enabled(&self) -> bool {
110 *self == Run::Enabled
111 }
112}
113#[doc = "Field `RUN` writer - Run"]
114pub type RunW<'a, REG> = crate::FieldWriter<'a, REG, 4, Run>;
115impl<'a, REG> RunW<'a, REG>
116where
117 REG: crate::Writable + crate::RegisterSpec,
118 REG::Ux: From<u8>,
119{
120 #[doc = "PWM counter is stopped, but PWM outputs hold the current state."]
121 #[inline(always)]
122 pub fn disabled(self) -> &'a mut crate::W<REG> {
123 self.variant(Run::Disabled)
124 }
125 #[doc = "PWM counter is started in the corresponding submodule."]
126 #[inline(always)]
127 pub fn enabled(self) -> &'a mut crate::W<REG> {
128 self.variant(Run::Enabled)
129 }
130}
131#[doc = "Current Polarity\n\nValue on reset: 0"]
132#[cfg_attr(feature = "defmt", derive(defmt::Format))]
133#[derive(Clone, Copy, Debug, PartialEq, Eq)]
134#[repr(u8)]
135pub enum Ipol {
136 #[doc = "0: PWM23 is used to generate complementary PWM pair in the corresponding submodule."]
137 Pwm23 = 0,
138 #[doc = "1: PWM45 is used to generate complementary PWM pair in the corresponding submodule."]
139 Pwm45 = 1,
140}
141impl From<Ipol> for u8 {
142 #[inline(always)]
143 fn from(variant: Ipol) -> Self {
144 variant as _
145 }
146}
147impl crate::FieldSpec for Ipol {
148 type Ux = u8;
149}
150impl crate::IsEnum for Ipol {}
151#[doc = "Field `IPOL` reader - Current Polarity"]
152pub type IpolR = crate::FieldReader<Ipol>;
153impl IpolR {
154 #[doc = "Get enumerated values variant"]
155 #[inline(always)]
156 pub const fn variant(&self) -> Option<Ipol> {
157 match self.bits {
158 0 => Some(Ipol::Pwm23),
159 1 => Some(Ipol::Pwm45),
160 _ => None,
161 }
162 }
163 #[doc = "PWM23 is used to generate complementary PWM pair in the corresponding submodule."]
164 #[inline(always)]
165 pub fn is_pwm23(&self) -> bool {
166 *self == Ipol::Pwm23
167 }
168 #[doc = "PWM45 is used to generate complementary PWM pair in the corresponding submodule."]
169 #[inline(always)]
170 pub fn is_pwm45(&self) -> bool {
171 *self == Ipol::Pwm45
172 }
173}
174#[doc = "Field `IPOL` writer - Current Polarity"]
175pub type IpolW<'a, REG> = crate::FieldWriter<'a, REG, 4, Ipol>;
176impl<'a, REG> IpolW<'a, REG>
177where
178 REG: crate::Writable + crate::RegisterSpec,
179 REG::Ux: From<u8>,
180{
181 #[doc = "PWM23 is used to generate complementary PWM pair in the corresponding submodule."]
182 #[inline(always)]
183 pub fn pwm23(self) -> &'a mut crate::W<REG> {
184 self.variant(Ipol::Pwm23)
185 }
186 #[doc = "PWM45 is used to generate complementary PWM pair in the corresponding submodule."]
187 #[inline(always)]
188 pub fn pwm45(self) -> &'a mut crate::W<REG> {
189 self.variant(Ipol::Pwm45)
190 }
191}
192impl R {
193 #[doc = "Bits 0:3 - Load Okay"]
194 #[inline(always)]
195 pub fn ldok(&self) -> LdokR {
196 LdokR::new((self.bits & 0x0f) as u8)
197 }
198 #[doc = "Bits 4:7 - Clear Load Okay"]
199 #[inline(always)]
200 pub fn cldok(&self) -> CldokR {
201 CldokR::new(((self.bits >> 4) & 0x0f) as u8)
202 }
203 #[doc = "Bits 8:11 - Run"]
204 #[inline(always)]
205 pub fn run(&self) -> RunR {
206 RunR::new(((self.bits >> 8) & 0x0f) as u8)
207 }
208 #[doc = "Bits 12:15 - Current Polarity"]
209 #[inline(always)]
210 pub fn ipol(&self) -> IpolR {
211 IpolR::new(((self.bits >> 12) & 0x0f) as u8)
212 }
213}
214#[cfg(feature = "debug")]
215impl core::fmt::Debug for R {
216 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
217 f.debug_struct("MCTRL")
218 .field("ldok", &self.ldok())
219 .field("cldok", &self.cldok())
220 .field("run", &self.run())
221 .field("ipol", &self.ipol())
222 .finish()
223 }
224}
225impl W {
226 #[doc = "Bits 0:3 - Load Okay"]
227 #[inline(always)]
228 pub fn ldok(&mut self) -> LdokW<'_, MctrlSpec> {
229 LdokW::new(self, 0)
230 }
231 #[doc = "Bits 4:7 - Clear Load Okay"]
232 #[inline(always)]
233 pub fn cldok(&mut self) -> CldokW<'_, MctrlSpec> {
234 CldokW::new(self, 4)
235 }
236 #[doc = "Bits 8:11 - Run"]
237 #[inline(always)]
238 pub fn run(&mut self) -> RunW<'_, MctrlSpec> {
239 RunW::new(self, 8)
240 }
241 #[doc = "Bits 12:15 - Current Polarity"]
242 #[inline(always)]
243 pub fn ipol(&mut self) -> IpolW<'_, MctrlSpec> {
244 IpolW::new(self, 12)
245 }
246}
247#[doc = "Master Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`mctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
248pub struct MctrlSpec;
249impl crate::RegisterSpec for MctrlSpec {
250 type Ux = u16;
251}
252#[doc = "`read()` method returns [`mctrl::R`](R) reader structure"]
253impl crate::Readable for MctrlSpec {}
254#[doc = "`write(|w| ..)` method takes [`mctrl::W`](W) writer structure"]
255impl crate::Writable for MctrlSpec {
256 type Safety = crate::Unsafe;
257}
258#[doc = "`reset()` method sets MCTRL to value 0"]
259impl crate::Resettable for MctrlSpec {}