stm32f3/stm32f302/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 `TIM6EN` reader - Timer 6 clock enable
66pub use TIM2EN_R as TIM6EN_R;
67///Field `WWDGEN` reader - Window watchdog clock enable
68pub use TIM2EN_R as WWDGEN_R;
69///Field `SPI2EN` reader - SPI 2 clock enable
70pub use TIM2EN_R as SPI2EN_R;
71///Field `SPI3EN` reader - SPI 3 clock enable
72pub use TIM2EN_R as SPI3EN_R;
73///Field `USART2EN` reader - USART 2 clock enable
74pub use TIM2EN_R as USART2EN_R;
75///Field `USART3EN` reader - USART3 clock enable
76pub use TIM2EN_R as USART3EN_R;
77///Field `UART4EN` reader - UART4 clock enable
78pub use TIM2EN_R as UART4EN_R;
79///Field `UART5EN` reader - UART5 clock enable
80pub use TIM2EN_R as UART5EN_R;
81///Field `I2C1EN` reader - I2C 1 clock enable
82pub use TIM2EN_R as I2C1EN_R;
83///Field `I2C2EN` reader - I2C 2 clock enable
84pub use TIM2EN_R as I2C2EN_R;
85///Field `USBEN` reader - USB clock enable
86pub use TIM2EN_R as USBEN_R;
87///Field `CANEN` reader - CAN clock enable
88pub use TIM2EN_R as CANEN_R;
89///Field `PWREN` reader - Power interface clock enable
90pub use TIM2EN_R as PWREN_R;
91///Field `DAC1EN` reader - DAC interface clock enable
92pub use TIM2EN_R as DAC1EN_R;
93///Field `I2C3EN` reader - I2C3 clock enable
94pub use TIM2EN_R as I2C3EN_R;
95///Field `TIM3EN` writer - Timer 3 clock enable
96pub use TIM2EN_W as TIM3EN_W;
97///Field `TIM4EN` writer - Timer 4 clock enable
98pub use TIM2EN_W as TIM4EN_W;
99///Field `TIM6EN` writer - Timer 6 clock enable
100pub use TIM2EN_W as TIM6EN_W;
101///Field `WWDGEN` writer - Window watchdog clock enable
102pub use TIM2EN_W as WWDGEN_W;
103///Field `SPI2EN` writer - SPI 2 clock enable
104pub use TIM2EN_W as SPI2EN_W;
105///Field `SPI3EN` writer - SPI 3 clock enable
106pub use TIM2EN_W as SPI3EN_W;
107///Field `USART2EN` writer - USART 2 clock enable
108pub use TIM2EN_W as USART2EN_W;
109///Field `USART3EN` writer - USART3 clock enable
110pub use TIM2EN_W as USART3EN_W;
111///Field `UART4EN` writer - UART4 clock enable
112pub use TIM2EN_W as UART4EN_W;
113///Field `UART5EN` writer - UART5 clock enable
114pub use TIM2EN_W as UART5EN_W;
115///Field `I2C1EN` writer - I2C 1 clock enable
116pub use TIM2EN_W as I2C1EN_W;
117///Field `I2C2EN` writer - I2C 2 clock enable
118pub use TIM2EN_W as I2C2EN_W;
119///Field `USBEN` writer - USB clock enable
120pub use TIM2EN_W as USBEN_W;
121///Field `CANEN` writer - CAN clock enable
122pub use TIM2EN_W as CANEN_W;
123///Field `PWREN` writer - Power interface clock enable
124pub use TIM2EN_W as PWREN_W;
125///Field `DAC1EN` writer - DAC interface clock enable
126pub use TIM2EN_W as DAC1EN_W;
127///Field `I2C3EN` writer - I2C3 clock enable
128pub use TIM2EN_W as I2C3EN_W;
129impl R {
130    ///Bit 0 - Timer 2 clock enable
131    #[inline(always)]
132    pub fn tim2en(&self) -> TIM2EN_R {
133        TIM2EN_R::new((self.bits & 1) != 0)
134    }
135    ///Bit 1 - Timer 3 clock enable
136    #[inline(always)]
137    pub fn tim3en(&self) -> TIM3EN_R {
138        TIM3EN_R::new(((self.bits >> 1) & 1) != 0)
139    }
140    ///Bit 2 - Timer 4 clock enable
141    #[inline(always)]
142    pub fn tim4en(&self) -> TIM4EN_R {
143        TIM4EN_R::new(((self.bits >> 2) & 1) != 0)
144    }
145    ///Bit 4 - Timer 6 clock enable
146    #[inline(always)]
147    pub fn tim6en(&self) -> TIM6EN_R {
148        TIM6EN_R::new(((self.bits >> 4) & 1) != 0)
149    }
150    ///Bit 11 - Window watchdog clock enable
151    #[inline(always)]
152    pub fn wwdgen(&self) -> WWDGEN_R {
153        WWDGEN_R::new(((self.bits >> 11) & 1) != 0)
154    }
155    ///Bit 14 - SPI 2 clock enable
156    #[inline(always)]
157    pub fn spi2en(&self) -> SPI2EN_R {
158        SPI2EN_R::new(((self.bits >> 14) & 1) != 0)
159    }
160    ///Bit 15 - SPI 3 clock enable
161    #[inline(always)]
162    pub fn spi3en(&self) -> SPI3EN_R {
163        SPI3EN_R::new(((self.bits >> 15) & 1) != 0)
164    }
165    ///Bit 17 - USART 2 clock enable
166    #[inline(always)]
167    pub fn usart2en(&self) -> USART2EN_R {
168        USART2EN_R::new(((self.bits >> 17) & 1) != 0)
169    }
170    ///Bit 18 - USART3 clock enable
171    #[inline(always)]
172    pub fn usart3en(&self) -> USART3EN_R {
173        USART3EN_R::new(((self.bits >> 18) & 1) != 0)
174    }
175    ///Bit 19 - UART4 clock enable
176    #[inline(always)]
177    pub fn uart4en(&self) -> UART4EN_R {
178        UART4EN_R::new(((self.bits >> 19) & 1) != 0)
179    }
180    ///Bit 20 - UART5 clock enable
181    #[inline(always)]
182    pub fn uart5en(&self) -> UART5EN_R {
183        UART5EN_R::new(((self.bits >> 20) & 1) != 0)
184    }
185    ///Bit 21 - I2C 1 clock enable
186    #[inline(always)]
187    pub fn i2c1en(&self) -> I2C1EN_R {
188        I2C1EN_R::new(((self.bits >> 21) & 1) != 0)
189    }
190    ///Bit 22 - I2C 2 clock enable
191    #[inline(always)]
192    pub fn i2c2en(&self) -> I2C2EN_R {
193        I2C2EN_R::new(((self.bits >> 22) & 1) != 0)
194    }
195    ///Bit 23 - USB clock enable
196    #[inline(always)]
197    pub fn usben(&self) -> USBEN_R {
198        USBEN_R::new(((self.bits >> 23) & 1) != 0)
199    }
200    ///Bit 25 - CAN clock enable
201    #[inline(always)]
202    pub fn canen(&self) -> CANEN_R {
203        CANEN_R::new(((self.bits >> 25) & 1) != 0)
204    }
205    ///Bit 28 - Power interface clock enable
206    #[inline(always)]
207    pub fn pwren(&self) -> PWREN_R {
208        PWREN_R::new(((self.bits >> 28) & 1) != 0)
209    }
210    ///Bit 29 - DAC interface clock enable
211    #[inline(always)]
212    pub fn dac1en(&self) -> DAC1EN_R {
213        DAC1EN_R::new(((self.bits >> 29) & 1) != 0)
214    }
215    ///Bit 30 - I2C3 clock enable
216    #[inline(always)]
217    pub fn i2c3en(&self) -> I2C3EN_R {
218        I2C3EN_R::new(((self.bits >> 30) & 1) != 0)
219    }
220}
221impl core::fmt::Debug for R {
222    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
223        f.debug_struct("APB1ENR")
224            .field("tim2en", &self.tim2en())
225            .field("tim3en", &self.tim3en())
226            .field("tim4en", &self.tim4en())
227            .field("tim6en", &self.tim6en())
228            .field("wwdgen", &self.wwdgen())
229            .field("spi2en", &self.spi2en())
230            .field("spi3en", &self.spi3en())
231            .field("usart2en", &self.usart2en())
232            .field("i2c1en", &self.i2c1en())
233            .field("i2c2en", &self.i2c2en())
234            .field("usben", &self.usben())
235            .field("canen", &self.canen())
236            .field("pwren", &self.pwren())
237            .field("dac1en", &self.dac1en())
238            .field("usart3en", &self.usart3en())
239            .field("uart4en", &self.uart4en())
240            .field("uart5en", &self.uart5en())
241            .field("i2c3en", &self.i2c3en())
242            .finish()
243    }
244}
245impl W {
246    ///Bit 0 - Timer 2 clock enable
247    #[inline(always)]
248    pub fn tim2en(&mut self) -> TIM2EN_W<APB1ENRrs> {
249        TIM2EN_W::new(self, 0)
250    }
251    ///Bit 1 - Timer 3 clock enable
252    #[inline(always)]
253    pub fn tim3en(&mut self) -> TIM3EN_W<APB1ENRrs> {
254        TIM3EN_W::new(self, 1)
255    }
256    ///Bit 2 - Timer 4 clock enable
257    #[inline(always)]
258    pub fn tim4en(&mut self) -> TIM4EN_W<APB1ENRrs> {
259        TIM4EN_W::new(self, 2)
260    }
261    ///Bit 4 - Timer 6 clock enable
262    #[inline(always)]
263    pub fn tim6en(&mut self) -> TIM6EN_W<APB1ENRrs> {
264        TIM6EN_W::new(self, 4)
265    }
266    ///Bit 11 - Window watchdog clock enable
267    #[inline(always)]
268    pub fn wwdgen(&mut self) -> WWDGEN_W<APB1ENRrs> {
269        WWDGEN_W::new(self, 11)
270    }
271    ///Bit 14 - SPI 2 clock enable
272    #[inline(always)]
273    pub fn spi2en(&mut self) -> SPI2EN_W<APB1ENRrs> {
274        SPI2EN_W::new(self, 14)
275    }
276    ///Bit 15 - SPI 3 clock enable
277    #[inline(always)]
278    pub fn spi3en(&mut self) -> SPI3EN_W<APB1ENRrs> {
279        SPI3EN_W::new(self, 15)
280    }
281    ///Bit 17 - USART 2 clock enable
282    #[inline(always)]
283    pub fn usart2en(&mut self) -> USART2EN_W<APB1ENRrs> {
284        USART2EN_W::new(self, 17)
285    }
286    ///Bit 18 - USART3 clock enable
287    #[inline(always)]
288    pub fn usart3en(&mut self) -> USART3EN_W<APB1ENRrs> {
289        USART3EN_W::new(self, 18)
290    }
291    ///Bit 19 - UART4 clock enable
292    #[inline(always)]
293    pub fn uart4en(&mut self) -> UART4EN_W<APB1ENRrs> {
294        UART4EN_W::new(self, 19)
295    }
296    ///Bit 20 - UART5 clock enable
297    #[inline(always)]
298    pub fn uart5en(&mut self) -> UART5EN_W<APB1ENRrs> {
299        UART5EN_W::new(self, 20)
300    }
301    ///Bit 21 - I2C 1 clock enable
302    #[inline(always)]
303    pub fn i2c1en(&mut self) -> I2C1EN_W<APB1ENRrs> {
304        I2C1EN_W::new(self, 21)
305    }
306    ///Bit 22 - I2C 2 clock enable
307    #[inline(always)]
308    pub fn i2c2en(&mut self) -> I2C2EN_W<APB1ENRrs> {
309        I2C2EN_W::new(self, 22)
310    }
311    ///Bit 23 - USB clock enable
312    #[inline(always)]
313    pub fn usben(&mut self) -> USBEN_W<APB1ENRrs> {
314        USBEN_W::new(self, 23)
315    }
316    ///Bit 25 - CAN clock enable
317    #[inline(always)]
318    pub fn canen(&mut self) -> CANEN_W<APB1ENRrs> {
319        CANEN_W::new(self, 25)
320    }
321    ///Bit 28 - Power interface clock enable
322    #[inline(always)]
323    pub fn pwren(&mut self) -> PWREN_W<APB1ENRrs> {
324        PWREN_W::new(self, 28)
325    }
326    ///Bit 29 - DAC interface clock enable
327    #[inline(always)]
328    pub fn dac1en(&mut self) -> DAC1EN_W<APB1ENRrs> {
329        DAC1EN_W::new(self, 29)
330    }
331    ///Bit 30 - I2C3 clock enable
332    #[inline(always)]
333    pub fn i2c3en(&mut self) -> I2C3EN_W<APB1ENRrs> {
334        I2C3EN_W::new(self, 30)
335    }
336}
337/**APB1 peripheral clock enable register (RCC_APB1ENR)
338
339You 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).
340
341See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F302.html#RCC:APB1ENR)*/
342pub struct APB1ENRrs;
343impl crate::RegisterSpec for APB1ENRrs {
344    type Ux = u32;
345}
346///`read()` method returns [`apb1enr::R`](R) reader structure
347impl crate::Readable for APB1ENRrs {}
348///`write(|w| ..)` method takes [`apb1enr::W`](W) writer structure
349impl crate::Writable for APB1ENRrs {
350    type Safety = crate::Unsafe;
351}
352///`reset()` method sets APB1ENR to value 0
353impl crate::Resettable for APB1ENRrs {}