stm32wb_pac/tim16/
bdtr.rs

1#[doc = "Reader of register BDTR"]
2pub type R = crate::R<u32, super::BDTR>;
3#[doc = "Writer for register BDTR"]
4pub type W = crate::W<u32, super::BDTR>;
5#[doc = "Register BDTR `reset()`'s with value 0"]
6impl crate::ResetValue for super::BDTR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `DTG`"]
14pub type DTG_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `DTG`"]
16pub struct DTG_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> DTG_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff);
24        self.w
25    }
26}
27#[doc = "Reader of field `LOCK`"]
28pub type LOCK_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `LOCK`"]
30pub struct LOCK_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> LOCK_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
38        self.w
39    }
40}
41#[doc = "Reader of field `OSSI`"]
42pub type OSSI_R = crate::R<bool, bool>;
43#[doc = "Write proxy for field `OSSI`"]
44pub struct OSSI_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> OSSI_W<'a> {
48    #[doc = r"Sets the field bit"]
49    #[inline(always)]
50    pub fn set_bit(self) -> &'a mut W {
51        self.bit(true)
52    }
53    #[doc = r"Clears the field bit"]
54    #[inline(always)]
55    pub fn clear_bit(self) -> &'a mut W {
56        self.bit(false)
57    }
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub fn bit(self, value: bool) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
62        self.w
63    }
64}
65#[doc = "Reader of field `OSSR`"]
66pub type OSSR_R = crate::R<bool, bool>;
67#[doc = "Write proxy for field `OSSR`"]
68pub struct OSSR_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> OSSR_W<'a> {
72    #[doc = r"Sets the field bit"]
73    #[inline(always)]
74    pub fn set_bit(self) -> &'a mut W {
75        self.bit(true)
76    }
77    #[doc = r"Clears the field bit"]
78    #[inline(always)]
79    pub fn clear_bit(self) -> &'a mut W {
80        self.bit(false)
81    }
82    #[doc = r"Writes raw bits to the field"]
83    #[inline(always)]
84    pub fn bit(self, value: bool) -> &'a mut W {
85        self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11);
86        self.w
87    }
88}
89#[doc = "Reader of field `BKE`"]
90pub type BKE_R = crate::R<bool, bool>;
91#[doc = "Write proxy for field `BKE`"]
92pub struct BKE_W<'a> {
93    w: &'a mut W,
94}
95impl<'a> BKE_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 << 12)) | (((value as u32) & 0x01) << 12);
110        self.w
111    }
112}
113#[doc = "Reader of field `BKP`"]
114pub type BKP_R = crate::R<bool, bool>;
115#[doc = "Write proxy for field `BKP`"]
116pub struct BKP_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> BKP_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 << 13)) | (((value as u32) & 0x01) << 13);
134        self.w
135    }
136}
137#[doc = "Reader of field `AOE`"]
138pub type AOE_R = crate::R<bool, bool>;
139#[doc = "Write proxy for field `AOE`"]
140pub struct AOE_W<'a> {
141    w: &'a mut W,
142}
143impl<'a> AOE_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 << 14)) | (((value as u32) & 0x01) << 14);
158        self.w
159    }
160}
161#[doc = "Reader of field `MOE`"]
162pub type MOE_R = crate::R<bool, bool>;
163#[doc = "Write proxy for field `MOE`"]
164pub struct MOE_W<'a> {
165    w: &'a mut W,
166}
167impl<'a> MOE_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 << 15)) | (((value as u32) & 0x01) << 15);
182        self.w
183    }
184}
185#[doc = "Reader of field `BKF`"]
186pub type BKF_R = crate::R<u8, u8>;
187#[doc = "Write proxy for field `BKF`"]
188pub struct BKF_W<'a> {
189    w: &'a mut W,
190}
191impl<'a> BKF_W<'a> {
192    #[doc = r"Writes raw bits to the field"]
193    #[inline(always)]
194    pub unsafe fn bits(self, value: u8) -> &'a mut W {
195        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
196        self.w
197    }
198}
199impl R {
200    #[doc = "Bits 0:7 - Dead-time generator setup"]
201    #[inline(always)]
202    pub fn dtg(&self) -> DTG_R {
203        DTG_R::new((self.bits & 0xff) as u8)
204    }
205    #[doc = "Bits 8:9 - Lock configuration"]
206    #[inline(always)]
207    pub fn lock(&self) -> LOCK_R {
208        LOCK_R::new(((self.bits >> 8) & 0x03) as u8)
209    }
210    #[doc = "Bit 10 - Off-state selection for Idle mode"]
211    #[inline(always)]
212    pub fn ossi(&self) -> OSSI_R {
213        OSSI_R::new(((self.bits >> 10) & 0x01) != 0)
214    }
215    #[doc = "Bit 11 - Off-state selection for Run mode"]
216    #[inline(always)]
217    pub fn ossr(&self) -> OSSR_R {
218        OSSR_R::new(((self.bits >> 11) & 0x01) != 0)
219    }
220    #[doc = "Bit 12 - Break enable"]
221    #[inline(always)]
222    pub fn bke(&self) -> BKE_R {
223        BKE_R::new(((self.bits >> 12) & 0x01) != 0)
224    }
225    #[doc = "Bit 13 - Break polarity"]
226    #[inline(always)]
227    pub fn bkp(&self) -> BKP_R {
228        BKP_R::new(((self.bits >> 13) & 0x01) != 0)
229    }
230    #[doc = "Bit 14 - Automatic output enable"]
231    #[inline(always)]
232    pub fn aoe(&self) -> AOE_R {
233        AOE_R::new(((self.bits >> 14) & 0x01) != 0)
234    }
235    #[doc = "Bit 15 - Main output enable"]
236    #[inline(always)]
237    pub fn moe(&self) -> MOE_R {
238        MOE_R::new(((self.bits >> 15) & 0x01) != 0)
239    }
240    #[doc = "Bits 16:19 - Break filter"]
241    #[inline(always)]
242    pub fn bkf(&self) -> BKF_R {
243        BKF_R::new(((self.bits >> 16) & 0x0f) as u8)
244    }
245}
246impl W {
247    #[doc = "Bits 0:7 - Dead-time generator setup"]
248    #[inline(always)]
249    pub fn dtg(&mut self) -> DTG_W {
250        DTG_W { w: self }
251    }
252    #[doc = "Bits 8:9 - Lock configuration"]
253    #[inline(always)]
254    pub fn lock(&mut self) -> LOCK_W {
255        LOCK_W { w: self }
256    }
257    #[doc = "Bit 10 - Off-state selection for Idle mode"]
258    #[inline(always)]
259    pub fn ossi(&mut self) -> OSSI_W {
260        OSSI_W { w: self }
261    }
262    #[doc = "Bit 11 - Off-state selection for Run mode"]
263    #[inline(always)]
264    pub fn ossr(&mut self) -> OSSR_W {
265        OSSR_W { w: self }
266    }
267    #[doc = "Bit 12 - Break enable"]
268    #[inline(always)]
269    pub fn bke(&mut self) -> BKE_W {
270        BKE_W { w: self }
271    }
272    #[doc = "Bit 13 - Break polarity"]
273    #[inline(always)]
274    pub fn bkp(&mut self) -> BKP_W {
275        BKP_W { w: self }
276    }
277    #[doc = "Bit 14 - Automatic output enable"]
278    #[inline(always)]
279    pub fn aoe(&mut self) -> AOE_W {
280        AOE_W { w: self }
281    }
282    #[doc = "Bit 15 - Main output enable"]
283    #[inline(always)]
284    pub fn moe(&mut self) -> MOE_W {
285        MOE_W { w: self }
286    }
287    #[doc = "Bits 16:19 - Break filter"]
288    #[inline(always)]
289    pub fn bkf(&mut self) -> BKF_W {
290        BKF_W { w: self }
291    }
292}