浏览代码

Better explain the watchdog "problem" and rename the config define so it explains that the feature belongs to the watchdog.

daid303 12 年前
父节点
当前提交
b6ff45254e
共有 3 个文件被更改,包括 12 次插入10 次删除
  1. 4
    3
      Marlin/Configuration_adv.h
  2. 0
    1
      Marlin/Marlin.h
  3. 8
    6
      Marlin/watchdog.cpp

+ 4
- 3
Marlin/Configuration_adv.h 查看文件

185
 //#define USE_WATCHDOG
185
 //#define USE_WATCHDOG
186
 
186
 
187
 #ifdef USE_WATCHDOG
187
 #ifdef USE_WATCHDOG
188
-// you cannot watchdog reboot on Arduino mega2560 due to a bug in he bootloader. Hence we need to ask the user to reset.
189
-//  THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
190
-//#define RESET_MANUAL
188
+// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
189
+// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
190
+//  However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
191
+#define WATCHDOG_RESET_MANUAL
191
 #endif
192
 #endif
192
 
193
 
193
 // extruder advance constant (s2/mm3)
194
 // extruder advance constant (s2/mm3)

+ 0
- 1
Marlin/Marlin.h 查看文件

17
 #include <util/delay.h>
17
 #include <util/delay.h>
18
 #include <avr/pgmspace.h>
18
 #include <avr/pgmspace.h>
19
 #include <avr/eeprom.h>
19
 #include <avr/eeprom.h>
20
-#include <avr/wdt.h>
21
 #include <avr/interrupt.h>
20
 #include <avr/interrupt.h>
22
 
21
 
23
 
22
 

+ 8
- 6
Marlin/watchdog.cpp 查看文件

1
 #include "Marlin.h"
1
 #include "Marlin.h"
2
 
2
 
3
-#ifdef USE_WATCHDOG
3
+#ifdef USE_WATCHDOG
4
+#include <avr/wdt.h>
5
+
4
 #include "watchdog.h"
6
 #include "watchdog.h"
5
 #include "ultralcd.h"
7
 #include "ultralcd.h"
6
 
8
 
16
 /// intialise watch dog with a 1 sec interrupt time
18
 /// intialise watch dog with a 1 sec interrupt time
17
 void watchdog_init()
19
 void watchdog_init()
18
 {
20
 {
19
-#ifdef RESET_MANUAL
21
+#ifdef WATCHDOG_RESET_MANUAL
20
     //We enable the watchdog timer, but only for the interrupt.
22
     //We enable the watchdog timer, but only for the interrupt.
21
     //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
23
     //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
22
     wdt_reset();
24
     wdt_reset();
30
 /// reset watchdog. MUST be called every 1s after init or avr will reset.
32
 /// reset watchdog. MUST be called every 1s after init or avr will reset.
31
 void watchdog_reset() 
33
 void watchdog_reset() 
32
 {
34
 {
33
-  wdt_reset();
35
+    wdt_reset();
34
 }
36
 }
35
 
37
 
36
 //===========================================================================
38
 //===========================================================================
38
 //===========================================================================
40
 //===========================================================================
39
 
41
 
40
 //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
42
 //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
41
-#ifdef RESET_MANUAL
43
+#ifdef WATCHDOG_RESET_MANUAL
42
 ISR(WDT_vect)
44
 ISR(WDT_vect)
43
-{ 
45
+{ 
46
+    //TODO: This message gets overwritten by the kill() call
44
     LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
47
     LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
45
     LCD_STATUS;
48
     LCD_STATUS;
46
     SERIAL_ERROR_START;
49
     SERIAL_ERROR_START;
47
     SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
50
     SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
48
-
49
     kill(); //kill blocks
51
     kill(); //kill blocks
50
     while(1); //wait for user or serial reset
52
     while(1); //wait for user or serial reset
51
 }
53
 }

正在加载...
取消
保存