Skip to content

How to get the gpio back from Output? #2031

Closed Answered by MabezDev
yanshay asked this question in Q&A
Discussion options

You must be logged in to vote

If you pass the pin as &mut gpio0 into Ouput, when you drop that Output you will be able to use gpio0 again in the new driver.

let mut pin = io.gpio0;

{
    let output0 = Output::new(&mut pin, Level::Low);
    // use in driver 0
    // output0 dropped here
}

let output1 = Output::new(&mut pin, Level::Low); // could also pass by value here if its not needed again
// use output1 in driver 1

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yanshay
Comment options

Answer selected by yanshay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants