Skip to main content

atsamv71n21/pwm0/
pwm_lebr2.rs

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