Skip to content

Commit

Permalink
Coerce pull-type as well
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Sep 28, 2023
1 parent a0c2014 commit 5ccd92c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions rp2040-hal/examples/gpio_dyn_pin_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use hal::gpio::DynPinId;
use hal::gpio::FunctionSioOutput;
use hal::gpio::Pin;
use hal::gpio::PullDown;
use hal::gpio::PullNone;
// Ensure we halt the program on panic (if we don't mention this crate it won't
// be linked)
use panic_halt as _;
Expand Down Expand Up @@ -91,11 +91,23 @@ fn main() -> ! {
// To put pins into an array we have to convert them to Dynamically Typed pins.
// This means they'll carry their pin and bank numbers around with them at run time,
// rather than relying on the Type of the pin to track that.
let mut pinarray: [Pin<DynPinId, FunctionSioOutput, PullDown>; 4] = [
pins.gpio2.into_push_pull_output().into_dyn_pin(),
pins.gpio3.into_push_pull_output().into_dyn_pin(),
pins.gpio4.into_push_pull_output().into_dyn_pin(),
pins.gpio5.into_push_pull_output().into_dyn_pin(),
let mut pinarray: [Pin<DynPinId, FunctionSioOutput, PullNone>; 4] = [
pins.gpio2
.into_push_pull_output()
.into_dyn_pin()
.into_pull_type(),
pins.gpio3
.into_push_pull_output()
.into_dyn_pin()
.into_pull_type(),
pins.gpio4
.into_push_pull_output()
.into_dyn_pin()
.into_pull_type(),
pins.gpio5
.into_push_pull_output()
.into_dyn_pin()
.into_pull_type(),
];

// Also set a pin as a dynamic input. We won't use this, it is just to demonstrate that
Expand Down

0 comments on commit 5ccd92c

Please sign in to comment.