1234567891011121314151617181920212223242526 |
- void resetForFlashing(int afterms) {
- // this can be used to flash new firmware even when serial DTS line is not connected, so no auto-reset on serial connect is performed
- // this schematic does not use a DTS line in order not to purge unsafed data accidentially
- // also it is normally not connected via USB directly, but over RS-232 with some metres of cable in between
- // called from serial routine, so that a serial command, iE "reset 1000" calls this function with value given
- // tested OK with a 1000ms delay before starting avrdude to upload the new binary
- saveAllCurrentData(false);
- Serial.print(F("saved all data, resetting in "));
- Serial.print(afterms);
- Serial.println("ms...");
- Serial.end();
- delay(afterms);
- //Serial.println(F("RESETTING NOW"));
- doHardreset();
- // WDT reset DOES NOT put bootloader in flash mode!!
- //wdt_disable();
- //wdt_enable(WDTO_4S);
- //while (1) {delay(500); Serial.print(".");}
- }
- void doHardreset() {
- pinMode(PIN_OUT_HARDRESET, OUTPUT);
- digitalWrite(PIN_OUT_HARDRESET, LOW); // pull a pin low that is connected to /RESET as WDT reset DOES NOT put bootloader in flash mode!!
- }
|