|
@@ -1,25 +1,14 @@
|
1
|
1
|
#include "Marlin.h"
|
2
|
2
|
|
3
|
3
|
#if ENABLED(USE_WATCHDOG)
|
4
|
|
-#include <avr/wdt.h>
|
5
|
4
|
|
6
|
5
|
#include "watchdog.h"
|
7
|
|
-#include "ultralcd.h"
|
8
|
6
|
|
9
|
|
-//===========================================================================
|
10
|
|
-//============================ private variables ============================
|
11
|
|
-//===========================================================================
|
12
|
|
-
|
13
|
|
-//===========================================================================
|
14
|
|
-//================================ functions ================================
|
15
|
|
-//===========================================================================
|
16
|
|
-
|
17
|
|
-
|
18
|
|
-/// intialise watch dog with a 4 sec interrupt time
|
|
7
|
+// Initialize watchdog with a 4 sec interrupt time
|
19
|
8
|
void watchdog_init() {
|
20
|
9
|
#if ENABLED(WATCHDOG_RESET_MANUAL)
|
21
|
|
- //We enable the watchdog timer, but only for the interrupt.
|
22
|
|
- //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
|
|
10
|
+ // We enable the watchdog timer, but only for the interrupt.
|
|
11
|
+ // Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
|
23
|
12
|
wdt_reset();
|
24
|
13
|
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
|
25
|
14
|
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
|
|
@@ -28,23 +17,18 @@ void watchdog_init() {
|
28
|
17
|
#endif
|
29
|
18
|
}
|
30
|
19
|
|
31
|
|
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
|
32
|
|
-void watchdog_reset() {
|
33
|
|
- wdt_reset();
|
34
|
|
-}
|
35
|
|
-
|
36
|
20
|
//===========================================================================
|
37
|
21
|
//=================================== ISR ===================================
|
38
|
22
|
//===========================================================================
|
39
|
23
|
|
40
|
|
-//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
|
|
24
|
+// Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
|
41
|
25
|
#if ENABLED(WATCHDOG_RESET_MANUAL)
|
42
|
|
-ISR(WDT_vect) {
|
43
|
|
- SERIAL_ERROR_START;
|
44
|
|
- SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
|
45
|
|
- kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display
|
46
|
|
- while (1); //wait for user or serial reset
|
47
|
|
-}
|
48
|
|
-#endif//RESET_MANUAL
|
49
|
|
-
|
50
|
|
-#endif//USE_WATCHDOG
|
|
26
|
+ ISR(WDT_vect) {
|
|
27
|
+ SERIAL_ERROR_START;
|
|
28
|
+ SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
|
|
29
|
+ kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display
|
|
30
|
+ while (1); //wait for user or serial reset
|
|
31
|
+ }
|
|
32
|
+#endif //WATCHDOG_RESET_MANUAL
|
|
33
|
+
|
|
34
|
+#endif //USE_WATCHDOG
|