feat: connect reset pin
This commit is contained in:
18
watchdog.ino
18
watchdog.ino
@@ -1,8 +1,10 @@
|
|||||||
const int HEARTBEAT_MAX_DELAY_MILLIS = 20000; //this is coupled to the HEARTBEAT_INTERVAL in src/main.rs
|
const int HEARTBEAT_MAX_DELAY_MILLIS = 20000; //this is coupled to the HEARTBEAT_INTERVAL in src/main.rs
|
||||||
|
const int PIN_SWITCH = 13;
|
||||||
|
|
||||||
unsigned long startTimeMillis;
|
unsigned long startTimeMillis;
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
pinMode(PIN_SWITCH, OUTPUT);
|
||||||
waitForSerial();
|
waitForSerial();
|
||||||
//NOTE might want to replace this initialization with a check in the first loop, so we dont instantly reboot
|
//NOTE might want to replace this initialization with a check in the first loop, so we dont instantly reboot
|
||||||
startTimeMillis = millis();
|
startTimeMillis = millis();
|
||||||
@@ -15,19 +17,6 @@ void loop(){
|
|||||||
if (tickMillis > HEARTBEAT_MAX_DELAY_MILLIS){rst();}
|
if (tickMillis > HEARTBEAT_MAX_DELAY_MILLIS){rst();}
|
||||||
if (Serial.available() > 0) { // if something has been written to the serial port
|
if (Serial.available() > 0) { // if something has been written to the serial port
|
||||||
startTimeMillis = millis();
|
startTimeMillis = millis();
|
||||||
|
|
||||||
|
|
||||||
int value = Serial.parseInt();
|
|
||||||
|
|
||||||
if(value > 0)
|
|
||||||
{
|
|
||||||
Serial.print("Number: ");
|
|
||||||
Serial.print(value);
|
|
||||||
Serial.print(", hex: ");
|
|
||||||
Serial.print(value, HEX);
|
|
||||||
Serial.print(", bin: ");
|
|
||||||
Serial.println(value, BIN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +24,9 @@ void loop(){
|
|||||||
void rst(){
|
void rst(){
|
||||||
//TODO connect the RST pins on the motherboard
|
//TODO connect the RST pins on the motherboard
|
||||||
Serial.println("Error!");
|
Serial.println("Error!");
|
||||||
|
digialWrite(PIN_SWITCH, LOW);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(PIN_SWITCH, HIGH);
|
||||||
waitForSerial();
|
waitForSerial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user