|
@@ -1263,63 +1263,9 @@ void prepare_arc_move(char isclockwise) {
|
1263
|
1263
|
}
|
1264
|
1264
|
}
|
1265
|
1265
|
|
1266
|
|
-#ifdef USE_WATCHDOG
|
1267
|
1266
|
|
1268
|
|
-#include <avr/wdt.h>
|
1269
|
|
-#include <avr/interrupt.h>
|
1270
|
1267
|
|
1271
|
|
-volatile uint8_t timeout_seconds=0;
|
1272
|
1268
|
|
1273
|
|
-void(* ctrlaltdelete) (void) = 0;
|
1274
|
|
-
|
1275
|
|
-ISR(WDT_vect) { //Watchdog timer interrupt, called if main program blocks >1sec
|
1276
|
|
- if(timeout_seconds++ >= WATCHDOG_TIMEOUT)
|
1277
|
|
- {
|
1278
|
|
- kill();
|
1279
|
|
-#ifdef RESET_MANUAL
|
1280
|
|
- LCD_MESSAGE("Please Reset!");
|
1281
|
|
- ECHOLN("echo_: Something is wrong, please turn off the printer.");
|
1282
|
|
-#else
|
1283
|
|
- LCD_MESSAGE("Timeout, resetting!");
|
1284
|
|
-#endif
|
1285
|
|
- //disable watchdog, it will survife reboot.
|
1286
|
|
- WDTCSR |= (1<<WDCE) | (1<<WDE);
|
1287
|
|
- WDTCSR = 0;
|
1288
|
|
-#ifdef RESET_MANUAL
|
1289
|
|
- while(1); //wait for user or serial reset
|
1290
|
|
-#else
|
1291
|
|
- ctrlaltdelete();
|
1292
|
|
-#endif
|
1293
|
|
- }
|
1294
|
|
-}
|
1295
|
|
-
|
1296
|
|
-/// intialise watch dog with a 1 sec interrupt time
|
1297
|
|
-void wd_init() {
|
1298
|
|
- WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
|
1299
|
|
- WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
|
1300
|
|
-}
|
1301
|
|
-
|
1302
|
|
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
|
1303
|
|
-void wd_reset() {
|
1304
|
|
- wdt_reset();
|
1305
|
|
- timeout_seconds=0; //reset counter for resets
|
1306
|
|
-}
|
1307
|
|
-#endif /* USE_WATCHDOG */
|
1308
|
|
-
|
1309
|
|
-
|
1310
|
|
-inline void kill()
|
1311
|
|
-{
|
1312
|
|
- disable_heater();
|
1313
|
|
-
|
1314
|
|
- disable_x();
|
1315
|
|
- disable_y();
|
1316
|
|
- disable_z();
|
1317
|
|
- disable_e();
|
1318
|
|
-
|
1319
|
|
- if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
1320
|
|
- Serial.println("!! Printer halted. kill() called !!");
|
1321
|
|
- while(1); // Wait for reset
|
1322
|
|
-}
|
1323
|
1269
|
|
1324
|
1270
|
void manage_inactivity(byte debug) {
|
1325
|
1271
|
if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill();
|