Commit 6a1767e
committed
gpio: introduce AfType + unified Pin::set_as_af + Speed::to_mode
Mirrors embassy-stm32 gpio_v1's `AfType` struct and the `set_as_af`
method on `SealedPin`. Drivers can now express any pin direction
(input-with-pull, output push-pull, output open-drain) as a single
`AfType` value built via `AfType::input(pull)` or
`AfType::output(output_type, speed)`, and feed it through one
`set_as_af()` call instead of juggling `set_as_af_output(AFType,
Speed)` + `set_as_input(Pull)` plus a separate `afio_remap()` call.
`Speed::to_mode()` is added as a const helper so `AfType::output` can
stay `const fn`. The pre-existing `From<Speed> for vals::Mode` now
delegates to it.
Drops the previous `From<AFType> for vals::Cnf` direction-overloaded
constants in favor of the explicit `AfType::output` constructor. The
old `set_as_af_output`/`set_as_input` methods remain for backwards
compatibility but new code should reach for `set_as_af` via the
`new_pin!` / `set_as_af!` macros added in the next commit.1 parent 817ea75 commit 6a1767e
1 file changed
Lines changed: 66 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | | - | |
50 | 55 | | |
51 | | - | |
52 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
459 | 465 | | |
460 | 466 | | |
461 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
462 | 507 | | |
463 | 508 | | |
464 | 509 | | |
| |||
569 | 614 | | |
570 | 615 | | |
571 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
572 | 626 | | |
573 | 627 | | |
574 | 628 | | |
| |||
0 commit comments