ambiq_apollo2_pac/gpio/
cfgg.rs1#[doc = "Reader of register CFGG"]
2pub type R = crate::R<u32, super::CFGG>;
3#[doc = "Writer for register CFGG"]
4pub type W = crate::W<u32, super::CFGG>;
5#[doc = "Register CFGG `reset()`'s with value 0"]
6impl crate::ResetValue for super::CFGG {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "GPIO49 interrupt direction.\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum GPIO49INTD_A {
16 #[doc = "0: Interrupt on low to high GPIO transition"]
17 INTLH = 0,
18 #[doc = "1: Interrupt on high to low GPIO transition"]
19 INTHL = 1,
20}
21impl From<GPIO49INTD_A> for bool {
22 #[inline(always)]
23 fn from(variant: GPIO49INTD_A) -> Self {
24 variant as u8 != 0
25 }
26}
27#[doc = "Reader of field `GPIO49INTD`"]
28pub type GPIO49INTD_R = crate::R<bool, GPIO49INTD_A>;
29impl GPIO49INTD_R {
30 #[doc = r"Get enumerated values variant"]
31 #[inline(always)]
32 pub fn variant(&self) -> GPIO49INTD_A {
33 match self.bits {
34 false => GPIO49INTD_A::INTLH,
35 true => GPIO49INTD_A::INTHL,
36 }
37 }
38 #[doc = "Checks if the value of the field is `INTLH`"]
39 #[inline(always)]
40 pub fn is_intlh(&self) -> bool {
41 *self == GPIO49INTD_A::INTLH
42 }
43 #[doc = "Checks if the value of the field is `INTHL`"]
44 #[inline(always)]
45 pub fn is_inthl(&self) -> bool {
46 *self == GPIO49INTD_A::INTHL
47 }
48}
49#[doc = "Write proxy for field `GPIO49INTD`"]
50pub struct GPIO49INTD_W<'a> {
51 w: &'a mut W,
52}
53impl<'a> GPIO49INTD_W<'a> {
54 #[doc = r"Writes `variant` to the field"]
55 #[inline(always)]
56 pub fn variant(self, variant: GPIO49INTD_A) -> &'a mut W {
57 {
58 self.bit(variant.into())
59 }
60 }
61 #[doc = "Interrupt on low to high GPIO transition"]
62 #[inline(always)]
63 pub fn intlh(self) -> &'a mut W {
64 self.variant(GPIO49INTD_A::INTLH)
65 }
66 #[doc = "Interrupt on high to low GPIO transition"]
67 #[inline(always)]
68 pub fn inthl(self) -> &'a mut W {
69 self.variant(GPIO49INTD_A::INTHL)
70 }
71 #[doc = r"Sets the field bit"]
72 #[inline(always)]
73 pub fn set_bit(self) -> &'a mut W {
74 self.bit(true)
75 }
76 #[doc = r"Clears the field bit"]
77 #[inline(always)]
78 pub fn clear_bit(self) -> &'a mut W {
79 self.bit(false)
80 }
81 #[doc = r"Writes raw bits to the field"]
82 #[inline(always)]
83 pub fn bit(self, value: bool) -> &'a mut W {
84 self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
85 self.w
86 }
87}
88#[doc = "GPIO49 output configuration.\n\nValue on reset: 0"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90#[repr(u8)]
91pub enum GPIO49OUTCFG_A {
92 #[doc = "0: Output disabled"]
93 DIS = 0,
94 #[doc = "1: Output is push-pull"]
95 PUSHPULL = 1,
96 #[doc = "2: Output is open drain"]
97 OD = 2,
98 #[doc = "3: Output is tri-state"]
99 TS = 3,
100}
101impl From<GPIO49OUTCFG_A> for u8 {
102 #[inline(always)]
103 fn from(variant: GPIO49OUTCFG_A) -> Self {
104 variant as _
105 }
106}
107#[doc = "Reader of field `GPIO49OUTCFG`"]
108pub type GPIO49OUTCFG_R = crate::R<u8, GPIO49OUTCFG_A>;
109impl GPIO49OUTCFG_R {
110 #[doc = r"Get enumerated values variant"]
111 #[inline(always)]
112 pub fn variant(&self) -> GPIO49OUTCFG_A {
113 match self.bits {
114 0 => GPIO49OUTCFG_A::DIS,
115 1 => GPIO49OUTCFG_A::PUSHPULL,
116 2 => GPIO49OUTCFG_A::OD,
117 3 => GPIO49OUTCFG_A::TS,
118 _ => unreachable!(),
119 }
120 }
121 #[doc = "Checks if the value of the field is `DIS`"]
122 #[inline(always)]
123 pub fn is_dis(&self) -> bool {
124 *self == GPIO49OUTCFG_A::DIS
125 }
126 #[doc = "Checks if the value of the field is `PUSHPULL`"]
127 #[inline(always)]
128 pub fn is_pushpull(&self) -> bool {
129 *self == GPIO49OUTCFG_A::PUSHPULL
130 }
131 #[doc = "Checks if the value of the field is `OD`"]
132 #[inline(always)]
133 pub fn is_od(&self) -> bool {
134 *self == GPIO49OUTCFG_A::OD
135 }
136 #[doc = "Checks if the value of the field is `TS`"]
137 #[inline(always)]
138 pub fn is_ts(&self) -> bool {
139 *self == GPIO49OUTCFG_A::TS
140 }
141}
142#[doc = "Write proxy for field `GPIO49OUTCFG`"]
143pub struct GPIO49OUTCFG_W<'a> {
144 w: &'a mut W,
145}
146impl<'a> GPIO49OUTCFG_W<'a> {
147 #[doc = r"Writes `variant` to the field"]
148 #[inline(always)]
149 pub fn variant(self, variant: GPIO49OUTCFG_A) -> &'a mut W {
150 {
151 self.bits(variant.into())
152 }
153 }
154 #[doc = "Output disabled"]
155 #[inline(always)]
156 pub fn dis(self) -> &'a mut W {
157 self.variant(GPIO49OUTCFG_A::DIS)
158 }
159 #[doc = "Output is push-pull"]
160 #[inline(always)]
161 pub fn pushpull(self) -> &'a mut W {
162 self.variant(GPIO49OUTCFG_A::PUSHPULL)
163 }
164 #[doc = "Output is open drain"]
165 #[inline(always)]
166 pub fn od(self) -> &'a mut W {
167 self.variant(GPIO49OUTCFG_A::OD)
168 }
169 #[doc = "Output is tri-state"]
170 #[inline(always)]
171 pub fn ts(self) -> &'a mut W {
172 self.variant(GPIO49OUTCFG_A::TS)
173 }
174 #[doc = r"Writes raw bits to the field"]
175 #[inline(always)]
176 pub fn bits(self, value: u8) -> &'a mut W {
177 self.w.bits = (self.w.bits & !(0x03 << 5)) | (((value as u32) & 0x03) << 5);
178 self.w
179 }
180}
181#[doc = "GPIO49 input enable.\n\nValue on reset: 0"]
182#[derive(Clone, Copy, Debug, PartialEq)]
183pub enum GPIO49INCFG_A {
184 #[doc = "0: Read the GPIO pin data"]
185 READ = 0,
186 #[doc = "1: Readback will always be zero"]
187 RDZERO = 1,
188}
189impl From<GPIO49INCFG_A> for bool {
190 #[inline(always)]
191 fn from(variant: GPIO49INCFG_A) -> Self {
192 variant as u8 != 0
193 }
194}
195#[doc = "Reader of field `GPIO49INCFG`"]
196pub type GPIO49INCFG_R = crate::R<bool, GPIO49INCFG_A>;
197impl GPIO49INCFG_R {
198 #[doc = r"Get enumerated values variant"]
199 #[inline(always)]
200 pub fn variant(&self) -> GPIO49INCFG_A {
201 match self.bits {
202 false => GPIO49INCFG_A::READ,
203 true => GPIO49INCFG_A::RDZERO,
204 }
205 }
206 #[doc = "Checks if the value of the field is `READ`"]
207 #[inline(always)]
208 pub fn is_read(&self) -> bool {
209 *self == GPIO49INCFG_A::READ
210 }
211 #[doc = "Checks if the value of the field is `RDZERO`"]
212 #[inline(always)]
213 pub fn is_rdzero(&self) -> bool {
214 *self == GPIO49INCFG_A::RDZERO
215 }
216}
217#[doc = "Write proxy for field `GPIO49INCFG`"]
218pub struct GPIO49INCFG_W<'a> {
219 w: &'a mut W,
220}
221impl<'a> GPIO49INCFG_W<'a> {
222 #[doc = r"Writes `variant` to the field"]
223 #[inline(always)]
224 pub fn variant(self, variant: GPIO49INCFG_A) -> &'a mut W {
225 {
226 self.bit(variant.into())
227 }
228 }
229 #[doc = "Read the GPIO pin data"]
230 #[inline(always)]
231 pub fn read(self) -> &'a mut W {
232 self.variant(GPIO49INCFG_A::READ)
233 }
234 #[doc = "Readback will always be zero"]
235 #[inline(always)]
236 pub fn rdzero(self) -> &'a mut W {
237 self.variant(GPIO49INCFG_A::RDZERO)
238 }
239 #[doc = r"Sets the field bit"]
240 #[inline(always)]
241 pub fn set_bit(self) -> &'a mut W {
242 self.bit(true)
243 }
244 #[doc = r"Clears the field bit"]
245 #[inline(always)]
246 pub fn clear_bit(self) -> &'a mut W {
247 self.bit(false)
248 }
249 #[doc = r"Writes raw bits to the field"]
250 #[inline(always)]
251 pub fn bit(self, value: bool) -> &'a mut W {
252 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
253 self.w
254 }
255}
256#[doc = "GPIO48 interrupt direction.\n\nValue on reset: 0"]
257#[derive(Clone, Copy, Debug, PartialEq)]
258pub enum GPIO48INTD_A {
259 #[doc = "0: Interrupt on low to high GPIO transition"]
260 INTLH = 0,
261 #[doc = "1: Interrupt on high to low GPIO transition"]
262 INTHL = 1,
263}
264impl From<GPIO48INTD_A> for bool {
265 #[inline(always)]
266 fn from(variant: GPIO48INTD_A) -> Self {
267 variant as u8 != 0
268 }
269}
270#[doc = "Reader of field `GPIO48INTD`"]
271pub type GPIO48INTD_R = crate::R<bool, GPIO48INTD_A>;
272impl GPIO48INTD_R {
273 #[doc = r"Get enumerated values variant"]
274 #[inline(always)]
275 pub fn variant(&self) -> GPIO48INTD_A {
276 match self.bits {
277 false => GPIO48INTD_A::INTLH,
278 true => GPIO48INTD_A::INTHL,
279 }
280 }
281 #[doc = "Checks if the value of the field is `INTLH`"]
282 #[inline(always)]
283 pub fn is_intlh(&self) -> bool {
284 *self == GPIO48INTD_A::INTLH
285 }
286 #[doc = "Checks if the value of the field is `INTHL`"]
287 #[inline(always)]
288 pub fn is_inthl(&self) -> bool {
289 *self == GPIO48INTD_A::INTHL
290 }
291}
292#[doc = "Write proxy for field `GPIO48INTD`"]
293pub struct GPIO48INTD_W<'a> {
294 w: &'a mut W,
295}
296impl<'a> GPIO48INTD_W<'a> {
297 #[doc = r"Writes `variant` to the field"]
298 #[inline(always)]
299 pub fn variant(self, variant: GPIO48INTD_A) -> &'a mut W {
300 {
301 self.bit(variant.into())
302 }
303 }
304 #[doc = "Interrupt on low to high GPIO transition"]
305 #[inline(always)]
306 pub fn intlh(self) -> &'a mut W {
307 self.variant(GPIO48INTD_A::INTLH)
308 }
309 #[doc = "Interrupt on high to low GPIO transition"]
310 #[inline(always)]
311 pub fn inthl(self) -> &'a mut W {
312 self.variant(GPIO48INTD_A::INTHL)
313 }
314 #[doc = r"Sets the field bit"]
315 #[inline(always)]
316 pub fn set_bit(self) -> &'a mut W {
317 self.bit(true)
318 }
319 #[doc = r"Clears the field bit"]
320 #[inline(always)]
321 pub fn clear_bit(self) -> &'a mut W {
322 self.bit(false)
323 }
324 #[doc = r"Writes raw bits to the field"]
325 #[inline(always)]
326 pub fn bit(self, value: bool) -> &'a mut W {
327 self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
328 self.w
329 }
330}
331#[doc = "GPIO48 output configuration.\n\nValue on reset: 0"]
332#[derive(Clone, Copy, Debug, PartialEq)]
333#[repr(u8)]
334pub enum GPIO48OUTCFG_A {
335 #[doc = "0: Output disabled"]
336 DIS = 0,
337 #[doc = "1: Output is push-pull"]
338 PUSHPULL = 1,
339 #[doc = "2: Output is open drain"]
340 OD = 2,
341 #[doc = "3: Output is tri-state"]
342 TS = 3,
343}
344impl From<GPIO48OUTCFG_A> for u8 {
345 #[inline(always)]
346 fn from(variant: GPIO48OUTCFG_A) -> Self {
347 variant as _
348 }
349}
350#[doc = "Reader of field `GPIO48OUTCFG`"]
351pub type GPIO48OUTCFG_R = crate::R<u8, GPIO48OUTCFG_A>;
352impl GPIO48OUTCFG_R {
353 #[doc = r"Get enumerated values variant"]
354 #[inline(always)]
355 pub fn variant(&self) -> GPIO48OUTCFG_A {
356 match self.bits {
357 0 => GPIO48OUTCFG_A::DIS,
358 1 => GPIO48OUTCFG_A::PUSHPULL,
359 2 => GPIO48OUTCFG_A::OD,
360 3 => GPIO48OUTCFG_A::TS,
361 _ => unreachable!(),
362 }
363 }
364 #[doc = "Checks if the value of the field is `DIS`"]
365 #[inline(always)]
366 pub fn is_dis(&self) -> bool {
367 *self == GPIO48OUTCFG_A::DIS
368 }
369 #[doc = "Checks if the value of the field is `PUSHPULL`"]
370 #[inline(always)]
371 pub fn is_pushpull(&self) -> bool {
372 *self == GPIO48OUTCFG_A::PUSHPULL
373 }
374 #[doc = "Checks if the value of the field is `OD`"]
375 #[inline(always)]
376 pub fn is_od(&self) -> bool {
377 *self == GPIO48OUTCFG_A::OD
378 }
379 #[doc = "Checks if the value of the field is `TS`"]
380 #[inline(always)]
381 pub fn is_ts(&self) -> bool {
382 *self == GPIO48OUTCFG_A::TS
383 }
384}
385#[doc = "Write proxy for field `GPIO48OUTCFG`"]
386pub struct GPIO48OUTCFG_W<'a> {
387 w: &'a mut W,
388}
389impl<'a> GPIO48OUTCFG_W<'a> {
390 #[doc = r"Writes `variant` to the field"]
391 #[inline(always)]
392 pub fn variant(self, variant: GPIO48OUTCFG_A) -> &'a mut W {
393 {
394 self.bits(variant.into())
395 }
396 }
397 #[doc = "Output disabled"]
398 #[inline(always)]
399 pub fn dis(self) -> &'a mut W {
400 self.variant(GPIO48OUTCFG_A::DIS)
401 }
402 #[doc = "Output is push-pull"]
403 #[inline(always)]
404 pub fn pushpull(self) -> &'a mut W {
405 self.variant(GPIO48OUTCFG_A::PUSHPULL)
406 }
407 #[doc = "Output is open drain"]
408 #[inline(always)]
409 pub fn od(self) -> &'a mut W {
410 self.variant(GPIO48OUTCFG_A::OD)
411 }
412 #[doc = "Output is tri-state"]
413 #[inline(always)]
414 pub fn ts(self) -> &'a mut W {
415 self.variant(GPIO48OUTCFG_A::TS)
416 }
417 #[doc = r"Writes raw bits to the field"]
418 #[inline(always)]
419 pub fn bits(self, value: u8) -> &'a mut W {
420 self.w.bits = (self.w.bits & !(0x03 << 1)) | (((value as u32) & 0x03) << 1);
421 self.w
422 }
423}
424#[doc = "GPIO48 input enable.\n\nValue on reset: 0"]
425#[derive(Clone, Copy, Debug, PartialEq)]
426pub enum GPIO48INCFG_A {
427 #[doc = "0: Read the GPIO pin data"]
428 READ = 0,
429 #[doc = "1: Readback will always be zero"]
430 RDZERO = 1,
431}
432impl From<GPIO48INCFG_A> for bool {
433 #[inline(always)]
434 fn from(variant: GPIO48INCFG_A) -> Self {
435 variant as u8 != 0
436 }
437}
438#[doc = "Reader of field `GPIO48INCFG`"]
439pub type GPIO48INCFG_R = crate::R<bool, GPIO48INCFG_A>;
440impl GPIO48INCFG_R {
441 #[doc = r"Get enumerated values variant"]
442 #[inline(always)]
443 pub fn variant(&self) -> GPIO48INCFG_A {
444 match self.bits {
445 false => GPIO48INCFG_A::READ,
446 true => GPIO48INCFG_A::RDZERO,
447 }
448 }
449 #[doc = "Checks if the value of the field is `READ`"]
450 #[inline(always)]
451 pub fn is_read(&self) -> bool {
452 *self == GPIO48INCFG_A::READ
453 }
454 #[doc = "Checks if the value of the field is `RDZERO`"]
455 #[inline(always)]
456 pub fn is_rdzero(&self) -> bool {
457 *self == GPIO48INCFG_A::RDZERO
458 }
459}
460#[doc = "Write proxy for field `GPIO48INCFG`"]
461pub struct GPIO48INCFG_W<'a> {
462 w: &'a mut W,
463}
464impl<'a> GPIO48INCFG_W<'a> {
465 #[doc = r"Writes `variant` to the field"]
466 #[inline(always)]
467 pub fn variant(self, variant: GPIO48INCFG_A) -> &'a mut W {
468 {
469 self.bit(variant.into())
470 }
471 }
472 #[doc = "Read the GPIO pin data"]
473 #[inline(always)]
474 pub fn read(self) -> &'a mut W {
475 self.variant(GPIO48INCFG_A::READ)
476 }
477 #[doc = "Readback will always be zero"]
478 #[inline(always)]
479 pub fn rdzero(self) -> &'a mut W {
480 self.variant(GPIO48INCFG_A::RDZERO)
481 }
482 #[doc = r"Sets the field bit"]
483 #[inline(always)]
484 pub fn set_bit(self) -> &'a mut W {
485 self.bit(true)
486 }
487 #[doc = r"Clears the field bit"]
488 #[inline(always)]
489 pub fn clear_bit(self) -> &'a mut W {
490 self.bit(false)
491 }
492 #[doc = r"Writes raw bits to the field"]
493 #[inline(always)]
494 pub fn bit(self, value: bool) -> &'a mut W {
495 self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
496 self.w
497 }
498}
499impl R {
500 #[doc = "Bit 7 - GPIO49 interrupt direction."]
501 #[inline(always)]
502 pub fn gpio49intd(&self) -> GPIO49INTD_R {
503 GPIO49INTD_R::new(((self.bits >> 7) & 0x01) != 0)
504 }
505 #[doc = "Bits 5:6 - GPIO49 output configuration."]
506 #[inline(always)]
507 pub fn gpio49outcfg(&self) -> GPIO49OUTCFG_R {
508 GPIO49OUTCFG_R::new(((self.bits >> 5) & 0x03) as u8)
509 }
510 #[doc = "Bit 4 - GPIO49 input enable."]
511 #[inline(always)]
512 pub fn gpio49incfg(&self) -> GPIO49INCFG_R {
513 GPIO49INCFG_R::new(((self.bits >> 4) & 0x01) != 0)
514 }
515 #[doc = "Bit 3 - GPIO48 interrupt direction."]
516 #[inline(always)]
517 pub fn gpio48intd(&self) -> GPIO48INTD_R {
518 GPIO48INTD_R::new(((self.bits >> 3) & 0x01) != 0)
519 }
520 #[doc = "Bits 1:2 - GPIO48 output configuration."]
521 #[inline(always)]
522 pub fn gpio48outcfg(&self) -> GPIO48OUTCFG_R {
523 GPIO48OUTCFG_R::new(((self.bits >> 1) & 0x03) as u8)
524 }
525 #[doc = "Bit 0 - GPIO48 input enable."]
526 #[inline(always)]
527 pub fn gpio48incfg(&self) -> GPIO48INCFG_R {
528 GPIO48INCFG_R::new((self.bits & 0x01) != 0)
529 }
530}
531impl W {
532 #[doc = "Bit 7 - GPIO49 interrupt direction."]
533 #[inline(always)]
534 pub fn gpio49intd(&mut self) -> GPIO49INTD_W {
535 GPIO49INTD_W { w: self }
536 }
537 #[doc = "Bits 5:6 - GPIO49 output configuration."]
538 #[inline(always)]
539 pub fn gpio49outcfg(&mut self) -> GPIO49OUTCFG_W {
540 GPIO49OUTCFG_W { w: self }
541 }
542 #[doc = "Bit 4 - GPIO49 input enable."]
543 #[inline(always)]
544 pub fn gpio49incfg(&mut self) -> GPIO49INCFG_W {
545 GPIO49INCFG_W { w: self }
546 }
547 #[doc = "Bit 3 - GPIO48 interrupt direction."]
548 #[inline(always)]
549 pub fn gpio48intd(&mut self) -> GPIO48INTD_W {
550 GPIO48INTD_W { w: self }
551 }
552 #[doc = "Bits 1:2 - GPIO48 output configuration."]
553 #[inline(always)]
554 pub fn gpio48outcfg(&mut self) -> GPIO48OUTCFG_W {
555 GPIO48OUTCFG_W { w: self }
556 }
557 #[doc = "Bit 0 - GPIO48 input enable."]
558 #[inline(always)]
559 pub fn gpio48incfg(&mut self) -> GPIO48INCFG_W {
560 GPIO48INCFG_W { w: self }
561 }
562}