Skip to main content

alt_sam3x8e/pwm/cmpm7/
mod.rs

1#[doc = "Reader of register CMPM7"]
2pub type R = crate::R<u32, super::CMPM7>;
3#[doc = "Writer for register CMPM7"]
4pub type W = crate::W<u32, super::CMPM7>;
5#[doc = "Register CMPM7 `reset()`'s with value 0"]
6impl crate::ResetValue for super::CMPM7 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `CEN`"]
14pub type CEN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `CEN`"]
16pub struct CEN_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> CEN_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `CTR`"]
38pub type CTR_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `CTR`"]
40pub struct CTR_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> CTR_W<'a> {
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub unsafe fn bits(self, value: u8) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x0f << 4)) | (((value as u32) & 0x0f) << 4);
48        self.w
49    }
50}
51#[doc = "Reader of field `CPR`"]
52pub type CPR_R = crate::R<u8, u8>;
53#[doc = "Write proxy for field `CPR`"]
54pub struct CPR_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> CPR_W<'a> {
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub unsafe fn bits(self, value: u8) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
62        self.w
63    }
64}
65#[doc = "Reader of field `CPRCNT`"]
66pub type CPRCNT_R = crate::R<u8, u8>;
67#[doc = "Write proxy for field `CPRCNT`"]
68pub struct CPRCNT_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> CPRCNT_W<'a> {
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u8) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x0f << 12)) | (((value as u32) & 0x0f) << 12);
76        self.w
77    }
78}
79#[doc = "Reader of field `CUPR`"]
80pub type CUPR_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `CUPR`"]
82pub struct CUPR_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> CUPR_W<'a> {
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub unsafe fn bits(self, value: u8) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
90        self.w
91    }
92}
93#[doc = "Reader of field `CUPRCNT`"]
94pub type CUPRCNT_R = crate::R<u8, u8>;
95#[doc = "Write proxy for field `CUPRCNT`"]
96pub struct CUPRCNT_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> CUPRCNT_W<'a> {
100    #[doc = r"Writes raw bits to the field"]
101    #[inline(always)]
102    pub unsafe fn bits(self, value: u8) -> &'a mut W {
103        self.w.bits = (self.w.bits & !(0x0f << 20)) | (((value as u32) & 0x0f) << 20);
104        self.w
105    }
106}
107impl R {
108    #[doc = "Bit 0 - Comparison x Enable"]
109    #[inline(always)]
110    pub fn cen(&self) -> CEN_R {
111        CEN_R::new((self.bits & 0x01) != 0)
112    }
113    #[doc = "Bits 4:7 - Comparison x Trigger"]
114    #[inline(always)]
115    pub fn ctr(&self) -> CTR_R {
116        CTR_R::new(((self.bits >> 4) & 0x0f) as u8)
117    }
118    #[doc = "Bits 8:11 - Comparison x Period"]
119    #[inline(always)]
120    pub fn cpr(&self) -> CPR_R {
121        CPR_R::new(((self.bits >> 8) & 0x0f) as u8)
122    }
123    #[doc = "Bits 12:15 - Comparison x Period Counter"]
124    #[inline(always)]
125    pub fn cprcnt(&self) -> CPRCNT_R {
126        CPRCNT_R::new(((self.bits >> 12) & 0x0f) as u8)
127    }
128    #[doc = "Bits 16:19 - Comparison x Update Period"]
129    #[inline(always)]
130    pub fn cupr(&self) -> CUPR_R {
131        CUPR_R::new(((self.bits >> 16) & 0x0f) as u8)
132    }
133    #[doc = "Bits 20:23 - Comparison x Update Period Counter"]
134    #[inline(always)]
135    pub fn cuprcnt(&self) -> CUPRCNT_R {
136        CUPRCNT_R::new(((self.bits >> 20) & 0x0f) as u8)
137    }
138}
139impl W {
140    #[doc = "Bit 0 - Comparison x Enable"]
141    #[inline(always)]
142    pub fn cen(&mut self) -> CEN_W {
143        CEN_W { w: self }
144    }
145    #[doc = "Bits 4:7 - Comparison x Trigger"]
146    #[inline(always)]
147    pub fn ctr(&mut self) -> CTR_W {
148        CTR_W { w: self }
149    }
150    #[doc = "Bits 8:11 - Comparison x Period"]
151    #[inline(always)]
152    pub fn cpr(&mut self) -> CPR_W {
153        CPR_W { w: self }
154    }
155    #[doc = "Bits 12:15 - Comparison x Period Counter"]
156    #[inline(always)]
157    pub fn cprcnt(&mut self) -> CPRCNT_W {
158        CPRCNT_W { w: self }
159    }
160    #[doc = "Bits 16:19 - Comparison x Update Period"]
161    #[inline(always)]
162    pub fn cupr(&mut self) -> CUPR_W {
163        CUPR_W { w: self }
164    }
165    #[doc = "Bits 20:23 - Comparison x Update Period Counter"]
166    #[inline(always)]
167    pub fn cuprcnt(&mut self) -> CUPRCNT_W {
168        CUPRCNT_W { w: self }
169    }
170}