stm32f1_staging/stm32f101/rcc/
apb1enr.rs

1///Register `APB1ENR` reader
2pub type R = crate::R<APB1ENRrs>;
3///Register `APB1ENR` writer
4pub type W = crate::W<APB1ENRrs>;
5/**Timer 2 clock enable
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum TIM2EN {
11    ///0: The selected clock is disabled
12    Disabled = 0,
13    ///1: The selected clock is enabled
14    Enabled = 1,
15}
16impl From<TIM2EN> for bool {
17    #[inline(always)]
18    fn from(variant: TIM2EN) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `TIM2EN` reader - Timer 2 clock enable
23pub type TIM2EN_R = crate::BitReader<TIM2EN>;
24impl TIM2EN_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> TIM2EN {
28        match self.bits {
29            false => TIM2EN::Disabled,
30            true => TIM2EN::Enabled,
31        }
32    }
33    ///The selected clock is disabled
34    #[inline(always)]
35    pub fn is_disabled(&self) -> bool {
36        *self == TIM2EN::Disabled
37    }
38    ///The selected clock is enabled
39    #[inline(always)]
40    pub fn is_enabled(&self) -> bool {
41        *self == TIM2EN::Enabled
42    }
43}
44///Field `TIM2EN` writer - Timer 2 clock enable
45pub type TIM2EN_W<'a, REG> = crate::BitWriter<'a, REG, TIM2EN>;
46impl<'a, REG> TIM2EN_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///The selected clock is disabled
51    #[inline(always)]
52    pub fn disabled(self) -> &'a mut crate::W<REG> {
53        self.variant(TIM2EN::Disabled)
54    }
55    ///The selected clock is enabled
56    #[inline(always)]
57    pub fn enabled(self) -> &'a mut crate::W<REG> {
58        self.variant(TIM2EN::Enabled)
59    }
60}
61///Field `TIM3EN` reader - Timer 3 clock enable
62pub use TIM2EN_R as TIM3EN_R;
63///Field `TIM4EN` reader - Timer 4 clock enable
64pub use TIM2EN_R as TIM4EN_R;
65///Field `TIM5EN` reader - Timer 5 clock enable
66pub use TIM2EN_R as TIM5EN_R;
67///Field `TIM6EN` reader - Timer 6 clock enable
68pub use TIM2EN_R as TIM6EN_R;
69///Field `TIM7EN` reader - Timer 7 clock enable
70pub use TIM2EN_R as TIM7EN_R;
71///Field `TIM12EN` reader - Timer 12 clock enable
72pub use TIM2EN_R as TIM12EN_R;
73///Field `TIM13EN` reader - Timer 13 clock enable
74pub use TIM2EN_R as TIM13EN_R;
75///Field `TIM14EN` reader - Timer 14 clock enable
76pub use TIM2EN_R as TIM14EN_R;
77///Field `WWDGEN` reader - Window watchdog clock enable
78pub use TIM2EN_R as WWDGEN_R;
79///Field `SPI2EN` reader - SPI 2 clock enable
80pub use TIM2EN_R as SPI2EN_R;
81///Field `SPI3EN` reader - SPI 3 clock enable
82pub use TIM2EN_R as SPI3EN_R;
83///Field `USART2EN` reader - USART 2 clock enable
84pub use TIM2EN_R as USART2EN_R;
85///Field `USART3EN` reader - USART 3 clock enable
86pub use TIM2EN_R as USART3EN_R;
87///Field `UART4EN` reader - UART 4 clock enable
88pub use TIM2EN_R as UART4EN_R;
89///Field `UART5EN` reader - UART 5 clock enable
90pub use TIM2EN_R as UART5EN_R;
91///Field `I2C1EN` reader - I2C 1 clock enable
92pub use TIM2EN_R as I2C1EN_R;
93///Field `I2C2EN` reader - I2C 2 clock enable
94pub use TIM2EN_R as I2C2EN_R;
95///Field `BKPEN` reader - Backup interface clock enable
96pub use TIM2EN_R as BKPEN_R;
97///Field `PWREN` reader - Power interface clock enable
98pub use TIM2EN_R as PWREN_R;
99///Field `DACEN` reader - DAC interface clock enable
100pub use TIM2EN_R as DACEN_R;
101///Field `TIM3EN` writer - Timer 3 clock enable
102pub use TIM2EN_W as TIM3EN_W;
103///Field `TIM4EN` writer - Timer 4 clock enable
104pub use TIM2EN_W as TIM4EN_W;
105///Field `TIM5EN` writer - Timer 5 clock enable
106pub use TIM2EN_W as TIM5EN_W;
107///Field `TIM6EN` writer - Timer 6 clock enable
108pub use TIM2EN_W as TIM6EN_W;
109///Field `TIM7EN` writer - Timer 7 clock enable
110pub use TIM2EN_W as TIM7EN_W;
111///Field `TIM12EN` writer - Timer 12 clock enable
112pub use TIM2EN_W as TIM12EN_W;
113///Field `TIM13EN` writer - Timer 13 clock enable
114pub use TIM2EN_W as TIM13EN_W;
115///Field `TIM14EN` writer - Timer 14 clock enable
116pub use TIM2EN_W as TIM14EN_W;
117///Field `WWDGEN` writer - Window watchdog clock enable
118pub use TIM2EN_W as WWDGEN_W;
119///Field `SPI2EN` writer - SPI 2 clock enable
120pub use TIM2EN_W as SPI2EN_W;
121///Field `SPI3EN` writer - SPI 3 clock enable
122pub use TIM2EN_W as SPI3EN_W;
123///Field `USART2EN` writer - USART 2 clock enable
124pub use TIM2EN_W as USART2EN_W;
125///Field `USART3EN` writer - USART 3 clock enable
126pub use TIM2EN_W as USART3EN_W;
127///Field `UART4EN` writer - UART 4 clock enable
128pub use TIM2EN_W as UART4EN_W;
129///Field `UART5EN` writer - UART 5 clock enable
130pub use TIM2EN_W as UART5EN_W;
131///Field `I2C1EN` writer - I2C 1 clock enable
132pub use TIM2EN_W as I2C1EN_W;
133///Field `I2C2EN` writer - I2C 2 clock enable
134pub use TIM2EN_W as I2C2EN_W;
135///Field `BKPEN` writer - Backup interface clock enable
136pub use TIM2EN_W as BKPEN_W;
137///Field `PWREN` writer - Power interface clock enable
138pub use TIM2EN_W as PWREN_W;
139///Field `DACEN` writer - DAC interface clock enable
140pub use TIM2EN_W as DACEN_W;
141impl R {
142    ///Bit 0 - Timer 2 clock enable
143    #[inline(always)]
144    pub fn tim2en(&self) -> TIM2EN_R {
145        TIM2EN_R::new((self.bits & 1) != 0)
146    }
147    ///Bit 1 - Timer 3 clock enable
148    #[inline(always)]
149    pub fn tim3en(&self) -> TIM3EN_R {
150        TIM3EN_R::new(((self.bits >> 1) & 1) != 0)
151    }
152    ///Bit 2 - Timer 4 clock enable
153    #[inline(always)]
154    pub fn tim4en(&self) -> TIM4EN_R {
155        TIM4EN_R::new(((self.bits >> 2) & 1) != 0)
156    }
157    ///Bit 3 - Timer 5 clock enable
158    #[inline(always)]
159    pub fn tim5en(&self) -> TIM5EN_R {
160        TIM5EN_R::new(((self.bits >> 3) & 1) != 0)
161    }
162    ///Bit 4 - Timer 6 clock enable
163    #[inline(always)]
164    pub fn tim6en(&self) -> TIM6EN_R {
165        TIM6EN_R::new(((self.bits >> 4) & 1) != 0)
166    }
167    ///Bit 5 - Timer 7 clock enable
168    #[inline(always)]
169    pub fn tim7en(&self) -> TIM7EN_R {
170        TIM7EN_R::new(((self.bits >> 5) & 1) != 0)
171    }
172    ///Bit 6 - Timer 12 clock enable
173    #[inline(always)]
174    pub fn tim12en(&self) -> TIM12EN_R {
175        TIM12EN_R::new(((self.bits >> 6) & 1) != 0)
176    }
177    ///Bit 7 - Timer 13 clock enable
178    #[inline(always)]
179    pub fn tim13en(&self) -> TIM13EN_R {
180        TIM13EN_R::new(((self.bits >> 7) & 1) != 0)
181    }
182    ///Bit 8 - Timer 14 clock enable
183    #[inline(always)]
184    pub fn tim14en(&self) -> TIM14EN_R {
185        TIM14EN_R::new(((self.bits >> 8) & 1) != 0)
186    }
187    ///Bit 11 - Window watchdog clock enable
188    #[inline(always)]
189    pub fn wwdgen(&self) -> WWDGEN_R {
190        WWDGEN_R::new(((self.bits >> 11) & 1) != 0)
191    }
192    ///Bit 14 - SPI 2 clock enable
193    #[inline(always)]
194    pub fn spi2en(&self) -> SPI2EN_R {
195        SPI2EN_R::new(((self.bits >> 14) & 1) != 0)
196    }
197    ///Bit 15 - SPI 3 clock enable
198    #[inline(always)]
199    pub fn spi3en(&self) -> SPI3EN_R {
200        SPI3EN_R::new(((self.bits >> 15) & 1) != 0)
201    }
202    ///Bit 17 - USART 2 clock enable
203    #[inline(always)]
204    pub fn usart2en(&self) -> USART2EN_R {
205        USART2EN_R::new(((self.bits >> 17) & 1) != 0)
206    }
207    ///Bit 18 - USART 3 clock enable
208    #[inline(always)]
209    pub fn usart3en(&self) -> USART3EN_R {
210        USART3EN_R::new(((self.bits >> 18) & 1) != 0)
211    }
212    ///Bit 19 - UART 4 clock enable
213    #[inline(always)]
214    pub fn uart4en(&self) -> UART4EN_R {
215        UART4EN_R::new(((self.bits >> 19) & 1) != 0)
216    }
217    ///Bit 20 - UART 5 clock enable
218    #[inline(always)]
219    pub fn uart5en(&self) -> UART5EN_R {
220        UART5EN_R::new(((self.bits >> 20) & 1) != 0)
221    }
222    ///Bit 21 - I2C 1 clock enable
223    #[inline(always)]
224    pub fn i2c1en(&self) -> I2C1EN_R {
225        I2C1EN_R::new(((self.bits >> 21) & 1) != 0)
226    }
227    ///Bit 22 - I2C 2 clock enable
228    #[inline(always)]
229    pub fn i2c2en(&self) -> I2C2EN_R {
230        I2C2EN_R::new(((self.bits >> 22) & 1) != 0)
231    }
232    ///Bit 27 - Backup interface clock enable
233    #[inline(always)]
234    pub fn bkpen(&self) -> BKPEN_R {
235        BKPEN_R::new(((self.bits >> 27) & 1) != 0)
236    }
237    ///Bit 28 - Power interface clock enable
238    #[inline(always)]
239    pub fn pwren(&self) -> PWREN_R {
240        PWREN_R::new(((self.bits >> 28) & 1) != 0)
241    }
242    ///Bit 29 - DAC interface clock enable
243    #[inline(always)]
244    pub fn dacen(&self) -> DACEN_R {
245        DACEN_R::new(((self.bits >> 29) & 1) != 0)
246    }
247}
248impl core::fmt::Debug for R {
249    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
250        f.debug_struct("APB1ENR")
251            .field("tim2en", &self.tim2en())
252            .field("tim3en", &self.tim3en())
253            .field("tim4en", &self.tim4en())
254            .field("tim5en", &self.tim5en())
255            .field("tim6en", &self.tim6en())
256            .field("tim7en", &self.tim7en())
257            .field("tim12en", &self.tim12en())
258            .field("tim13en", &self.tim13en())
259            .field("tim14en", &self.tim14en())
260            .field("wwdgen", &self.wwdgen())
261            .field("spi2en", &self.spi2en())
262            .field("spi3en", &self.spi3en())
263            .field("usart2en", &self.usart2en())
264            .field("usart3en", &self.usart3en())
265            .field("uart4en", &self.uart4en())
266            .field("uart5en", &self.uart5en())
267            .field("i2c1en", &self.i2c1en())
268            .field("i2c2en", &self.i2c2en())
269            .field("bkpen", &self.bkpen())
270            .field("pwren", &self.pwren())
271            .field("dacen", &self.dacen())
272            .finish()
273    }
274}
275impl W {
276    ///Bit 0 - Timer 2 clock enable
277    #[inline(always)]
278    pub fn tim2en(&mut self) -> TIM2EN_W<APB1ENRrs> {
279        TIM2EN_W::new(self, 0)
280    }
281    ///Bit 1 - Timer 3 clock enable
282    #[inline(always)]
283    pub fn tim3en(&mut self) -> TIM3EN_W<APB1ENRrs> {
284        TIM3EN_W::new(self, 1)
285    }
286    ///Bit 2 - Timer 4 clock enable
287    #[inline(always)]
288    pub fn tim4en(&mut self) -> TIM4EN_W<APB1ENRrs> {
289        TIM4EN_W::new(self, 2)
290    }
291    ///Bit 3 - Timer 5 clock enable
292    #[inline(always)]
293    pub fn tim5en(&mut self) -> TIM5EN_W<APB1ENRrs> {
294        TIM5EN_W::new(self, 3)
295    }
296    ///Bit 4 - Timer 6 clock enable
297    #[inline(always)]
298    pub fn tim6en(&mut self) -> TIM6EN_W<APB1ENRrs> {
299        TIM6EN_W::new(self, 4)
300    }
301    ///Bit 5 - Timer 7 clock enable
302    #[inline(always)]
303    pub fn tim7en(&mut self) -> TIM7EN_W<APB1ENRrs> {
304        TIM7EN_W::new(self, 5)
305    }
306    ///Bit 6 - Timer 12 clock enable
307    #[inline(always)]
308    pub fn tim12en(&mut self) -> TIM12EN_W<APB1ENRrs> {
309        TIM12EN_W::new(self, 6)
310    }
311    ///Bit 7 - Timer 13 clock enable
312    #[inline(always)]
313    pub fn tim13en(&mut self) -> TIM13EN_W<APB1ENRrs> {
314        TIM13EN_W::new(self, 7)
315    }
316    ///Bit 8 - Timer 14 clock enable
317    #[inline(always)]
318    pub fn tim14en(&mut self) -> TIM14EN_W<APB1ENRrs> {
319        TIM14EN_W::new(self, 8)
320    }
321    ///Bit 11 - Window watchdog clock enable
322    #[inline(always)]
323    pub fn wwdgen(&mut self) -> WWDGEN_W<APB1ENRrs> {
324        WWDGEN_W::new(self, 11)
325    }
326    ///Bit 14 - SPI 2 clock enable
327    #[inline(always)]
328    pub fn spi2en(&mut self) -> SPI2EN_W<APB1ENRrs> {
329        SPI2EN_W::new(self, 14)
330    }
331    ///Bit 15 - SPI 3 clock enable
332    #[inline(always)]
333    pub fn spi3en(&mut self) -> SPI3EN_W<APB1ENRrs> {
334        SPI3EN_W::new(self, 15)
335    }
336    ///Bit 17 - USART 2 clock enable
337    #[inline(always)]
338    pub fn usart2en(&mut self) -> USART2EN_W<APB1ENRrs> {
339        USART2EN_W::new(self, 17)
340    }
341    ///Bit 18 - USART 3 clock enable
342    #[inline(always)]
343    pub fn usart3en(&mut self) -> USART3EN_W<APB1ENRrs> {
344        USART3EN_W::new(self, 18)
345    }
346    ///Bit 19 - UART 4 clock enable
347    #[inline(always)]
348    pub fn uart4en(&mut self) -> UART4EN_W<APB1ENRrs> {
349        UART4EN_W::new(self, 19)
350    }
351    ///Bit 20 - UART 5 clock enable
352    #[inline(always)]
353    pub fn uart5en(&mut self) -> UART5EN_W<APB1ENRrs> {
354        UART5EN_W::new(self, 20)
355    }
356    ///Bit 21 - I2C 1 clock enable
357    #[inline(always)]
358    pub fn i2c1en(&mut self) -> I2C1EN_W<APB1ENRrs> {
359        I2C1EN_W::new(self, 21)
360    }
361    ///Bit 22 - I2C 2 clock enable
362    #[inline(always)]
363    pub fn i2c2en(&mut self) -> I2C2EN_W<APB1ENRrs> {
364        I2C2EN_W::new(self, 22)
365    }
366    ///Bit 27 - Backup interface clock enable
367    #[inline(always)]
368    pub fn bkpen(&mut self) -> BKPEN_W<APB1ENRrs> {
369        BKPEN_W::new(self, 27)
370    }
371    ///Bit 28 - Power interface clock enable
372    #[inline(always)]
373    pub fn pwren(&mut self) -> PWREN_W<APB1ENRrs> {
374        PWREN_W::new(self, 28)
375    }
376    ///Bit 29 - DAC interface clock enable
377    #[inline(always)]
378    pub fn dacen(&mut self) -> DACEN_W<APB1ENRrs> {
379        DACEN_W::new(self, 29)
380    }
381}
382/**APB1 peripheral clock enable register (RCC_APB1ENR)
383
384You can [`read`](crate::Reg::read) this register and get [`apb1enr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`apb1enr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
385
386See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F101.html#RCC:APB1ENR)*/
387pub struct APB1ENRrs;
388impl crate::RegisterSpec for APB1ENRrs {
389    type Ux = u32;
390}
391///`read()` method returns [`apb1enr::R`](R) reader structure
392impl crate::Readable for APB1ENRrs {}
393///`write(|w| ..)` method takes [`apb1enr::W`](W) writer structure
394impl crate::Writable for APB1ENRrs {
395    type Safety = crate::Unsafe;
396}
397///`reset()` method sets APB1ENR to value 0
398impl crate::Resettable for APB1ENRrs {}