stm32f1_staging/stm32f107/gpioa/
crl.rs1pub type R = crate::R<CRLrs>;
3pub type W = crate::W<CRLrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u8)]
11pub enum MODE {
12 Input = 0,
14 Output = 1,
16 Output2 = 2,
18 Output50 = 3,
20}
21impl From<MODE> for u8 {
22 #[inline(always)]
23 fn from(variant: MODE) -> Self {
24 variant as _
25 }
26}
27impl crate::FieldSpec for MODE {
28 type Ux = u8;
29}
30impl crate::IsEnum for MODE {}
31pub type MODE_R = crate::FieldReader<MODE>;
33impl MODE_R {
34 #[inline(always)]
36 pub const fn variant(&self) -> MODE {
37 match self.bits {
38 0 => MODE::Input,
39 1 => MODE::Output,
40 2 => MODE::Output2,
41 3 => MODE::Output50,
42 _ => unreachable!(),
43 }
44 }
45 #[inline(always)]
47 pub fn is_input(&self) -> bool {
48 *self == MODE::Input
49 }
50 #[inline(always)]
52 pub fn is_output(&self) -> bool {
53 *self == MODE::Output
54 }
55 #[inline(always)]
57 pub fn is_output2(&self) -> bool {
58 *self == MODE::Output2
59 }
60 #[inline(always)]
62 pub fn is_output50(&self) -> bool {
63 *self == MODE::Output50
64 }
65}
66pub type MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE, crate::Safe>;
68impl<'a, REG> MODE_W<'a, REG>
69where
70 REG: crate::Writable + crate::RegisterSpec,
71 REG::Ux: From<u8>,
72{
73 #[inline(always)]
75 pub fn input(self) -> &'a mut crate::W<REG> {
76 self.variant(MODE::Input)
77 }
78 #[inline(always)]
80 pub fn output(self) -> &'a mut crate::W<REG> {
81 self.variant(MODE::Output)
82 }
83 #[inline(always)]
85 pub fn output2(self) -> &'a mut crate::W<REG> {
86 self.variant(MODE::Output2)
87 }
88 #[inline(always)]
90 pub fn output50(self) -> &'a mut crate::W<REG> {
91 self.variant(MODE::Output50)
92 }
93}
94#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99#[repr(u8)]
100pub enum CONFIG {
101 PushPull = 0,
103 OpenDrain = 1,
105 AltPushPull = 2,
107 AltOpenDrain = 3,
109}
110impl From<CONFIG> for u8 {
111 #[inline(always)]
112 fn from(variant: CONFIG) -> Self {
113 variant as _
114 }
115}
116impl crate::FieldSpec for CONFIG {
117 type Ux = u8;
118}
119impl crate::IsEnum for CONFIG {}
120pub type CNF_R = crate::FieldReader<CONFIG>;
122impl CNF_R {
123 #[inline(always)]
125 pub const fn variant(&self) -> CONFIG {
126 match self.bits {
127 0 => CONFIG::PushPull,
128 1 => CONFIG::OpenDrain,
129 2 => CONFIG::AltPushPull,
130 3 => CONFIG::AltOpenDrain,
131 _ => unreachable!(),
132 }
133 }
134 #[inline(always)]
136 pub fn is_push_pull(&self) -> bool {
137 *self == CONFIG::PushPull
138 }
139 #[inline(always)]
141 pub fn is_open_drain(&self) -> bool {
142 *self == CONFIG::OpenDrain
143 }
144 #[inline(always)]
146 pub fn is_alt_push_pull(&self) -> bool {
147 *self == CONFIG::AltPushPull
148 }
149 #[inline(always)]
151 pub fn is_alt_open_drain(&self) -> bool {
152 *self == CONFIG::AltOpenDrain
153 }
154}
155pub type CNF_W<'a, REG> = crate::FieldWriter<'a, REG, 2, CONFIG, crate::Safe>;
157impl<'a, REG> CNF_W<'a, REG>
158where
159 REG: crate::Writable + crate::RegisterSpec,
160 REG::Ux: From<u8>,
161{
162 #[inline(always)]
164 pub fn push_pull(self) -> &'a mut crate::W<REG> {
165 self.variant(CONFIG::PushPull)
166 }
167 #[inline(always)]
169 pub fn open_drain(self) -> &'a mut crate::W<REG> {
170 self.variant(CONFIG::OpenDrain)
171 }
172 #[inline(always)]
174 pub fn alt_push_pull(self) -> &'a mut crate::W<REG> {
175 self.variant(CONFIG::AltPushPull)
176 }
177 #[inline(always)]
179 pub fn alt_open_drain(self) -> &'a mut crate::W<REG> {
180 self.variant(CONFIG::AltOpenDrain)
181 }
182}
183impl R {
184 #[inline(always)]
188 pub fn mode(&self, n: u8) -> MODE_R {
189 #[allow(clippy::no_effect)] [(); 8][n as usize];
190 MODE_R::new(((self.bits >> (n * 4)) & 3) as u8)
191 }
192 #[inline(always)]
195 pub fn mode_iter(&self) -> impl Iterator<Item = MODE_R> + '_ {
196 (0..8).map(move |n| MODE_R::new(((self.bits >> (n * 4)) & 3) as u8))
197 }
198 #[inline(always)]
200 pub fn mode0(&self) -> MODE_R {
201 MODE_R::new((self.bits & 3) as u8)
202 }
203 #[inline(always)]
205 pub fn mode1(&self) -> MODE_R {
206 MODE_R::new(((self.bits >> 4) & 3) as u8)
207 }
208 #[inline(always)]
210 pub fn mode2(&self) -> MODE_R {
211 MODE_R::new(((self.bits >> 8) & 3) as u8)
212 }
213 #[inline(always)]
215 pub fn mode3(&self) -> MODE_R {
216 MODE_R::new(((self.bits >> 12) & 3) as u8)
217 }
218 #[inline(always)]
220 pub fn mode4(&self) -> MODE_R {
221 MODE_R::new(((self.bits >> 16) & 3) as u8)
222 }
223 #[inline(always)]
225 pub fn mode5(&self) -> MODE_R {
226 MODE_R::new(((self.bits >> 20) & 3) as u8)
227 }
228 #[inline(always)]
230 pub fn mode6(&self) -> MODE_R {
231 MODE_R::new(((self.bits >> 24) & 3) as u8)
232 }
233 #[inline(always)]
235 pub fn mode7(&self) -> MODE_R {
236 MODE_R::new(((self.bits >> 28) & 3) as u8)
237 }
238 #[inline(always)]
242 pub fn cnf(&self, n: u8) -> CNF_R {
243 #[allow(clippy::no_effect)] [(); 8][n as usize];
244 CNF_R::new(((self.bits >> (n * 4 + 2)) & 3) as u8)
245 }
246 #[inline(always)]
249 pub fn cnf_iter(&self) -> impl Iterator<Item = CNF_R> + '_ {
250 (0..8).map(move |n| CNF_R::new(((self.bits >> (n * 4 + 2)) & 3) as u8))
251 }
252 #[inline(always)]
254 pub fn cnf0(&self) -> CNF_R {
255 CNF_R::new(((self.bits >> 2) & 3) as u8)
256 }
257 #[inline(always)]
259 pub fn cnf1(&self) -> CNF_R {
260 CNF_R::new(((self.bits >> 6) & 3) as u8)
261 }
262 #[inline(always)]
264 pub fn cnf2(&self) -> CNF_R {
265 CNF_R::new(((self.bits >> 10) & 3) as u8)
266 }
267 #[inline(always)]
269 pub fn cnf3(&self) -> CNF_R {
270 CNF_R::new(((self.bits >> 14) & 3) as u8)
271 }
272 #[inline(always)]
274 pub fn cnf4(&self) -> CNF_R {
275 CNF_R::new(((self.bits >> 18) & 3) as u8)
276 }
277 #[inline(always)]
279 pub fn cnf5(&self) -> CNF_R {
280 CNF_R::new(((self.bits >> 22) & 3) as u8)
281 }
282 #[inline(always)]
284 pub fn cnf6(&self) -> CNF_R {
285 CNF_R::new(((self.bits >> 26) & 3) as u8)
286 }
287 #[inline(always)]
289 pub fn cnf7(&self) -> CNF_R {
290 CNF_R::new(((self.bits >> 30) & 3) as u8)
291 }
292}
293impl core::fmt::Debug for R {
294 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
295 f.debug_struct("CRL")
296 .field("mode0", &self.mode0())
297 .field("mode1", &self.mode1())
298 .field("mode2", &self.mode2())
299 .field("mode3", &self.mode3())
300 .field("mode4", &self.mode4())
301 .field("mode5", &self.mode5())
302 .field("mode6", &self.mode6())
303 .field("mode7", &self.mode7())
304 .field("cnf0", &self.cnf0())
305 .field("cnf1", &self.cnf1())
306 .field("cnf2", &self.cnf2())
307 .field("cnf3", &self.cnf3())
308 .field("cnf4", &self.cnf4())
309 .field("cnf5", &self.cnf5())
310 .field("cnf6", &self.cnf6())
311 .field("cnf7", &self.cnf7())
312 .finish()
313 }
314}
315impl W {
316 #[inline(always)]
320 pub fn mode(&mut self, n: u8) -> MODE_W<CRLrs> {
321 #[allow(clippy::no_effect)] [(); 8][n as usize];
322 MODE_W::new(self, n * 4)
323 }
324 #[inline(always)]
326 pub fn mode0(&mut self) -> MODE_W<CRLrs> {
327 MODE_W::new(self, 0)
328 }
329 #[inline(always)]
331 pub fn mode1(&mut self) -> MODE_W<CRLrs> {
332 MODE_W::new(self, 4)
333 }
334 #[inline(always)]
336 pub fn mode2(&mut self) -> MODE_W<CRLrs> {
337 MODE_W::new(self, 8)
338 }
339 #[inline(always)]
341 pub fn mode3(&mut self) -> MODE_W<CRLrs> {
342 MODE_W::new(self, 12)
343 }
344 #[inline(always)]
346 pub fn mode4(&mut self) -> MODE_W<CRLrs> {
347 MODE_W::new(self, 16)
348 }
349 #[inline(always)]
351 pub fn mode5(&mut self) -> MODE_W<CRLrs> {
352 MODE_W::new(self, 20)
353 }
354 #[inline(always)]
356 pub fn mode6(&mut self) -> MODE_W<CRLrs> {
357 MODE_W::new(self, 24)
358 }
359 #[inline(always)]
361 pub fn mode7(&mut self) -> MODE_W<CRLrs> {
362 MODE_W::new(self, 28)
363 }
364 #[inline(always)]
368 pub fn cnf(&mut self, n: u8) -> CNF_W<CRLrs> {
369 #[allow(clippy::no_effect)] [(); 8][n as usize];
370 CNF_W::new(self, n * 4 + 2)
371 }
372 #[inline(always)]
374 pub fn cnf0(&mut self) -> CNF_W<CRLrs> {
375 CNF_W::new(self, 2)
376 }
377 #[inline(always)]
379 pub fn cnf1(&mut self) -> CNF_W<CRLrs> {
380 CNF_W::new(self, 6)
381 }
382 #[inline(always)]
384 pub fn cnf2(&mut self) -> CNF_W<CRLrs> {
385 CNF_W::new(self, 10)
386 }
387 #[inline(always)]
389 pub fn cnf3(&mut self) -> CNF_W<CRLrs> {
390 CNF_W::new(self, 14)
391 }
392 #[inline(always)]
394 pub fn cnf4(&mut self) -> CNF_W<CRLrs> {
395 CNF_W::new(self, 18)
396 }
397 #[inline(always)]
399 pub fn cnf5(&mut self) -> CNF_W<CRLrs> {
400 CNF_W::new(self, 22)
401 }
402 #[inline(always)]
404 pub fn cnf6(&mut self) -> CNF_W<CRLrs> {
405 CNF_W::new(self, 26)
406 }
407 #[inline(always)]
409 pub fn cnf7(&mut self) -> CNF_W<CRLrs> {
410 CNF_W::new(self, 30)
411 }
412}
413pub struct CRLrs;
419impl crate::RegisterSpec for CRLrs {
420 type Ux = u32;
421}
422impl crate::Readable for CRLrs {}
424impl crate::Writable for CRLrs {
426 type Safety = crate::Unsafe;
427}
428impl crate::Resettable for CRLrs {
430 const RESET_VALUE: u32 = 0x4444_4444;
431}