1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#[doc = "Register `pcr%s` reader"]
pub struct R(crate::R<PCR_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl From<crate::R<PCR_SPEC>> for R {
    #[inline(always)]
    fn from(reader: crate::R<PCR_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `pcr%s` writer"]
pub struct W(crate::W<PCR_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl From<crate::W<PCR_SPEC>> for W {
    #[inline(always)]
    fn from(writer: crate::W<PCR_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `pwm_prescal_k` reader - PWM pre-scale K, actual pre-scale is (K + 1)"]
pub type PWM_PRESCAL_K_R = crate::FieldReader<u8, u8>;
#[doc = "Field `pwm_prescal_k` writer - PWM pre-scale K, actual pre-scale is (K + 1)"]
pub type PWM_PRESCAL_K_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCR_SPEC, u8, u8, 8, O>;
#[doc = "Field `pwm_act_sta` reader - PWM Active State"]
pub type PWM_ACT_STA_R = crate::BitReader<PWM_ACT_STA_A>;
#[doc = "PWM Active State\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PWM_ACT_STA_A {
    #[doc = "0: low level"]
    LOW = 0,
    #[doc = "1: high level"]
    HIGH = 1,
}
impl From<PWM_ACT_STA_A> for bool {
    #[inline(always)]
    fn from(variant: PWM_ACT_STA_A) -> Self {
        variant as u8 != 0
    }
}
impl PWM_ACT_STA_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PWM_ACT_STA_A {
        match self.bits {
            false => PWM_ACT_STA_A::LOW,
            true => PWM_ACT_STA_A::HIGH,
        }
    }
    #[doc = "Checks if the value of the field is `LOW`"]
    #[inline(always)]
    pub fn is_low(&self) -> bool {
        *self == PWM_ACT_STA_A::LOW
    }
    #[doc = "Checks if the value of the field is `HIGH`"]
    #[inline(always)]
    pub fn is_high(&self) -> bool {
        *self == PWM_ACT_STA_A::HIGH
    }
}
#[doc = "Field `pwm_act_sta` writer - PWM Active State"]
pub type PWM_ACT_STA_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCR_SPEC, PWM_ACT_STA_A, O>;
impl<'a, const O: u8> PWM_ACT_STA_W<'a, O> {
    #[doc = "low level"]
    #[inline(always)]
    pub fn low(self) -> &'a mut W {
        self.variant(PWM_ACT_STA_A::LOW)
    }
    #[doc = "high level"]
    #[inline(always)]
    pub fn high(self) -> &'a mut W {
        self.variant(PWM_ACT_STA_A::HIGH)
    }
}
#[doc = "Field `pwm_mode` reader - PWM Output Mode Select"]
pub type PWM_MODE_R = crate::BitReader<PWM_MODE_A>;
#[doc = "PWM Output Mode Select\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PWM_MODE_A {
    #[doc = "0: Cycle mode"]
    CYCLE = 0,
    #[doc = "1: Pulse mode"]
    PULSE = 1,
}
impl From<PWM_MODE_A> for bool {
    #[inline(always)]
    fn from(variant: PWM_MODE_A) -> Self {
        variant as u8 != 0
    }
}
impl PWM_MODE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PWM_MODE_A {
        match self.bits {
            false => PWM_MODE_A::CYCLE,
            true => PWM_MODE_A::PULSE,
        }
    }
    #[doc = "Checks if the value of the field is `CYCLE`"]
    #[inline(always)]
    pub fn is_cycle(&self) -> bool {
        *self == PWM_MODE_A::CYCLE
    }
    #[doc = "Checks if the value of the field is `PULSE`"]
    #[inline(always)]
    pub fn is_pulse(&self) -> bool {
        *self == PWM_MODE_A::PULSE
    }
}
#[doc = "Field `pwm_mode` writer - PWM Output Mode Select"]
pub type PWM_MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCR_SPEC, PWM_MODE_A, O>;
impl<'a, const O: u8> PWM_MODE_W<'a, O> {
    #[doc = "Cycle mode"]
    #[inline(always)]
    pub fn cycle(self) -> &'a mut W {
        self.variant(PWM_MODE_A::CYCLE)
    }
    #[doc = "Pulse mode"]
    #[inline(always)]
    pub fn pulse(self) -> &'a mut W {
        self.variant(PWM_MODE_A::PULSE)
    }
}
#[doc = "Field `pwm_pul_start` reader - PWM Pulse Output Start"]
pub type PWM_PUL_START_R = crate::BitReader<PWM_PUL_START_A>;
#[doc = "PWM Pulse Output Start\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PWM_PUL_START_A {
    #[doc = "0: `0`"]
    NO_EFFECT = 0,
    #[doc = "1: Output pulse for PWM_CYCLE_NM + 1"]
    START = 1,
}
impl From<PWM_PUL_START_A> for bool {
    #[inline(always)]
    fn from(variant: PWM_PUL_START_A) -> Self {
        variant as u8 != 0
    }
}
impl PWM_PUL_START_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PWM_PUL_START_A {
        match self.bits {
            false => PWM_PUL_START_A::NO_EFFECT,
            true => PWM_PUL_START_A::START,
        }
    }
    #[doc = "Checks if the value of the field is `NO_EFFECT`"]
    #[inline(always)]
    pub fn is_no_effect(&self) -> bool {
        *self == PWM_PUL_START_A::NO_EFFECT
    }
    #[doc = "Checks if the value of the field is `START`"]
    #[inline(always)]
    pub fn is_start(&self) -> bool {
        *self == PWM_PUL_START_A::START
    }
}
#[doc = "Field `pwm_pul_start` writer - PWM Pulse Output Start"]
pub type PWM_PUL_START_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCR_SPEC, PWM_PUL_START_A, O>;
impl<'a, const O: u8> PWM_PUL_START_W<'a, O> {
    #[doc = "`0`"]
    #[inline(always)]
    pub fn no_effect(self) -> &'a mut W {
        self.variant(PWM_PUL_START_A::NO_EFFECT)
    }
    #[doc = "Output pulse for PWM_CYCLE_NM + 1"]
    #[inline(always)]
    pub fn start(self) -> &'a mut W {
        self.variant(PWM_PUL_START_A::START)
    }
}
#[doc = "Field `pwm_period_rdy` reader - PWM Period Register Ready"]
pub type PWM_PERIOD_RDY_R = crate::BitReader<PWM_PERIOD_RDY_A>;
#[doc = "PWM Period Register Ready\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PWM_PERIOD_RDY_A {
    #[doc = "0: PWM period register is ready to write"]
    READY = 0,
    #[doc = "1: PWM period register is busy"]
    BUSY = 1,
}
impl From<PWM_PERIOD_RDY_A> for bool {
    #[inline(always)]
    fn from(variant: PWM_PERIOD_RDY_A) -> Self {
        variant as u8 != 0
    }
}
impl PWM_PERIOD_RDY_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PWM_PERIOD_RDY_A {
        match self.bits {
            false => PWM_PERIOD_RDY_A::READY,
            true => PWM_PERIOD_RDY_A::BUSY,
        }
    }
    #[doc = "Checks if the value of the field is `READY`"]
    #[inline(always)]
    pub fn is_ready(&self) -> bool {
        *self == PWM_PERIOD_RDY_A::READY
    }
    #[doc = "Checks if the value of the field is `BUSY`"]
    #[inline(always)]
    pub fn is_busy(&self) -> bool {
        *self == PWM_PERIOD_RDY_A::BUSY
    }
}
#[doc = "Field `pwm_pul_num` reader - In pulse mode, the PWM outputs pulse for PWM_CYCLE_NUM + 1 times and then stops"]
pub type PWM_PUL_NUM_R = crate::FieldReader<u16, u16>;
#[doc = "Field `pwm_pul_num` writer - In pulse mode, the PWM outputs pulse for PWM_CYCLE_NUM + 1 times and then stops"]
pub type PWM_PUL_NUM_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCR_SPEC, u16, u16, 16, O>;
impl R {
    #[doc = "Bits 0:7 - PWM pre-scale K, actual pre-scale is (K + 1)"]
    #[inline(always)]
    pub fn pwm_prescal_k(&self) -> PWM_PRESCAL_K_R {
        PWM_PRESCAL_K_R::new((self.bits & 0xff) as u8)
    }
    #[doc = "Bit 8 - PWM Active State"]
    #[inline(always)]
    pub fn pwm_act_sta(&self) -> PWM_ACT_STA_R {
        PWM_ACT_STA_R::new(((self.bits >> 8) & 1) != 0)
    }
    #[doc = "Bit 9 - PWM Output Mode Select"]
    #[inline(always)]
    pub fn pwm_mode(&self) -> PWM_MODE_R {
        PWM_MODE_R::new(((self.bits >> 9) & 1) != 0)
    }
    #[doc = "Bit 10 - PWM Pulse Output Start"]
    #[inline(always)]
    pub fn pwm_pul_start(&self) -> PWM_PUL_START_R {
        PWM_PUL_START_R::new(((self.bits >> 10) & 1) != 0)
    }
    #[doc = "Bit 11 - PWM Period Register Ready"]
    #[inline(always)]
    pub fn pwm_period_rdy(&self) -> PWM_PERIOD_RDY_R {
        PWM_PERIOD_RDY_R::new(((self.bits >> 11) & 1) != 0)
    }
    #[doc = "Bits 16:31 - In pulse mode, the PWM outputs pulse for PWM_CYCLE_NUM + 1 times and then stops"]
    #[inline(always)]
    pub fn pwm_pul_num(&self) -> PWM_PUL_NUM_R {
        PWM_PUL_NUM_R::new(((self.bits >> 16) & 0xffff) as u16)
    }
}
impl W {
    #[doc = "Bits 0:7 - PWM pre-scale K, actual pre-scale is (K + 1)"]
    #[inline(always)]
    #[must_use]
    pub fn pwm_prescal_k(&mut self) -> PWM_PRESCAL_K_W<0> {
        PWM_PRESCAL_K_W::new(self)
    }
    #[doc = "Bit 8 - PWM Active State"]
    #[inline(always)]
    #[must_use]
    pub fn pwm_act_sta(&mut self) -> PWM_ACT_STA_W<8> {
        PWM_ACT_STA_W::new(self)
    }
    #[doc = "Bit 9 - PWM Output Mode Select"]
    #[inline(always)]
    #[must_use]
    pub fn pwm_mode(&mut self) -> PWM_MODE_W<9> {
        PWM_MODE_W::new(self)
    }
    #[doc = "Bit 10 - PWM Pulse Output Start"]
    #[inline(always)]
    #[must_use]
    pub fn pwm_pul_start(&mut self) -> PWM_PUL_START_W<10> {
        PWM_PUL_START_W::new(self)
    }
    #[doc = "Bits 16:31 - In pulse mode, the PWM outputs pulse for PWM_CYCLE_NUM + 1 times and then stops"]
    #[inline(always)]
    #[must_use]
    pub fn pwm_pul_num(&mut self) -> PWM_PUL_NUM_W<16> {
        PWM_PUL_NUM_W::new(self)
    }
    #[doc = "Writes raw bits to the register."]
    #[inline(always)]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "PWM 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 [pcr](index.html) module"]
pub struct PCR_SPEC;
impl crate::RegisterSpec for PCR_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [pcr::R](R) reader structure"]
impl crate::Readable for PCR_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [pcr::W](W) writer structure"]
impl crate::Writable for PCR_SPEC {
    type Writer = W;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets pcr%s to value 0"]
impl crate::Resettable for PCR_SPEC {
    const RESET_VALUE: Self::Ux = 0;
}