mmarchetti / DirectIO

Fast, simple I/O library for Arduino
GNU Lesser General Public License v3.0
115 stars 27 forks source link

Change pin mode in work? #9

Open vvzvlad opened 7 years ago

vvzvlad commented 7 years ago

How do I do this using DirectIO?

pinMode(ESP_RESET_PIN, OUTPUT);
digitalWrite(ESP_RESET_PIN, LOW);
delay(50);
digitalWrite(ESP_RESET_PIN, HIGH);
delay(50);
pinMode(ESP_RESET_PIN, INPUT);
mmarchetti commented 7 years ago

DirectIO doesn't have a straightforward way to put outputs back into high-impedance mode. This is something that should be addressed (and I think would be straightforward).

You could leave the last pinMode call in place as long as you don't use the Output object again. Wrapping this in a function would prevent that:

void ESPReset(void)
{
    Output< ESP_RESET_PIN> pin;
    pin = LOW;
    delay(50);
    pin = HIGH;
    delay(50);
    pinMode(ESP_RESET_PIN, INPUT);
}

Alternatively, you could keep the code sequence you have.