Browse Source

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

pull/1/head
daid303 12 years ago
parent
commit
b6ff45254e
  1. 7
      Marlin/Configuration_adv.h
  2. 1
      Marlin/Marlin.h
  3. 10
      Marlin/watchdog.cpp

7
Marlin/Configuration_adv.h

@ -185,9 +185,10 @@
//#define USE_WATCHDOG //#define USE_WATCHDOG
#ifdef USE_WATCHDOG #ifdef USE_WATCHDOG
// you cannot watchdog reboot on Arduino mega2560 due to a bug in he bootloader. Hence we need to ask the user to reset. // If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
// 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. // The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
//#define RESET_MANUAL // 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.
#define WATCHDOG_RESET_MANUAL
#endif #endif
// extruder advance constant (s2/mm3) // extruder advance constant (s2/mm3)

1
Marlin/Marlin.h

@ -17,7 +17,6 @@
#include <util/delay.h> #include <util/delay.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <avr/wdt.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>

10
Marlin/watchdog.cpp

@ -1,6 +1,8 @@
#include "Marlin.h" #include "Marlin.h"
#ifdef USE_WATCHDOG #ifdef USE_WATCHDOG
#include <avr/wdt.h>
#include "watchdog.h" #include "watchdog.h"
#include "ultralcd.h" #include "ultralcd.h"
@ -16,7 +18,7 @@
/// intialise watch dog with a 1 sec interrupt time /// intialise watch dog with a 1 sec interrupt time
void watchdog_init() void watchdog_init()
{ {
#ifdef RESET_MANUAL #ifdef WATCHDOG_RESET_MANUAL
//We enable the watchdog timer, but only for the interrupt. //We enable the watchdog timer, but only for the interrupt.
//Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details. //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
wdt_reset(); wdt_reset();
@ -30,7 +32,7 @@ void watchdog_init()
/// reset watchdog. MUST be called every 1s after init or avr will reset. /// reset watchdog. MUST be called every 1s after init or avr will reset.
void watchdog_reset() void watchdog_reset()
{ {
wdt_reset(); wdt_reset();
} }
//=========================================================================== //===========================================================================
@ -38,14 +40,14 @@ void watchdog_reset()
//=========================================================================== //===========================================================================
//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
#ifdef RESET_MANUAL #ifdef WATCHDOG_RESET_MANUAL
ISR(WDT_vect) ISR(WDT_vect)
{ {
//TODO: This message gets overwritten by the kill() call
LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
LCD_STATUS; LCD_STATUS;
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer."); SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
kill(); //kill blocks kill(); //kill blocks
while(1); //wait for user or serial reset while(1); //wait for user or serial reset
} }

Loading…
Cancel
Save