stm32wb_pac/tim2/
cr1.rs

1#[doc = "Reader of register CR1"]
2pub type R = crate::R<u32, super::CR1>;
3#[doc = "Writer for register CR1"]
4pub type W = crate::W<u32, super::CR1>;
5#[doc = "Register CR1 `reset()`'s with value 0"]
6impl crate::ResetValue for super::CR1 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `UIFREMAP`"]
14pub type UIFREMAP_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `UIFREMAP`"]
16pub struct UIFREMAP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> UIFREMAP_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 << 11)) | (((value as u32) & 0x01) << 11);
34        self.w
35    }
36}
37#[doc = "Reader of field `CKD`"]
38pub type CKD_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `CKD`"]
40pub struct CKD_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> CKD_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 & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
48        self.w
49    }
50}
51#[doc = "Reader of field `ARPE`"]
52pub type ARPE_R = crate::R<bool, bool>;
53#[doc = "Write proxy for field `ARPE`"]
54pub struct ARPE_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> ARPE_W<'a> {
58    #[doc = r"Sets the field bit"]
59    #[inline(always)]
60    pub fn set_bit(self) -> &'a mut W {
61        self.bit(true)
62    }
63    #[doc = r"Clears the field bit"]
64    #[inline(always)]
65    pub fn clear_bit(self) -> &'a mut W {
66        self.bit(false)
67    }
68    #[doc = r"Writes raw bits to the field"]
69    #[inline(always)]
70    pub fn bit(self, value: bool) -> &'a mut W {
71        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
72        self.w
73    }
74}
75#[doc = "Reader of field `CMS`"]
76pub type CMS_R = crate::R<u8, u8>;
77#[doc = "Write proxy for field `CMS`"]
78pub struct CMS_W<'a> {
79    w: &'a mut W,
80}
81impl<'a> CMS_W<'a> {
82    #[doc = r"Writes raw bits to the field"]
83    #[inline(always)]
84    pub unsafe fn bits(self, value: u8) -> &'a mut W {
85        self.w.bits = (self.w.bits & !(0x03 << 5)) | (((value as u32) & 0x03) << 5);
86        self.w
87    }
88}
89#[doc = "Reader of field `DIR`"]
90pub type DIR_R = crate::R<bool, bool>;
91#[doc = "Write proxy for field `DIR`"]
92pub struct DIR_W<'a> {
93    w: &'a mut W,
94}
95impl<'a> DIR_W<'a> {
96    #[doc = r"Sets the field bit"]
97    #[inline(always)]
98    pub fn set_bit(self) -> &'a mut W {
99        self.bit(true)
100    }
101    #[doc = r"Clears the field bit"]
102    #[inline(always)]
103    pub fn clear_bit(self) -> &'a mut W {
104        self.bit(false)
105    }
106    #[doc = r"Writes raw bits to the field"]
107    #[inline(always)]
108    pub fn bit(self, value: bool) -> &'a mut W {
109        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
110        self.w
111    }
112}
113#[doc = "Reader of field `OPM`"]
114pub type OPM_R = crate::R<bool, bool>;
115#[doc = "Write proxy for field `OPM`"]
116pub struct OPM_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> OPM_W<'a> {
120    #[doc = r"Sets the field bit"]
121    #[inline(always)]
122    pub fn set_bit(self) -> &'a mut W {
123        self.bit(true)
124    }
125    #[doc = r"Clears the field bit"]
126    #[inline(always)]
127    pub fn clear_bit(self) -> &'a mut W {
128        self.bit(false)
129    }
130    #[doc = r"Writes raw bits to the field"]
131    #[inline(always)]
132    pub fn bit(self, value: bool) -> &'a mut W {
133        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
134        self.w
135    }
136}
137#[doc = "Reader of field `URS`"]
138pub type URS_R = crate::R<bool, bool>;
139#[doc = "Write proxy for field `URS`"]
140pub struct URS_W<'a> {
141    w: &'a mut W,
142}
143impl<'a> URS_W<'a> {
144    #[doc = r"Sets the field bit"]
145    #[inline(always)]
146    pub fn set_bit(self) -> &'a mut W {
147        self.bit(true)
148    }
149    #[doc = r"Clears the field bit"]
150    #[inline(always)]
151    pub fn clear_bit(self) -> &'a mut W {
152        self.bit(false)
153    }
154    #[doc = r"Writes raw bits to the field"]
155    #[inline(always)]
156    pub fn bit(self, value: bool) -> &'a mut W {
157        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
158        self.w
159    }
160}
161#[doc = "Reader of field `UDIS`"]
162pub type UDIS_R = crate::R<bool, bool>;
163#[doc = "Write proxy for field `UDIS`"]
164pub struct UDIS_W<'a> {
165    w: &'a mut W,
166}
167impl<'a> UDIS_W<'a> {
168    #[doc = r"Sets the field bit"]
169    #[inline(always)]
170    pub fn set_bit(self) -> &'a mut W {
171        self.bit(true)
172    }
173    #[doc = r"Clears the field bit"]
174    #[inline(always)]
175    pub fn clear_bit(self) -> &'a mut W {
176        self.bit(false)
177    }
178    #[doc = r"Writes raw bits to the field"]
179    #[inline(always)]
180    pub fn bit(self, value: bool) -> &'a mut W {
181        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
182        self.w
183    }
184}
185#[doc = "Reader of field `CEN`"]
186pub type CEN_R = crate::R<bool, bool>;
187#[doc = "Write proxy for field `CEN`"]
188pub struct CEN_W<'a> {
189    w: &'a mut W,
190}
191impl<'a> CEN_W<'a> {
192    #[doc = r"Sets the field bit"]
193    #[inline(always)]
194    pub fn set_bit(self) -> &'a mut W {
195        self.bit(true)
196    }
197    #[doc = r"Clears the field bit"]
198    #[inline(always)]
199    pub fn clear_bit(self) -> &'a mut W {
200        self.bit(false)
201    }
202    #[doc = r"Writes raw bits to the field"]
203    #[inline(always)]
204    pub fn bit(self, value: bool) -> &'a mut W {
205        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
206        self.w
207    }
208}
209impl R {
210    #[doc = "Bit 11 - UIF status bit remapping"]
211    #[inline(always)]
212    pub fn uifremap(&self) -> UIFREMAP_R {
213        UIFREMAP_R::new(((self.bits >> 11) & 0x01) != 0)
214    }
215    #[doc = "Bits 8:9 - Clock division"]
216    #[inline(always)]
217    pub fn ckd(&self) -> CKD_R {
218        CKD_R::new(((self.bits >> 8) & 0x03) as u8)
219    }
220    #[doc = "Bit 7 - Auto-reload preload enable"]
221    #[inline(always)]
222    pub fn arpe(&self) -> ARPE_R {
223        ARPE_R::new(((self.bits >> 7) & 0x01) != 0)
224    }
225    #[doc = "Bits 5:6 - Center-aligned mode selection"]
226    #[inline(always)]
227    pub fn cms(&self) -> CMS_R {
228        CMS_R::new(((self.bits >> 5) & 0x03) as u8)
229    }
230    #[doc = "Bit 4 - Direction"]
231    #[inline(always)]
232    pub fn dir(&self) -> DIR_R {
233        DIR_R::new(((self.bits >> 4) & 0x01) != 0)
234    }
235    #[doc = "Bit 3 - One-pulse mode"]
236    #[inline(always)]
237    pub fn opm(&self) -> OPM_R {
238        OPM_R::new(((self.bits >> 3) & 0x01) != 0)
239    }
240    #[doc = "Bit 2 - Update request source"]
241    #[inline(always)]
242    pub fn urs(&self) -> URS_R {
243        URS_R::new(((self.bits >> 2) & 0x01) != 0)
244    }
245    #[doc = "Bit 1 - Update disable"]
246    #[inline(always)]
247    pub fn udis(&self) -> UDIS_R {
248        UDIS_R::new(((self.bits >> 1) & 0x01) != 0)
249    }
250    #[doc = "Bit 0 - Counter enable"]
251    #[inline(always)]
252    pub fn cen(&self) -> CEN_R {
253        CEN_R::new((self.bits & 0x01) != 0)
254    }
255}
256impl W {
257    #[doc = "Bit 11 - UIF status bit remapping"]
258    #[inline(always)]
259    pub fn uifremap(&mut self) -> UIFREMAP_W {
260        UIFREMAP_W { w: self }
261    }
262    #[doc = "Bits 8:9 - Clock division"]
263    #[inline(always)]
264    pub fn ckd(&mut self) -> CKD_W {
265        CKD_W { w: self }
266    }
267    #[doc = "Bit 7 - Auto-reload preload enable"]
268    #[inline(always)]
269    pub fn arpe(&mut self) -> ARPE_W {
270        ARPE_W { w: self }
271    }
272    #[doc = "Bits 5:6 - Center-aligned mode selection"]
273    #[inline(always)]
274    pub fn cms(&mut self) -> CMS_W {
275        CMS_W { w: self }
276    }
277    #[doc = "Bit 4 - Direction"]
278    #[inline(always)]
279    pub fn dir(&mut self) -> DIR_W {
280        DIR_W { w: self }
281    }
282    #[doc = "Bit 3 - One-pulse mode"]
283    #[inline(always)]
284    pub fn opm(&mut self) -> OPM_W {
285        OPM_W { w: self }
286    }
287    #[doc = "Bit 2 - Update request source"]
288    #[inline(always)]
289    pub fn urs(&mut self) -> URS_W {
290        URS_W { w: self }
291    }
292    #[doc = "Bit 1 - Update disable"]
293    #[inline(always)]
294    pub fn udis(&mut self) -> UDIS_W {
295        UDIS_W { w: self }
296    }
297    #[doc = "Bit 0 - Counter enable"]
298    #[inline(always)]
299    pub fn cen(&mut self) -> CEN_W {
300        CEN_W { w: self }
301    }
302}