stm32l4x2_pac/tim15/
cnt.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::CNT {
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 CNTR {
47    bits: u16,
48}
49impl CNTR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u16 {
53        self.bits
54    }
55}
56#[doc = r" Value of the field"]
57pub struct UIFCPYR {
58    bits: bool,
59}
60impl UIFCPYR {
61    #[doc = r" Value of the field as raw bits"]
62    #[inline]
63    pub fn bit(&self) -> bool {
64        self.bits
65    }
66    #[doc = r" Returns `true` if the bit is clear (0)"]
67    #[inline]
68    pub fn bit_is_clear(&self) -> bool {
69        !self.bit()
70    }
71    #[doc = r" Returns `true` if the bit is set (1)"]
72    #[inline]
73    pub fn bit_is_set(&self) -> bool {
74        self.bit()
75    }
76}
77#[doc = r" Proxy"]
78pub struct _CNTW<'a> {
79    w: &'a mut W,
80}
81impl<'a> _CNTW<'a> {
82    #[doc = r" Writes raw bits to the field"]
83    #[inline]
84    pub unsafe fn bits(self, value: u16) -> &'a mut W {
85        const MASK: u16 = 65535;
86        const OFFSET: u8 = 0;
87        self.w.bits &= !((MASK as u32) << OFFSET);
88        self.w.bits |= ((value & MASK) as u32) << OFFSET;
89        self.w
90    }
91}
92impl R {
93    #[doc = r" Value of the register as raw bits"]
94    #[inline]
95    pub fn bits(&self) -> u32 {
96        self.bits
97    }
98    #[doc = "Bits 0:15 - counter value"]
99    #[inline]
100    pub fn cnt(&self) -> CNTR {
101        let bits = {
102            const MASK: u16 = 65535;
103            const OFFSET: u8 = 0;
104            ((self.bits >> OFFSET) & MASK as u32) as u16
105        };
106        CNTR { bits }
107    }
108    #[doc = "Bit 31 - UIF Copy"]
109    #[inline]
110    pub fn uifcpy(&self) -> UIFCPYR {
111        let bits = {
112            const MASK: bool = true;
113            const OFFSET: u8 = 31;
114            ((self.bits >> OFFSET) & MASK as u32) != 0
115        };
116        UIFCPYR { bits }
117    }
118}
119impl W {
120    #[doc = r" Reset value of the register"]
121    #[inline]
122    pub fn reset_value() -> W {
123        W { bits: 0 }
124    }
125    #[doc = r" Writes raw bits to the register"]
126    #[inline]
127    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
128        self.bits = bits;
129        self
130    }
131    #[doc = "Bits 0:15 - counter value"]
132    #[inline]
133    pub fn cnt(&mut self) -> _CNTW {
134        _CNTW { w: self }
135    }
136}