Remove private watchdog and use built-in wdt instead
This commit is contained in:
parent
ef774b0664
commit
834ae6d1d5
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// Firmware version
|
||||
#define FW_version "3.1.0"
|
||||
#define FW_local_variant 9
|
||||
#define FW_local_variant 10
|
||||
#define FW_report_version FW_version " r" STR(FW_local_variant)
|
||||
|
||||
#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@
|
|||
//=============================Additional Features===========================
|
||||
//===========================================================================
|
||||
|
||||
// The hardware watchdog should reset the microcontroller disabling all outputs
|
||||
// in case the firmware gets stuck and doesn't do temperature regulation.
|
||||
//#define WATCHDOG
|
||||
|
||||
//#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
|
||||
#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
|
||||
|
||||
|
|
@ -291,16 +295,6 @@
|
|||
//#define PROGRESS_MSG_ONCE
|
||||
#endif
|
||||
|
||||
// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
|
||||
//#define USE_WATCHDOG
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
|
||||
// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
|
||||
// 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
|
||||
|
||||
// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
|
||||
//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
||||
|
||||
|
|
|
|||
|
|
@ -48,14 +48,15 @@
|
|||
#include "temperature.h"
|
||||
#include "motion_control.h"
|
||||
#include "cardreader.h"
|
||||
#include "watchdog.h"
|
||||
#include "ConfigurationStore.h"
|
||||
#include "language.h"
|
||||
#include "pins_arduino.h"
|
||||
#include "math.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef WATCHDOG
|
||||
#include <avr/wdt.h>
|
||||
#endif
|
||||
|
||||
#ifdef BLINKM
|
||||
#include "BlinkM.h"
|
||||
|
|
@ -1103,7 +1104,6 @@ void setup()
|
|||
SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
|
||||
tp_init(); // Initialize temperature loop
|
||||
plan_init(); // Initialize planner;
|
||||
watchdog_init();
|
||||
st_init(); // Initialize stepper, this enables interrupts!
|
||||
setup_photpin();
|
||||
servo_init();
|
||||
|
|
@ -1282,6 +1282,9 @@ void setup()
|
|||
// so the next time the firmware gets updated, it will know from which version it has been updated.
|
||||
update_current_firmware_version_to_eeprom();
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#ifdef WATCHDOG
|
||||
wdt_enable(WDTO_4S);
|
||||
#endif
|
||||
}
|
||||
|
||||
void trace();
|
||||
|
|
@ -6582,9 +6585,12 @@ void kill(const char *full_screen_message)
|
|||
#endif
|
||||
suicide();
|
||||
// Wait for reset
|
||||
while(1) {
|
||||
// nice doggie
|
||||
watchdog_reset();
|
||||
while(1) {
|
||||
#ifdef WATCHDOG
|
||||
// nice doggie
|
||||
wdt_reset();
|
||||
#endif
|
||||
_delay_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@
|
|||
#include "Marlin.h"
|
||||
#include "ultralcd.h"
|
||||
#include "temperature.h"
|
||||
#include "watchdog.h"
|
||||
#include "cardreader.h"
|
||||
|
||||
#include "Sd2PinMap.h"
|
||||
|
||||
#ifdef WATCHDOG
|
||||
#include <avr/wdt.h>
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=============================public variables============================
|
||||
|
|
@ -841,7 +843,9 @@ static void updateTemperaturesFromRawValues()
|
|||
filament_width_meas = analog2widthFil();
|
||||
#endif
|
||||
//Reset the watchdog after we know we have a temperature measurement.
|
||||
watchdog_reset();
|
||||
#ifdef WATCHDOG
|
||||
wdt_reset();
|
||||
#endif
|
||||
|
||||
CRITICAL_SECTION_START;
|
||||
temp_meas_ready = false;
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
#include "Marlin.h"
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#include "watchdog.h"
|
||||
#include "ultralcd.h"
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
|
||||
//===========================================================================
|
||||
//=============================functinos ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
/// intialise watch dog with a 4 sec interrupt time
|
||||
void watchdog_init()
|
||||
{
|
||||
#ifdef WATCHDOG_RESET_MANUAL
|
||||
//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.
|
||||
wdt_reset();
|
||||
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
|
||||
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
|
||||
#else
|
||||
wdt_enable(WDTO_4S);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// reset watchdog. MUST be called every 1s after init or avr will reset.
|
||||
void watchdog_reset()
|
||||
{
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//=============================ISR ============================
|
||||
//===========================================================================
|
||||
|
||||
//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
|
||||
#ifdef WATCHDOG_RESET_MANUAL
|
||||
ISR(WDT_vect)
|
||||
{
|
||||
//TODO: This message gets overwritten by the kill() call
|
||||
LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
|
||||
lcd_update();
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
|
||||
kill(); //kill blocks
|
||||
while(1); //wait for user or serial reset
|
||||
}
|
||||
#endif//RESET_MANUAL
|
||||
|
||||
#endif//USE_WATCHDOG
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef WATCHDOG_H
|
||||
#define WATCHDOG_H
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
// initialize watch dog with a 1 sec interrupt time
|
||||
void watchdog_init();
|
||||
// pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or AVR will go into emergency procedures..
|
||||
void watchdog_reset();
|
||||
#else
|
||||
//If we do not have a watchdog, then we can have empty functions which are optimized away.
|
||||
FORCE_INLINE void watchdog_init() {};
|
||||
FORCE_INLINE void watchdog_reset() {};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue