stm32f1_staging/stm32f102/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 ADC1EN_R;
71pub use AFIOEN_R as SPI1EN_R;
73pub use AFIOEN_R as USART1EN_R;
75pub use AFIOEN_W as IOPAEN_W;
77pub use AFIOEN_W as IOPBEN_W;
79pub use AFIOEN_W as IOPCEN_W;
81pub use AFIOEN_W as IOPDEN_W;
83pub use AFIOEN_W as ADC1EN_W;
85pub use AFIOEN_W as SPI1EN_W;
87pub use AFIOEN_W as USART1EN_W;
89impl R {
90 #[inline(always)]
92 pub fn afioen(&self) -> AFIOEN_R {
93 AFIOEN_R::new((self.bits & 1) != 0)
94 }
95 #[inline(always)]
97 pub fn iopaen(&self) -> IOPAEN_R {
98 IOPAEN_R::new(((self.bits >> 2) & 1) != 0)
99 }
100 #[inline(always)]
102 pub fn iopben(&self) -> IOPBEN_R {
103 IOPBEN_R::new(((self.bits >> 3) & 1) != 0)
104 }
105 #[inline(always)]
107 pub fn iopcen(&self) -> IOPCEN_R {
108 IOPCEN_R::new(((self.bits >> 4) & 1) != 0)
109 }
110 #[inline(always)]
112 pub fn iopden(&self) -> IOPDEN_R {
113 IOPDEN_R::new(((self.bits >> 5) & 1) != 0)
114 }
115 #[inline(always)]
117 pub fn adc1en(&self) -> ADC1EN_R {
118 ADC1EN_R::new(((self.bits >> 9) & 1) != 0)
119 }
120 #[inline(always)]
122 pub fn spi1en(&self) -> SPI1EN_R {
123 SPI1EN_R::new(((self.bits >> 12) & 1) != 0)
124 }
125 #[inline(always)]
127 pub fn usart1en(&self) -> USART1EN_R {
128 USART1EN_R::new(((self.bits >> 14) & 1) != 0)
129 }
130}
131impl core::fmt::Debug for R {
132 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
133 f.debug_struct("APB2ENR")
134 .field("afioen", &self.afioen())
135 .field("iopaen", &self.iopaen())
136 .field("iopben", &self.iopben())
137 .field("iopcen", &self.iopcen())
138 .field("iopden", &self.iopden())
139 .field("adc1en", &self.adc1en())
140 .field("spi1en", &self.spi1en())
141 .field("usart1en", &self.usart1en())
142 .finish()
143 }
144}
145impl W {
146 #[inline(always)]
148 pub fn afioen(&mut self) -> AFIOEN_W<APB2ENRrs> {
149 AFIOEN_W::new(self, 0)
150 }
151 #[inline(always)]
153 pub fn iopaen(&mut self) -> IOPAEN_W<APB2ENRrs> {
154 IOPAEN_W::new(self, 2)
155 }
156 #[inline(always)]
158 pub fn iopben(&mut self) -> IOPBEN_W<APB2ENRrs> {
159 IOPBEN_W::new(self, 3)
160 }
161 #[inline(always)]
163 pub fn iopcen(&mut self) -> IOPCEN_W<APB2ENRrs> {
164 IOPCEN_W::new(self, 4)
165 }
166 #[inline(always)]
168 pub fn iopden(&mut self) -> IOPDEN_W<APB2ENRrs> {
169 IOPDEN_W::new(self, 5)
170 }
171 #[inline(always)]
173 pub fn adc1en(&mut self) -> ADC1EN_W<APB2ENRrs> {
174 ADC1EN_W::new(self, 9)
175 }
176 #[inline(always)]
178 pub fn spi1en(&mut self) -> SPI1EN_W<APB2ENRrs> {
179 SPI1EN_W::new(self, 12)
180 }
181 #[inline(always)]
183 pub fn usart1en(&mut self) -> USART1EN_W<APB2ENRrs> {
184 USART1EN_W::new(self, 14)
185 }
186}
187pub struct APB2ENRrs;
193impl crate::RegisterSpec for APB2ENRrs {
194 type Ux = u32;
195}
196impl crate::Readable for APB2ENRrs {}
198impl crate::Writable for APB2ENRrs {
200 type Safety = crate::Unsafe;
201}
202impl crate::Resettable for APB2ENRrs {}