stm32l4x2_pac/tim16/
sr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::SR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct CC1OFR {
47    bits: bool,
48}
49impl CC1OFR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bit(&self) -> bool {
53        self.bits
54    }
55    #[doc = r" Returns `true` if the bit is clear (0)"]
56    #[inline]
57    pub fn bit_is_clear(&self) -> bool {
58        !self.bit()
59    }
60    #[doc = r" Returns `true` if the bit is set (1)"]
61    #[inline]
62    pub fn bit_is_set(&self) -> bool {
63        self.bit()
64    }
65}
66#[doc = r" Value of the field"]
67pub struct BIFR {
68    bits: bool,
69}
70impl BIFR {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bit(&self) -> bool {
74        self.bits
75    }
76    #[doc = r" Returns `true` if the bit is clear (0)"]
77    #[inline]
78    pub fn bit_is_clear(&self) -> bool {
79        !self.bit()
80    }
81    #[doc = r" Returns `true` if the bit is set (1)"]
82    #[inline]
83    pub fn bit_is_set(&self) -> bool {
84        self.bit()
85    }
86}
87#[doc = r" Value of the field"]
88pub struct TIFR {
89    bits: bool,
90}
91impl TIFR {
92    #[doc = r" Value of the field as raw bits"]
93    #[inline]
94    pub fn bit(&self) -> bool {
95        self.bits
96    }
97    #[doc = r" Returns `true` if the bit is clear (0)"]
98    #[inline]
99    pub fn bit_is_clear(&self) -> bool {
100        !self.bit()
101    }
102    #[doc = r" Returns `true` if the bit is set (1)"]
103    #[inline]
104    pub fn bit_is_set(&self) -> bool {
105        self.bit()
106    }
107}
108#[doc = r" Value of the field"]
109pub struct COMIFR {
110    bits: bool,
111}
112impl COMIFR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bit(&self) -> bool {
116        self.bits
117    }
118    #[doc = r" Returns `true` if the bit is clear (0)"]
119    #[inline]
120    pub fn bit_is_clear(&self) -> bool {
121        !self.bit()
122    }
123    #[doc = r" Returns `true` if the bit is set (1)"]
124    #[inline]
125    pub fn bit_is_set(&self) -> bool {
126        self.bit()
127    }
128}
129#[doc = r" Value of the field"]
130pub struct CC1IFR {
131    bits: bool,
132}
133impl CC1IFR {
134    #[doc = r" Value of the field as raw bits"]
135    #[inline]
136    pub fn bit(&self) -> bool {
137        self.bits
138    }
139    #[doc = r" Returns `true` if the bit is clear (0)"]
140    #[inline]
141    pub fn bit_is_clear(&self) -> bool {
142        !self.bit()
143    }
144    #[doc = r" Returns `true` if the bit is set (1)"]
145    #[inline]
146    pub fn bit_is_set(&self) -> bool {
147        self.bit()
148    }
149}
150#[doc = "Possible values of the field `UIF`"]
151#[derive(Clone, Copy, Debug, PartialEq)]
152pub enum UIFR {
153    #[doc = "No update occurred"]
154    CLEAR,
155    #[doc = "Update interrupt pending."]
156    UPDATEPENDING,
157}
158impl UIFR {
159    #[doc = r" Returns `true` if the bit is clear (0)"]
160    #[inline]
161    pub fn bit_is_clear(&self) -> bool {
162        !self.bit()
163    }
164    #[doc = r" Returns `true` if the bit is set (1)"]
165    #[inline]
166    pub fn bit_is_set(&self) -> bool {
167        self.bit()
168    }
169    #[doc = r" Value of the field as raw bits"]
170    #[inline]
171    pub fn bit(&self) -> bool {
172        match *self {
173            UIFR::CLEAR => false,
174            UIFR::UPDATEPENDING => true,
175        }
176    }
177    #[allow(missing_docs)]
178    #[doc(hidden)]
179    #[inline]
180    pub fn _from(value: bool) -> UIFR {
181        match value {
182            false => UIFR::CLEAR,
183            true => UIFR::UPDATEPENDING,
184        }
185    }
186    #[doc = "Checks if the value of the field is `CLEAR`"]
187    #[inline]
188    pub fn is_clear(&self) -> bool {
189        *self == UIFR::CLEAR
190    }
191    #[doc = "Checks if the value of the field is `UPDATEPENDING`"]
192    #[inline]
193    pub fn is_update_pending(&self) -> bool {
194        *self == UIFR::UPDATEPENDING
195    }
196}
197#[doc = r" Proxy"]
198pub struct _CC1OFW<'a> {
199    w: &'a mut W,
200}
201impl<'a> _CC1OFW<'a> {
202    #[doc = r" Sets the field bit"]
203    pub fn set_bit(self) -> &'a mut W {
204        self.bit(true)
205    }
206    #[doc = r" Clears the field bit"]
207    pub fn clear_bit(self) -> &'a mut W {
208        self.bit(false)
209    }
210    #[doc = r" Writes raw bits to the field"]
211    #[inline]
212    pub fn bit(self, value: bool) -> &'a mut W {
213        const MASK: bool = true;
214        const OFFSET: u8 = 9;
215        self.w.bits &= !((MASK as u32) << OFFSET);
216        self.w.bits |= ((value & MASK) as u32) << OFFSET;
217        self.w
218    }
219}
220#[doc = r" Proxy"]
221pub struct _BIFW<'a> {
222    w: &'a mut W,
223}
224impl<'a> _BIFW<'a> {
225    #[doc = r" Sets the field bit"]
226    pub fn set_bit(self) -> &'a mut W {
227        self.bit(true)
228    }
229    #[doc = r" Clears the field bit"]
230    pub fn clear_bit(self) -> &'a mut W {
231        self.bit(false)
232    }
233    #[doc = r" Writes raw bits to the field"]
234    #[inline]
235    pub fn bit(self, value: bool) -> &'a mut W {
236        const MASK: bool = true;
237        const OFFSET: u8 = 7;
238        self.w.bits &= !((MASK as u32) << OFFSET);
239        self.w.bits |= ((value & MASK) as u32) << OFFSET;
240        self.w
241    }
242}
243#[doc = r" Proxy"]
244pub struct _TIFW<'a> {
245    w: &'a mut W,
246}
247impl<'a> _TIFW<'a> {
248    #[doc = r" Sets the field bit"]
249    pub fn set_bit(self) -> &'a mut W {
250        self.bit(true)
251    }
252    #[doc = r" Clears the field bit"]
253    pub fn clear_bit(self) -> &'a mut W {
254        self.bit(false)
255    }
256    #[doc = r" Writes raw bits to the field"]
257    #[inline]
258    pub fn bit(self, value: bool) -> &'a mut W {
259        const MASK: bool = true;
260        const OFFSET: u8 = 6;
261        self.w.bits &= !((MASK as u32) << OFFSET);
262        self.w.bits |= ((value & MASK) as u32) << OFFSET;
263        self.w
264    }
265}
266#[doc = r" Proxy"]
267pub struct _COMIFW<'a> {
268    w: &'a mut W,
269}
270impl<'a> _COMIFW<'a> {
271    #[doc = r" Sets the field bit"]
272    pub fn set_bit(self) -> &'a mut W {
273        self.bit(true)
274    }
275    #[doc = r" Clears the field bit"]
276    pub fn clear_bit(self) -> &'a mut W {
277        self.bit(false)
278    }
279    #[doc = r" Writes raw bits to the field"]
280    #[inline]
281    pub fn bit(self, value: bool) -> &'a mut W {
282        const MASK: bool = true;
283        const OFFSET: u8 = 5;
284        self.w.bits &= !((MASK as u32) << OFFSET);
285        self.w.bits |= ((value & MASK) as u32) << OFFSET;
286        self.w
287    }
288}
289#[doc = r" Proxy"]
290pub struct _CC1IFW<'a> {
291    w: &'a mut W,
292}
293impl<'a> _CC1IFW<'a> {
294    #[doc = r" Sets the field bit"]
295    pub fn set_bit(self) -> &'a mut W {
296        self.bit(true)
297    }
298    #[doc = r" Clears the field bit"]
299    pub fn clear_bit(self) -> &'a mut W {
300        self.bit(false)
301    }
302    #[doc = r" Writes raw bits to the field"]
303    #[inline]
304    pub fn bit(self, value: bool) -> &'a mut W {
305        const MASK: bool = true;
306        const OFFSET: u8 = 1;
307        self.w.bits &= !((MASK as u32) << OFFSET);
308        self.w.bits |= ((value & MASK) as u32) << OFFSET;
309        self.w
310    }
311}
312#[doc = "Values that can be written to the field `UIF`"]
313pub enum UIFW {
314    #[doc = "No update occurred"]
315    CLEAR,
316    #[doc = "Update interrupt pending."]
317    UPDATEPENDING,
318}
319impl UIFW {
320    #[allow(missing_docs)]
321    #[doc(hidden)]
322    #[inline]
323    pub fn _bits(&self) -> bool {
324        match *self {
325            UIFW::CLEAR => false,
326            UIFW::UPDATEPENDING => true,
327        }
328    }
329}
330#[doc = r" Proxy"]
331pub struct _UIFW<'a> {
332    w: &'a mut W,
333}
334impl<'a> _UIFW<'a> {
335    #[doc = r" Writes `variant` to the field"]
336    #[inline]
337    pub fn variant(self, variant: UIFW) -> &'a mut W {
338        {
339            self.bit(variant._bits())
340        }
341    }
342    #[doc = "No update occurred"]
343    #[inline]
344    pub fn clear(self) -> &'a mut W {
345        self.variant(UIFW::CLEAR)
346    }
347    #[doc = "Update interrupt pending."]
348    #[inline]
349    pub fn update_pending(self) -> &'a mut W {
350        self.variant(UIFW::UPDATEPENDING)
351    }
352    #[doc = r" Sets the field bit"]
353    pub fn set_bit(self) -> &'a mut W {
354        self.bit(true)
355    }
356    #[doc = r" Clears the field bit"]
357    pub fn clear_bit(self) -> &'a mut W {
358        self.bit(false)
359    }
360    #[doc = r" Writes raw bits to the field"]
361    #[inline]
362    pub fn bit(self, value: bool) -> &'a mut W {
363        const MASK: bool = true;
364        const OFFSET: u8 = 0;
365        self.w.bits &= !((MASK as u32) << OFFSET);
366        self.w.bits |= ((value & MASK) as u32) << OFFSET;
367        self.w
368    }
369}
370impl R {
371    #[doc = r" Value of the register as raw bits"]
372    #[inline]
373    pub fn bits(&self) -> u32 {
374        self.bits
375    }
376    #[doc = "Bit 9 - Capture/Compare 1 overcapture flag"]
377    #[inline]
378    pub fn cc1of(&self) -> CC1OFR {
379        let bits = {
380            const MASK: bool = true;
381            const OFFSET: u8 = 9;
382            ((self.bits >> OFFSET) & MASK as u32) != 0
383        };
384        CC1OFR { bits }
385    }
386    #[doc = "Bit 7 - Break interrupt flag"]
387    #[inline]
388    pub fn bif(&self) -> BIFR {
389        let bits = {
390            const MASK: bool = true;
391            const OFFSET: u8 = 7;
392            ((self.bits >> OFFSET) & MASK as u32) != 0
393        };
394        BIFR { bits }
395    }
396    #[doc = "Bit 6 - Trigger interrupt flag"]
397    #[inline]
398    pub fn tif(&self) -> TIFR {
399        let bits = {
400            const MASK: bool = true;
401            const OFFSET: u8 = 6;
402            ((self.bits >> OFFSET) & MASK as u32) != 0
403        };
404        TIFR { bits }
405    }
406    #[doc = "Bit 5 - COM interrupt flag"]
407    #[inline]
408    pub fn comif(&self) -> COMIFR {
409        let bits = {
410            const MASK: bool = true;
411            const OFFSET: u8 = 5;
412            ((self.bits >> OFFSET) & MASK as u32) != 0
413        };
414        COMIFR { bits }
415    }
416    #[doc = "Bit 1 - Capture/compare 1 interrupt flag"]
417    #[inline]
418    pub fn cc1if(&self) -> CC1IFR {
419        let bits = {
420            const MASK: bool = true;
421            const OFFSET: u8 = 1;
422            ((self.bits >> OFFSET) & MASK as u32) != 0
423        };
424        CC1IFR { bits }
425    }
426    #[doc = "Bit 0 - Update interrupt flag"]
427    #[inline]
428    pub fn uif(&self) -> UIFR {
429        UIFR::_from({
430            const MASK: bool = true;
431            const OFFSET: u8 = 0;
432            ((self.bits >> OFFSET) & MASK as u32) != 0
433        })
434    }
435}
436impl W {
437    #[doc = r" Reset value of the register"]
438    #[inline]
439    pub fn reset_value() -> W {
440        W { bits: 0 }
441    }
442    #[doc = r" Writes raw bits to the register"]
443    #[inline]
444    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
445        self.bits = bits;
446        self
447    }
448    #[doc = "Bit 9 - Capture/Compare 1 overcapture flag"]
449    #[inline]
450    pub fn cc1of(&mut self) -> _CC1OFW {
451        _CC1OFW { w: self }
452    }
453    #[doc = "Bit 7 - Break interrupt flag"]
454    #[inline]
455    pub fn bif(&mut self) -> _BIFW {
456        _BIFW { w: self }
457    }
458    #[doc = "Bit 6 - Trigger interrupt flag"]
459    #[inline]
460    pub fn tif(&mut self) -> _TIFW {
461        _TIFW { w: self }
462    }
463    #[doc = "Bit 5 - COM interrupt flag"]
464    #[inline]
465    pub fn comif(&mut self) -> _COMIFW {
466        _COMIFW { w: self }
467    }
468    #[doc = "Bit 1 - Capture/compare 1 interrupt flag"]
469    #[inline]
470    pub fn cc1if(&mut self) -> _CC1IFW {
471        _CC1IFW { w: self }
472    }
473    #[doc = "Bit 0 - Update interrupt flag"]
474    #[inline]
475    pub fn uif(&mut self) -> _UIFW {
476        _UIFW { w: self }
477    }
478}