stm32f1_staging/stm32f107/rcc/
apb2enr.rs1pub type R = crate::R<APB2ENRrs>;
3pub type W = crate::W<APB2ENRrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum AFIOEN {
11 Disabled = 0,
13 Enabled = 1,
15}
16impl From<AFIOEN> for bool {
17 #[inline(always)]
18 fn from(variant: AFIOEN) -> Self {
19 variant as u8 != 0
20 }
21}
22pub type AFIOEN_R = crate::BitReader<AFIOEN>;
24impl AFIOEN_R {
25 #[inline(always)]
27 pub const fn variant(&self) -> AFIOEN {
28 match self.bits {
29 false => AFIOEN::Disabled,
30 true => AFIOEN::Enabled,
31 }
32 }
33 #[inline(always)]
35 pub fn is_disabled(&self) -> bool {
36 *self == AFIOEN::Disabled
37 }
38 #[inline(always)]
40 pub fn is_enabled(&self) -> bool {
41 *self == AFIOEN::Enabled
42 }
43}
44pub type AFIOEN_W<'a, REG> = crate::BitWriter<'a, REG, AFIOEN>;
46impl<'a, REG> AFIOEN_W<'a, REG>
47where
48 REG: crate::Writable + crate::RegisterSpec,
49{
50 #[inline(always)]
52 pub fn disabled(self) -> &'a mut crate::W<REG> {
53 self.variant(AFIOEN::Disabled)
54 }
55 #[inline(always)]
57 pub fn enabled(self) -> &'a mut crate::W<REG> {
58 self.variant(AFIOEN::Enabled)
59 }
60}
61pub use AFIOEN_R as IOPAEN_R;
63pub use AFIOEN_R as IOPBEN_R;
65pub use AFIOEN_R as IOPCEN_R;
67pub use AFIOEN_R as IOPDEN_R;
69pub use AFIOEN_R as IOPEEN_R;
71pub use AFIOEN_R as ADC1EN_R;
73pub use AFIOEN_R as ADC2EN_R;
75pub use AFIOEN_R as TIM1EN_R;
77pub use AFIOEN_R as SPI1EN_R;
79pub use AFIOEN_R as USART1EN_R;
81pub use AFIOEN_W as IOPAEN_W;
83pub use AFIOEN_W as IOPBEN_W;
85pub use AFIOEN_W as IOPCEN_W;
87pub use AFIOEN_W as IOPDEN_W;
89pub use AFIOEN_W as IOPEEN_W;
91pub use AFIOEN_W as ADC1EN_W;
93pub use AFIOEN_W as ADC2EN_W;
95pub use AFIOEN_W as TIM1EN_W;
97pub use AFIOEN_W as SPI1EN_W;
99pub use AFIOEN_W as USART1EN_W;
101impl R {
102 #[inline(always)]
104 pub fn afioen(&self) -> AFIOEN_R {
105 AFIOEN_R::new((self.bits & 1) != 0)
106 }
107 #[inline(always)]
109 pub fn iopaen(&self) -> IOPAEN_R {
110 IOPAEN_R::new(((self.bits >> 2) & 1) != 0)
111 }
112 #[inline(always)]
114 pub fn iopben(&self) -> IOPBEN_R {
115 IOPBEN_R::new(((self.bits >> 3) & 1) != 0)
116 }
117 #[inline(always)]
119 pub fn iopcen(&self) -> IOPCEN_R {
120 IOPCEN_R::new(((self.bits >> 4) & 1) != 0)
121 }
122 #[inline(always)]
124 pub fn iopden(&self) -> IOPDEN_R {
125 IOPDEN_R::new(((self.bits >> 5) & 1) != 0)
126 }
127 #[inline(always)]
129 pub fn iopeen(&self) -> IOPEEN_R {
130 IOPEEN_R::new(((self.bits >> 6) & 1) != 0)
131 }
132 #[inline(always)]
134 pub fn adc1en(&self) -> ADC1EN_R {
135 ADC1EN_R::new(((self.bits >> 9) & 1) != 0)
136 }
137 #[inline(always)]
139 pub fn adc2en(&self) -> ADC2EN_R {
140 ADC2EN_R::new(((self.bits >> 10) & 1) != 0)
141 }
142 #[inline(always)]
144 pub fn tim1en(&self) -> TIM1EN_R {
145 TIM1EN_R::new(((self.bits >> 11) & 1) != 0)
146 }
147 #[inline(always)]
149 pub fn spi1en(&self) -> SPI1EN_R {
150 SPI1EN_R::new(((self.bits >> 12) & 1) != 0)
151 }
152 #[inline(always)]
154 pub fn usart1en(&self) -> USART1EN_R {
155 USART1EN_R::new(((self.bits >> 14) & 1) != 0)
156 }
157}
158impl core::fmt::Debug for R {
159 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
160 f.debug_struct("APB2ENR")
161 .field("afioen", &self.afioen())
162 .field("iopaen", &self.iopaen())
163 .field("iopben", &self.iopben())
164 .field("iopcen", &self.iopcen())
165 .field("iopden", &self.iopden())
166 .field("iopeen", &self.iopeen())
167 .field("adc1en", &self.adc1en())
168 .field("adc2en", &self.adc2en())
169 .field("tim1en", &self.tim1en())
170 .field("spi1en", &self.spi1en())
171 .field("usart1en", &self.usart1en())
172 .finish()
173 }
174}
175impl W {
176 #[inline(always)]
178 pub fn afioen(&mut self) -> AFIOEN_W<APB2ENRrs> {
179 AFIOEN_W::new(self, 0)
180 }
181 #[inline(always)]
183 pub fn iopaen(&mut self) -> IOPAEN_W<APB2ENRrs> {
184 IOPAEN_W::new(self, 2)
185 }
186 #[inline(always)]
188 pub fn iopben(&mut self) -> IOPBEN_W<APB2ENRrs> {
189 IOPBEN_W::new(self, 3)
190 }
191 #[inline(always)]
193 pub fn iopcen(&mut self) -> IOPCEN_W<APB2ENRrs> {
194 IOPCEN_W::new(self, 4)
195 }
196 #[inline(always)]
198 pub fn iopden(&mut self) -> IOPDEN_W<APB2ENRrs> {
199 IOPDEN_W::new(self, 5)
200 }
201 #[inline(always)]
203 pub fn iopeen(&mut self) -> IOPEEN_W<APB2ENRrs> {
204 IOPEEN_W::new(self, 6)
205 }
206 #[inline(always)]
208 pub fn adc1en(&mut self) -> ADC1EN_W<APB2ENRrs> {
209 ADC1EN_W::new(self, 9)
210 }
211 #[inline(always)]
213 pub fn adc2en(&mut self) -> ADC2EN_W<APB2ENRrs> {
214 ADC2EN_W::new(self, 10)
215 }
216 #[inline(always)]
218 pub fn tim1en(&mut self) -> TIM1EN_W<APB2ENRrs> {
219 TIM1EN_W::new(self, 11)
220 }
221 #[inline(always)]
223 pub fn spi1en(&mut self) -> SPI1EN_W<APB2ENRrs> {
224 SPI1EN_W::new(self, 12)
225 }
226 #[inline(always)]
228 pub fn usart1en(&mut self) -> USART1EN_W<APB2ENRrs> {
229 USART1EN_W::new(self, 14)
230 }
231}
232pub struct APB2ENRrs;
238impl crate::RegisterSpec for APB2ENRrs {
239 type Ux = u32;
240}
241impl crate::Readable for APB2ENRrs {}
243impl crate::Writable for APB2ENRrs {
245 type Safety = crate::Unsafe;
246}
247impl crate::Resettable for APB2ENRrs {}