Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.