atsams70n21/pwm0/pwm_cmp/
pwm_cmpm.rs

1#[doc = "Register `PWM_CMPM` reader"]
2pub struct R(crate::R<PWM_CMPM_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PWM_CMPM_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PWM_CMPM_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PWM_CMPM_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PWM_CMPM` writer"]
17pub struct W(crate::W<PWM_CMPM_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PWM_CMPM_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<PWM_CMPM_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PWM_CMPM_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CEN` reader - Comparison x Enable"]
38pub struct CEN_R(crate::FieldReader<bool, bool>);
39impl CEN_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: bool) -> Self {
42        CEN_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for CEN_R {
46    type Target = crate::FieldReader<bool, bool>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `CEN` writer - Comparison x Enable"]
53pub struct CEN_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> CEN_W<'a> {
57    #[doc = r"Sets the field bit"]
58    #[inline(always)]
59    pub fn set_bit(self) -> &'a mut W {
60        self.bit(true)
61    }
62    #[doc = r"Clears the field bit"]
63    #[inline(always)]
64    pub fn clear_bit(self) -> &'a mut W {
65        self.bit(false)
66    }
67    #[doc = r"Writes raw bits to the field"]
68    #[inline(always)]
69    pub fn bit(self, value: bool) -> &'a mut W {
70        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
71        self.w
72    }
73}
74#[doc = "Field `CTR` reader - Comparison x Trigger"]
75pub struct CTR_R(crate::FieldReader<u8, u8>);
76impl CTR_R {
77    #[inline(always)]
78    pub(crate) fn new(bits: u8) -> Self {
79        CTR_R(crate::FieldReader::new(bits))
80    }
81}
82impl core::ops::Deref for CTR_R {
83    type Target = crate::FieldReader<u8, u8>;
84    #[inline(always)]
85    fn deref(&self) -> &Self::Target {
86        &self.0
87    }
88}
89#[doc = "Field `CTR` writer - Comparison x Trigger"]
90pub struct CTR_W<'a> {
91    w: &'a mut W,
92}
93impl<'a> CTR_W<'a> {
94    #[doc = r"Writes raw bits to the field"]
95    #[inline(always)]
96    pub unsafe fn bits(self, value: u8) -> &'a mut W {
97        self.w.bits = (self.w.bits & !(0x0f << 4)) | ((value as u32 & 0x0f) << 4);
98        self.w
99    }
100}
101#[doc = "Field `CPR` reader - Comparison x Period"]
102pub struct CPR_R(crate::FieldReader<u8, u8>);
103impl CPR_R {
104    #[inline(always)]
105    pub(crate) fn new(bits: u8) -> Self {
106        CPR_R(crate::FieldReader::new(bits))
107    }
108}
109impl core::ops::Deref for CPR_R {
110    type Target = crate::FieldReader<u8, u8>;
111    #[inline(always)]
112    fn deref(&self) -> &Self::Target {
113        &self.0
114    }
115}
116#[doc = "Field `CPR` writer - Comparison x Period"]
117pub struct CPR_W<'a> {
118    w: &'a mut W,
119}
120impl<'a> CPR_W<'a> {
121    #[doc = r"Writes raw bits to the field"]
122    #[inline(always)]
123    pub unsafe fn bits(self, value: u8) -> &'a mut W {
124        self.w.bits = (self.w.bits & !(0x0f << 8)) | ((value as u32 & 0x0f) << 8);
125        self.w
126    }
127}
128#[doc = "Field `CPRCNT` reader - Comparison x Period Counter"]
129pub struct CPRCNT_R(crate::FieldReader<u8, u8>);
130impl CPRCNT_R {
131    #[inline(always)]
132    pub(crate) fn new(bits: u8) -> Self {
133        CPRCNT_R(crate::FieldReader::new(bits))
134    }
135}
136impl core::ops::Deref for CPRCNT_R {
137    type Target = crate::FieldReader<u8, u8>;
138    #[inline(always)]
139    fn deref(&self) -> &Self::Target {
140        &self.0
141    }
142}
143#[doc = "Field `CPRCNT` writer - Comparison x Period Counter"]
144pub struct CPRCNT_W<'a> {
145    w: &'a mut W,
146}
147impl<'a> CPRCNT_W<'a> {
148    #[doc = r"Writes raw bits to the field"]
149    #[inline(always)]
150    pub unsafe fn bits(self, value: u8) -> &'a mut W {
151        self.w.bits = (self.w.bits & !(0x0f << 12)) | ((value as u32 & 0x0f) << 12);
152        self.w
153    }
154}
155#[doc = "Field `CUPR` reader - Comparison x Update Period"]
156pub struct CUPR_R(crate::FieldReader<u8, u8>);
157impl CUPR_R {
158    #[inline(always)]
159    pub(crate) fn new(bits: u8) -> Self {
160        CUPR_R(crate::FieldReader::new(bits))
161    }
162}
163impl core::ops::Deref for CUPR_R {
164    type Target = crate::FieldReader<u8, u8>;
165    #[inline(always)]
166    fn deref(&self) -> &Self::Target {
167        &self.0
168    }
169}
170#[doc = "Field `CUPR` writer - Comparison x Update Period"]
171pub struct CUPR_W<'a> {
172    w: &'a mut W,
173}
174impl<'a> CUPR_W<'a> {
175    #[doc = r"Writes raw bits to the field"]
176    #[inline(always)]
177    pub unsafe fn bits(self, value: u8) -> &'a mut W {
178        self.w.bits = (self.w.bits & !(0x0f << 16)) | ((value as u32 & 0x0f) << 16);
179        self.w
180    }
181}
182#[doc = "Field `CUPRCNT` reader - Comparison x Update Period Counter"]
183pub struct CUPRCNT_R(crate::FieldReader<u8, u8>);
184impl CUPRCNT_R {
185    #[inline(always)]
186    pub(crate) fn new(bits: u8) -> Self {
187        CUPRCNT_R(crate::FieldReader::new(bits))
188    }
189}
190impl core::ops::Deref for CUPRCNT_R {
191    type Target = crate::FieldReader<u8, u8>;
192    #[inline(always)]
193    fn deref(&self) -> &Self::Target {
194        &self.0
195    }
196}
197#[doc = "Field `CUPRCNT` writer - Comparison x Update Period Counter"]
198pub struct CUPRCNT_W<'a> {
199    w: &'a mut W,
200}
201impl<'a> CUPRCNT_W<'a> {
202    #[doc = r"Writes raw bits to the field"]
203    #[inline(always)]
204    pub unsafe fn bits(self, value: u8) -> &'a mut W {
205        self.w.bits = (self.w.bits & !(0x0f << 20)) | ((value as u32 & 0x0f) << 20);
206        self.w
207    }
208}
209impl R {
210    #[doc = "Bit 0 - Comparison x Enable"]
211    #[inline(always)]
212    pub fn cen(&self) -> CEN_R {
213        CEN_R::new((self.bits & 0x01) != 0)
214    }
215    #[doc = "Bits 4:7 - Comparison x Trigger"]
216    #[inline(always)]
217    pub fn ctr(&self) -> CTR_R {
218        CTR_R::new(((self.bits >> 4) & 0x0f) as u8)
219    }
220    #[doc = "Bits 8:11 - Comparison x Period"]
221    #[inline(always)]
222    pub fn cpr(&self) -> CPR_R {
223        CPR_R::new(((self.bits >> 8) & 0x0f) as u8)
224    }
225    #[doc = "Bits 12:15 - Comparison x Period Counter"]
226    #[inline(always)]
227    pub fn cprcnt(&self) -> CPRCNT_R {
228        CPRCNT_R::new(((self.bits >> 12) & 0x0f) as u8)
229    }
230    #[doc = "Bits 16:19 - Comparison x Update Period"]
231    #[inline(always)]
232    pub fn cupr(&self) -> CUPR_R {
233        CUPR_R::new(((self.bits >> 16) & 0x0f) as u8)
234    }
235    #[doc = "Bits 20:23 - Comparison x Update Period Counter"]
236    #[inline(always)]
237    pub fn cuprcnt(&self) -> CUPRCNT_R {
238        CUPRCNT_R::new(((self.bits >> 20) & 0x0f) as u8)
239    }
240}
241impl W {
242    #[doc = "Bit 0 - Comparison x Enable"]
243    #[inline(always)]
244    pub fn cen(&mut self) -> CEN_W {
245        CEN_W { w: self }
246    }
247    #[doc = "Bits 4:7 - Comparison x Trigger"]
248    #[inline(always)]
249    pub fn ctr(&mut self) -> CTR_W {
250        CTR_W { w: self }
251    }
252    #[doc = "Bits 8:11 - Comparison x Period"]
253    #[inline(always)]
254    pub fn cpr(&mut self) -> CPR_W {
255        CPR_W { w: self }
256    }
257    #[doc = "Bits 12:15 - Comparison x Period Counter"]
258    #[inline(always)]
259    pub fn cprcnt(&mut self) -> CPRCNT_W {
260        CPRCNT_W { w: self }
261    }
262    #[doc = "Bits 16:19 - Comparison x Update Period"]
263    #[inline(always)]
264    pub fn cupr(&mut self) -> CUPR_W {
265        CUPR_W { w: self }
266    }
267    #[doc = "Bits 20:23 - Comparison x Update Period Counter"]
268    #[inline(always)]
269    pub fn cuprcnt(&mut self) -> CUPRCNT_W {
270        CUPRCNT_W { w: self }
271    }
272    #[doc = "Writes raw bits to the register."]
273    #[inline(always)]
274    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
275        self.0.bits(bits);
276        self
277    }
278}
279#[doc = "PWM Comparison 0 Mode 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 [pwm_cmpm](index.html) module"]
280pub struct PWM_CMPM_SPEC;
281impl crate::RegisterSpec for PWM_CMPM_SPEC {
282    type Ux = u32;
283}
284#[doc = "`read()` method returns [pwm_cmpm::R](R) reader structure"]
285impl crate::Readable for PWM_CMPM_SPEC {
286    type Reader = R;
287}
288#[doc = "`write(|w| ..)` method takes [pwm_cmpm::W](W) writer structure"]
289impl crate::Writable for PWM_CMPM_SPEC {
290    type Writer = W;
291}
292#[doc = "`reset()` method sets PWM_CMPM to value 0"]
293impl crate::Resettable for PWM_CMPM_SPEC {
294    #[inline(always)]
295    fn reset_value() -> Self::Ux {
296        0
297    }
298}