Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 10 months ago.
How do I save and subsequently restore the state of a GPIO pin after dynamic reconfiguration
I need to change the type of pins from "Something" to AnalogIn and back again within a function. If I dynamically change a pin it actually changes the pin (duh), so when I return from the function the pin stays reconfigured even if I use dynamic variables with local scope. Changing the pin back to e.g. DigitalInOut prior to leaving the function works but what if I didn't know what the pin was to start off with as with being called from different routines. What I need is a way to save the type and state of a pin on entering the function and then restoring on return.
Any ideas?