stm32u5/stm32u585/gpioa/afrl.rs
1///Register `AFRL` reader
2pub type R = crate::R<AFRLrs>;
3///Register `AFRL` writer
4pub type W = crate::W<AFRLrs>;
5/**Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u8)]
11pub enum ALTERNATE_FUNCTION {
12 ///0: AF0
13 Af0 = 0,
14 ///1: AF1
15 Af1 = 1,
16 ///2: AF2
17 Af2 = 2,
18 ///3: AF3
19 Af3 = 3,
20 ///4: AF4
21 Af4 = 4,
22 ///5: AF5
23 Af5 = 5,
24 ///6: AF6
25 Af6 = 6,
26 ///7: AF7
27 Af7 = 7,
28 ///8: AF8
29 Af8 = 8,
30 ///9: AF9
31 Af9 = 9,
32 ///10: AF10
33 Af10 = 10,
34 ///11: AF11
35 Af11 = 11,
36 ///12: AF12
37 Af12 = 12,
38 ///13: AF13
39 Af13 = 13,
40 ///14: AF14
41 Af14 = 14,
42 ///15: AF15
43 Af15 = 15,
44}
45impl From<ALTERNATE_FUNCTION> for u8 {
46 #[inline(always)]
47 fn from(variant: ALTERNATE_FUNCTION) -> Self {
48 variant as _
49 }
50}
51impl crate::FieldSpec for ALTERNATE_FUNCTION {
52 type Ux = u8;
53}
54impl crate::IsEnum for ALTERNATE_FUNCTION {}
55///Field `AFR(EL0,EL1,EL2,EL3,EL4,EL5,EL6,EL7)` reader - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
56pub type AFR_R = crate::FieldReader<ALTERNATE_FUNCTION>;
57impl AFR_R {
58 ///Get enumerated values variant
59 #[inline(always)]
60 pub const fn variant(&self) -> ALTERNATE_FUNCTION {
61 match self.bits {
62 0 => ALTERNATE_FUNCTION::Af0,
63 1 => ALTERNATE_FUNCTION::Af1,
64 2 => ALTERNATE_FUNCTION::Af2,
65 3 => ALTERNATE_FUNCTION::Af3,
66 4 => ALTERNATE_FUNCTION::Af4,
67 5 => ALTERNATE_FUNCTION::Af5,
68 6 => ALTERNATE_FUNCTION::Af6,
69 7 => ALTERNATE_FUNCTION::Af7,
70 8 => ALTERNATE_FUNCTION::Af8,
71 9 => ALTERNATE_FUNCTION::Af9,
72 10 => ALTERNATE_FUNCTION::Af10,
73 11 => ALTERNATE_FUNCTION::Af11,
74 12 => ALTERNATE_FUNCTION::Af12,
75 13 => ALTERNATE_FUNCTION::Af13,
76 14 => ALTERNATE_FUNCTION::Af14,
77 15 => ALTERNATE_FUNCTION::Af15,
78 _ => unreachable!(),
79 }
80 }
81 ///AF0
82 #[inline(always)]
83 pub fn is_af0(&self) -> bool {
84 *self == ALTERNATE_FUNCTION::Af0
85 }
86 ///AF1
87 #[inline(always)]
88 pub fn is_af1(&self) -> bool {
89 *self == ALTERNATE_FUNCTION::Af1
90 }
91 ///AF2
92 #[inline(always)]
93 pub fn is_af2(&self) -> bool {
94 *self == ALTERNATE_FUNCTION::Af2
95 }
96 ///AF3
97 #[inline(always)]
98 pub fn is_af3(&self) -> bool {
99 *self == ALTERNATE_FUNCTION::Af3
100 }
101 ///AF4
102 #[inline(always)]
103 pub fn is_af4(&self) -> bool {
104 *self == ALTERNATE_FUNCTION::Af4
105 }
106 ///AF5
107 #[inline(always)]
108 pub fn is_af5(&self) -> bool {
109 *self == ALTERNATE_FUNCTION::Af5
110 }
111 ///AF6
112 #[inline(always)]
113 pub fn is_af6(&self) -> bool {
114 *self == ALTERNATE_FUNCTION::Af6
115 }
116 ///AF7
117 #[inline(always)]
118 pub fn is_af7(&self) -> bool {
119 *self == ALTERNATE_FUNCTION::Af7
120 }
121 ///AF8
122 #[inline(always)]
123 pub fn is_af8(&self) -> bool {
124 *self == ALTERNATE_FUNCTION::Af8
125 }
126 ///AF9
127 #[inline(always)]
128 pub fn is_af9(&self) -> bool {
129 *self == ALTERNATE_FUNCTION::Af9
130 }
131 ///AF10
132 #[inline(always)]
133 pub fn is_af10(&self) -> bool {
134 *self == ALTERNATE_FUNCTION::Af10
135 }
136 ///AF11
137 #[inline(always)]
138 pub fn is_af11(&self) -> bool {
139 *self == ALTERNATE_FUNCTION::Af11
140 }
141 ///AF12
142 #[inline(always)]
143 pub fn is_af12(&self) -> bool {
144 *self == ALTERNATE_FUNCTION::Af12
145 }
146 ///AF13
147 #[inline(always)]
148 pub fn is_af13(&self) -> bool {
149 *self == ALTERNATE_FUNCTION::Af13
150 }
151 ///AF14
152 #[inline(always)]
153 pub fn is_af14(&self) -> bool {
154 *self == ALTERNATE_FUNCTION::Af14
155 }
156 ///AF15
157 #[inline(always)]
158 pub fn is_af15(&self) -> bool {
159 *self == ALTERNATE_FUNCTION::Af15
160 }
161}
162///Field `AFR(EL0,EL1,EL2,EL3,EL4,EL5,EL6,EL7)` writer - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
163pub type AFR_W<'a, REG> = crate::FieldWriter<'a, REG, 4, ALTERNATE_FUNCTION, crate::Safe>;
164impl<'a, REG> AFR_W<'a, REG>
165where
166 REG: crate::Writable + crate::RegisterSpec,
167 REG::Ux: From<u8>,
168{
169 ///AF0
170 #[inline(always)]
171 pub fn af0(self) -> &'a mut crate::W<REG> {
172 self.variant(ALTERNATE_FUNCTION::Af0)
173 }
174 ///AF1
175 #[inline(always)]
176 pub fn af1(self) -> &'a mut crate::W<REG> {
177 self.variant(ALTERNATE_FUNCTION::Af1)
178 }
179 ///AF2
180 #[inline(always)]
181 pub fn af2(self) -> &'a mut crate::W<REG> {
182 self.variant(ALTERNATE_FUNCTION::Af2)
183 }
184 ///AF3
185 #[inline(always)]
186 pub fn af3(self) -> &'a mut crate::W<REG> {
187 self.variant(ALTERNATE_FUNCTION::Af3)
188 }
189 ///AF4
190 #[inline(always)]
191 pub fn af4(self) -> &'a mut crate::W<REG> {
192 self.variant(ALTERNATE_FUNCTION::Af4)
193 }
194 ///AF5
195 #[inline(always)]
196 pub fn af5(self) -> &'a mut crate::W<REG> {
197 self.variant(ALTERNATE_FUNCTION::Af5)
198 }
199 ///AF6
200 #[inline(always)]
201 pub fn af6(self) -> &'a mut crate::W<REG> {
202 self.variant(ALTERNATE_FUNCTION::Af6)
203 }
204 ///AF7
205 #[inline(always)]
206 pub fn af7(self) -> &'a mut crate::W<REG> {
207 self.variant(ALTERNATE_FUNCTION::Af7)
208 }
209 ///AF8
210 #[inline(always)]
211 pub fn af8(self) -> &'a mut crate::W<REG> {
212 self.variant(ALTERNATE_FUNCTION::Af8)
213 }
214 ///AF9
215 #[inline(always)]
216 pub fn af9(self) -> &'a mut crate::W<REG> {
217 self.variant(ALTERNATE_FUNCTION::Af9)
218 }
219 ///AF10
220 #[inline(always)]
221 pub fn af10(self) -> &'a mut crate::W<REG> {
222 self.variant(ALTERNATE_FUNCTION::Af10)
223 }
224 ///AF11
225 #[inline(always)]
226 pub fn af11(self) -> &'a mut crate::W<REG> {
227 self.variant(ALTERNATE_FUNCTION::Af11)
228 }
229 ///AF12
230 #[inline(always)]
231 pub fn af12(self) -> &'a mut crate::W<REG> {
232 self.variant(ALTERNATE_FUNCTION::Af12)
233 }
234 ///AF13
235 #[inline(always)]
236 pub fn af13(self) -> &'a mut crate::W<REG> {
237 self.variant(ALTERNATE_FUNCTION::Af13)
238 }
239 ///AF14
240 #[inline(always)]
241 pub fn af14(self) -> &'a mut crate::W<REG> {
242 self.variant(ALTERNATE_FUNCTION::Af14)
243 }
244 ///AF15
245 #[inline(always)]
246 pub fn af15(self) -> &'a mut crate::W<REG> {
247 self.variant(ALTERNATE_FUNCTION::Af15)
248 }
249}
250impl R {
251 ///Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
252 ///
253 ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `AFREL0` field.</div>
254 #[inline(always)]
255 pub fn afr(&self, n: u8) -> AFR_R {
256 #[allow(clippy::no_effect)]
257 [(); 8][n as usize];
258 AFR_R::new(((self.bits >> (n * 4)) & 0x0f) as u8)
259 }
260 ///Iterator for array of:
261 ///Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
262 #[inline(always)]
263 pub fn afr_iter(&self) -> impl Iterator<Item = AFR_R> + '_ {
264 (0..8).map(move |n| AFR_R::new(((self.bits >> (n * 4)) & 0x0f) as u8))
265 }
266 ///Bits 0:3 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
267 #[inline(always)]
268 pub fn afrel0(&self) -> AFR_R {
269 AFR_R::new((self.bits & 0x0f) as u8)
270 }
271 ///Bits 4:7 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
272 #[inline(always)]
273 pub fn afrel1(&self) -> AFR_R {
274 AFR_R::new(((self.bits >> 4) & 0x0f) as u8)
275 }
276 ///Bits 8:11 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
277 #[inline(always)]
278 pub fn afrel2(&self) -> AFR_R {
279 AFR_R::new(((self.bits >> 8) & 0x0f) as u8)
280 }
281 ///Bits 12:15 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
282 #[inline(always)]
283 pub fn afrel3(&self) -> AFR_R {
284 AFR_R::new(((self.bits >> 12) & 0x0f) as u8)
285 }
286 ///Bits 16:19 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
287 #[inline(always)]
288 pub fn afrel4(&self) -> AFR_R {
289 AFR_R::new(((self.bits >> 16) & 0x0f) as u8)
290 }
291 ///Bits 20:23 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
292 #[inline(always)]
293 pub fn afrel5(&self) -> AFR_R {
294 AFR_R::new(((self.bits >> 20) & 0x0f) as u8)
295 }
296 ///Bits 24:27 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
297 #[inline(always)]
298 pub fn afrel6(&self) -> AFR_R {
299 AFR_R::new(((self.bits >> 24) & 0x0f) as u8)
300 }
301 ///Bits 28:31 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
302 #[inline(always)]
303 pub fn afrel7(&self) -> AFR_R {
304 AFR_R::new(((self.bits >> 28) & 0x0f) as u8)
305 }
306}
307impl core::fmt::Debug for R {
308 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
309 f.debug_struct("AFRL")
310 .field("afrel0", &self.afrel0())
311 .field("afrel1", &self.afrel1())
312 .field("afrel2", &self.afrel2())
313 .field("afrel3", &self.afrel3())
314 .field("afrel4", &self.afrel4())
315 .field("afrel5", &self.afrel5())
316 .field("afrel6", &self.afrel6())
317 .field("afrel7", &self.afrel7())
318 .finish()
319 }
320}
321impl W {
322 ///Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
323 ///
324 ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `AFREL0` field.</div>
325 #[inline(always)]
326 pub fn afr(&mut self, n: u8) -> AFR_W<AFRLrs> {
327 #[allow(clippy::no_effect)]
328 [(); 8][n as usize];
329 AFR_W::new(self, n * 4)
330 }
331 ///Bits 0:3 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
332 #[inline(always)]
333 pub fn afrel0(&mut self) -> AFR_W<AFRLrs> {
334 AFR_W::new(self, 0)
335 }
336 ///Bits 4:7 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
337 #[inline(always)]
338 pub fn afrel1(&mut self) -> AFR_W<AFRLrs> {
339 AFR_W::new(self, 4)
340 }
341 ///Bits 8:11 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
342 #[inline(always)]
343 pub fn afrel2(&mut self) -> AFR_W<AFRLrs> {
344 AFR_W::new(self, 8)
345 }
346 ///Bits 12:15 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
347 #[inline(always)]
348 pub fn afrel3(&mut self) -> AFR_W<AFRLrs> {
349 AFR_W::new(self, 12)
350 }
351 ///Bits 16:19 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
352 #[inline(always)]
353 pub fn afrel4(&mut self) -> AFR_W<AFRLrs> {
354 AFR_W::new(self, 16)
355 }
356 ///Bits 20:23 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
357 #[inline(always)]
358 pub fn afrel5(&mut self) -> AFR_W<AFRLrs> {
359 AFR_W::new(self, 20)
360 }
361 ///Bits 24:27 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
362 #[inline(always)]
363 pub fn afrel6(&mut self) -> AFR_W<AFRLrs> {
364 AFR_W::new(self, 24)
365 }
366 ///Bits 28:31 - Alternate function selection for port x I/O pin y These bits are written by software to configure alternate function I/Os. Note: This field is reserved and must be kept at reset value when the corresponding I/O is not available on the selected package.
367 #[inline(always)]
368 pub fn afrel7(&mut self) -> AFR_W<AFRLrs> {
369 AFR_W::new(self, 28)
370 }
371}
372/**GPIO alternate function low register
373
374You can [`read`](crate::Reg::read) this register and get [`afrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`afrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
375
376See register [structure](https://stm32-rs.github.io/stm32-rs/STM32U585.html#GPIOA:AFRL)*/
377pub struct AFRLrs;
378impl crate::RegisterSpec for AFRLrs {
379 type Ux = u32;
380}
381///`read()` method returns [`afrl::R`](R) reader structure
382impl crate::Readable for AFRLrs {}
383///`write(|w| ..)` method takes [`afrl::W`](W) writer structure
384impl crate::Writable for AFRLrs {
385 type Safety = crate::Unsafe;
386}
387///`reset()` method sets AFRL to value 0
388impl crate::Resettable for AFRLrs {}