Created
November 9, 2015 19:43
-
-
Save vicatcu/f770d5edca31251ac7e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gpio0 = 21; | |
int enable = 23; | |
enum {uart, flash} mode = flash; | |
void setup() { | |
Serial.begin(115200); | |
if(mode == flash){ | |
Serial1.begin(76800); | |
} | |
else if(mode == uart){ | |
Serial1.begin(115200); | |
} | |
pinMode(gpio0, OUTPUT); | |
pinMode(enable, OUTPUT); | |
if(mode == flash){ | |
digitalWrite(gpio0, HIGH); | |
} | |
else if(mode == uart){ | |
digitalWrite(gpio0, LOW); | |
} | |
digitalWrite(enable, LOW); | |
Serial.println("GPIO=HIGH, ENABLE=LOW"); | |
delay(100); | |
digitalWrite(enable, HIGH); | |
Serial.println("GPIO=HIGH, ENABLE=HIGH"); | |
if(mode == flash){ | |
delay(1000); | |
Serial1.begin(115200); | |
} | |
} | |
void loop() { | |
if(Serial1.available()){ | |
Serial.write(Serial1.read()); | |
} | |
if(Serial.available()){ | |
Serial1.write(Serial.read()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment