Overridable Options - Part 5

Apply `ENABLED` / `DISABLED` macros to files needing only a small
number of changes.
master
Scott Lahteine 9 years ago committed by Richard Wackerbarth
parent 5e834352a9
commit 58cfcd4239

@ -287,6 +287,6 @@ MarlinSerial MSerial;
#endif // !USBCON #endif // !USBCON
// For AT90USB targets use the UART for BT interfacing // For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && defined(BTENABLED) #if defined(USBCON) && ENABLED(BTENABLED)
HardwareSerial bt; HardwareSerial bt;
#endif #endif

@ -153,7 +153,7 @@ extern MarlinSerial MSerial;
#endif // !USBCON #endif // !USBCON
// Use the UART for BT in AT90USB configurations // Use the UART for BT in AT90USB configurations
#if defined(USBCON) && defined(BTENABLED) #if defined(USBCON) && ENABLED(BTENABLED)
extern HardwareSerial bt; extern HardwareSerial bt;
#endif #endif

@ -19,10 +19,10 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "Sd2Card.h" #include "Sd2Card.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef SOFTWARE_SPI #if DISABLED(SOFTWARE_SPI)
// functions for hardware SPI // functions for hardware SPI
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// make sure SPCR rate is in expected bits // make sure SPCR rate is in expected bits
@ -209,7 +209,7 @@ void Sd2Card::chipSelectHigh() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Sd2Card::chipSelectLow() { void Sd2Card::chipSelectLow() {
#ifndef SOFTWARE_SPI #if DISABLED(SOFTWARE_SPI)
spiInit(spiRate_); spiInit(spiRate_);
#endif // SOFTWARE_SPI #endif // SOFTWARE_SPI
digitalWrite(chipSelectPin_, LOW); digitalWrite(chipSelectPin_, LOW);
@ -297,7 +297,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
pinMode(SPI_MOSI_PIN, OUTPUT); pinMode(SPI_MOSI_PIN, OUTPUT);
pinMode(SPI_SCK_PIN, OUTPUT); pinMode(SPI_SCK_PIN, OUTPUT);
#ifndef SOFTWARE_SPI #if DISABLED(SOFTWARE_SPI)
// SS must be in output mode even it is not chip select // SS must be in output mode even it is not chip select
pinMode(SS_PIN, OUTPUT); pinMode(SS_PIN, OUTPUT);
// set SS high - may be chip select for another SPI device // set SS high - may be chip select for another SPI device
@ -353,7 +353,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
} }
chipSelectHigh(); chipSelectHigh();
#ifndef SOFTWARE_SPI #if DISABLED(SOFTWARE_SPI)
return setSckRate(sckRateID); return setSckRate(sckRateID);
#else // SOFTWARE_SPI #else // SOFTWARE_SPI
return true; return true;
@ -373,7 +373,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
* the value zero, false, is returned for failure. * the value zero, false, is returned for failure.
*/ */
bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) { bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
#ifdef SD_CHECK_AND_RETRY #if ENABLED(SD_CHECK_AND_RETRY)
uint8_t retryCnt = 3; uint8_t retryCnt = 3;
// use address if not SDHC card // use address if not SDHC card
if (type()!= SD_CARD_TYPE_SDHC) blockNumber <<= 9; if (type()!= SD_CARD_TYPE_SDHC) blockNumber <<= 9;
@ -422,7 +422,7 @@ bool Sd2Card::readData(uint8_t *dst) {
return readData(dst, 512); return readData(dst, 512);
} }
#ifdef SD_CHECK_AND_RETRY #if ENABLED(SD_CHECK_AND_RETRY)
static const uint16_t crctab[] PROGMEM = { static const uint16_t crctab[] PROGMEM = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
@ -483,7 +483,7 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
// transfer data // transfer data
spiRead(dst, count); spiRead(dst, count);
#ifdef SD_CHECK_AND_RETRY #if ENABLED(SD_CHECK_AND_RETRY)
{ {
uint16_t calcCrc = CRC_CCITT(dst, count); uint16_t calcCrc = CRC_CCITT(dst, count);
uint16_t recvCrc = spiRec() << 8; uint16_t recvCrc = spiRec() << 8;

@ -19,7 +19,7 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef Sd2Card_h #ifndef Sd2Card_h
#define Sd2Card_h #define Sd2Card_h
@ -125,7 +125,7 @@ uint8_t const SD_CARD_TYPE_SDHC = 3;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// SPI pin definitions - do not edit here - change in SdFatConfig.h // SPI pin definitions - do not edit here - change in SdFatConfig.h
// //
#ifndef SOFTWARE_SPI #if DISABLED(SOFTWARE_SPI)
// hardware pin defs // hardware pin defs
/** The default chip select pin for the SD card is SS. */ /** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN; uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;

@ -21,7 +21,7 @@
#include "Marlin.h" #include "Marlin.h"
#include "macros.h" #include "macros.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef Sd2PinMap_h #ifndef Sd2PinMap_h
#define Sd2PinMap_h #define Sd2PinMap_h

@ -19,7 +19,7 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "SdBaseFile.h" #include "SdBaseFile.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdBaseFile_h #ifndef SdBaseFile_h
#define SdBaseFile_h #define SdBaseFile_h

@ -22,7 +22,7 @@
* \brief configuration definitions * \brief configuration definitions
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdFatConfig_h #ifndef SdFatConfig_h
#define SdFatConfig_h #define SdFatConfig_h

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdFatStructs_h #ifndef SdFatStructs_h
#define SdFatStructs_h #define SdFatStructs_h

@ -19,7 +19,7 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "SdFatUtil.h" #include "SdFatUtil.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdFatUtil_h #ifndef SdFatUtil_h
#define SdFatUtil_h #define SdFatUtil_h

@ -19,7 +19,7 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "SdFile.h" #include "SdFile.h"
/** Create a file object and open it in the current working directory. /** Create a file object and open it in the current working directory.
* *

@ -23,7 +23,7 @@
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "SdBaseFile.h" #include "SdBaseFile.h"
#include <Print.h> #include <Print.h>
#ifndef SdFile_h #ifndef SdFile_h

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdInfo_h #ifndef SdInfo_h
#define SdInfo_h #define SdInfo_h

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#include "SdVolume.h" #include "SdVolume.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#ifndef SdVolume_h #ifndef SdVolume_h
#define SdVolume_h #define SdVolume_h
/** /**

@ -3,7 +3,8 @@
Created by Tim Koster, August 21 2013. Created by Tim Koster, August 21 2013.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef BLINKM
#if ENABLED(BLINKM)
#include "blinkm.h" #include "blinkm.h"

@ -5,9 +5,9 @@
#if HAS_BUZZER #if HAS_BUZZER
void buzz(long duration, uint16_t freq) { void buzz(long duration, uint16_t freq) {
if (freq > 0) { if (freq > 0) {
#ifdef LCD_USE_I2C_BUZZER #if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq); lcd_buzz(duration, freq);
#elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition #elif HAS_BUZZER // on-board buzzers have no further condition
SET_OUTPUT(BEEPER); SET_OUTPUT(BEEPER);
#ifdef SPEAKER // a speaker needs a AC ore a pulsed DC #ifdef SPEAKER // a speaker needs a AC ore a pulsed DC
//tone(BEEPER, freq, duration); // needs a PWMable pin //tone(BEEPER, freq, duration); // needs a PWMable pin

@ -5,7 +5,7 @@
#include "temperature.h" #include "temperature.h"
#include "language.h" #include "language.h"
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
CardReader::CardReader() { CardReader::CardReader() {
filesize = 0; filesize = 0;
@ -128,7 +128,7 @@ void CardReader::ls() {
lsDive("", root); lsDive("", root);
} }
#ifdef LONG_FILENAME_HOST_SUPPORT #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
/** /**
* Get a long pretty path based on a DOS 8.3 path * Get a long pretty path based on a DOS 8.3 path
@ -195,7 +195,7 @@ void CardReader::initsd() {
cardOK = false; cardOK = false;
if (root.isOpen()) root.close(); if (root.isOpen()) root.close();
#ifdef SDSLOW #if ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED #define SPI_SPEED SPI_HALF_SPEED
#else #else
#define SPI_SPEED SPI_FULL_SPEED #define SPI_SPEED SPI_FULL_SPEED

@ -1,7 +1,7 @@
#ifndef CARDREADER_H #ifndef CARDREADER_H
#define CARDREADER_H #define CARDREADER_H
#ifdef SDSUPPORT #if ENABLED(SDSUPPORT)
#define MAX_DIR_DEPTH 10 // Maximum folder depth #define MAX_DIR_DEPTH 10 // Maximum folder depth
@ -28,7 +28,7 @@ public:
void getStatus(); void getStatus();
void printingHasFinished(); void printingHasFinished();
#ifdef LONG_FILENAME_HOST_SUPPORT #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
void printLongPath(char *path); void printLongPath(char *path);
#endif #endif
@ -82,7 +82,7 @@ extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting) #define IS_SD_PRINTING (card.sdprinting)
#if (SDCARDDETECT > -1) #if (SDCARDDETECT > -1)
#ifdef SDCARDDETECTINVERTED #if ENABLED(SDCARDDETECTINVERTED)
#define IS_SD_INSERTED (READ(SDCARDDETECT) != 0) #define IS_SD_INSERTED (READ(SDCARDDETECT) != 0)
#else #else
#define IS_SD_INSERTED (READ(SDCARDDETECT) == 0) #define IS_SD_INSERTED (READ(SDCARDDETECT) == 0)

@ -37,7 +37,7 @@
#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en)
#endif #endif
#ifdef HAS_AUTOMATIC_VERSIONING #if ENABLED(HAS_AUTOMATIC_VERSIONING)
#include "_Version.h" #include "_Version.h"
#endif #endif
@ -216,7 +216,7 @@
// LCD Menu Messages // LCD Menu Messages
#if !(defined( DISPLAY_CHARSET_HD44780_JAPAN ) || defined( DISPLAY_CHARSET_HD44780_WESTERN ) || defined( DISPLAY_CHARSET_HD44780_CYRILLIC )) #if DISABLED(DISPLAY_CHARSET_HD44780_JAPAN) && DISABLED(DISPLAY_CHARSET_HD44780_WESTERN) && DISABLED(DISPLAY_CHARSET_HD44780_CYRILLIC)
#define DISPLAY_CHARSET_HD44780_JAPAN #define DISPLAY_CHARSET_HD44780_JAPAN
#endif #endif

@ -1,6 +1,6 @@
#include "Configuration.h" #include "Configuration.h"
#ifdef DIGIPOT_I2C #if ENABLED(DIGIPOT_I2C)
#include "Stream.h" #include "Stream.h"
#include "utility/twi.h" #include "utility/twi.h"

@ -3,7 +3,7 @@
// Please note that using the high-res version takes 402Bytes of PROGMEM. // Please note that using the high-res version takes 402Bytes of PROGMEM.
//#define START_BMPHIGH //#define START_BMPHIGH
#ifdef START_BMPHIGH #if ENABLED(START_BMPHIGH)
#define START_BMPWIDTH 112 #define START_BMPWIDTH 112
#define START_BMPHEIGHT 38 #define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14 #define START_BMPBYTEWIDTH 14

@ -1,6 +1,6 @@
#include "mesh_bed_leveling.h" #include "mesh_bed_leveling.h"
#ifdef MESH_BED_LEVELING #if ENABLED(MESH_BED_LEVELING)
mesh_bed_leveling mbl; mesh_bed_leveling mbl;

@ -1,6 +1,6 @@
#include "Marlin.h" #include "Marlin.h"
#ifdef MESH_BED_LEVELING #if ENABLED(MESH_BED_LEVELING)
#define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1)) #define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1))
#define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1)) #define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1))

@ -1,6 +1,6 @@
#include "qr_solve.h" #include "qr_solve.h"
#ifdef AUTO_BED_LEVELING_GRID #if ENABLED(AUTO_BED_LEVELING_GRID)
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>

@ -1,6 +1,6 @@
#include "Configuration.h" #include "Configuration.h"
#ifdef AUTO_BED_LEVELING_GRID #if ENABLED(AUTO_BED_LEVELING_GRID)
void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
double ddot ( int n, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy );

@ -42,10 +42,10 @@
attached() - Returns true if there is a servo attached. attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin. detach() - Stops an attached servos from pulsing its i/o pin.
*/ */
#include "Configuration.h" #include "Configuration.h"
#ifdef NUM_SERVOS #if HAS_SERVOS
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <Arduino.h> #include <Arduino.h>
@ -103,29 +103,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
// Interrupt handlers for Arduino // Interrupt handlers for Arduino
#ifdef _useTimer1 #if ENABLED(_useTimer1)
SIGNAL (TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); } SIGNAL (TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif #endif
#ifdef _useTimer3 #if ENABLED(_useTimer3)
SIGNAL (TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); } SIGNAL (TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif #endif
#ifdef _useTimer4 #if ENABLED(_useTimer4)
SIGNAL (TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); } SIGNAL (TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
#endif #endif
#ifdef _useTimer5 #if ENABLED(_useTimer5)
SIGNAL (TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); } SIGNAL (TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
#endif #endif
#else //!WIRING #else //!WIRING
// Interrupt handlers for Wiring // Interrupt handlers for Wiring
#ifdef _useTimer1 #if ENABLED(_useTimer1)
void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); } void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif #endif
#ifdef _useTimer3 #if ENABLED(_useTimer3)
void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); } void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif #endif
@ -133,7 +133,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
static void initISR(timer16_Sequence_t timer) { static void initISR(timer16_Sequence_t timer) {
#ifdef _useTimer1 #if ENABLED(_useTimer1)
if (timer == _timer1) { if (timer == _timer1) {
TCCR1A = 0; // normal counting mode TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8 TCCR1B = _BV(CS11); // set prescaler of 8
@ -152,7 +152,7 @@ static void initISR(timer16_Sequence_t timer) {
} }
#endif #endif
#ifdef _useTimer3 #if ENABLED(_useTimer3)
if (timer == _timer3) { if (timer == _timer3) {
TCCR3A = 0; // normal counting mode TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8 TCCR3B = _BV(CS31); // set prescaler of 8
@ -170,7 +170,7 @@ static void initISR(timer16_Sequence_t timer) {
} }
#endif #endif
#ifdef _useTimer4 #if ENABLED(_useTimer4)
if (timer == _timer4) { if (timer == _timer4) {
TCCR4A = 0; // normal counting mode TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8 TCCR4B = _BV(CS41); // set prescaler of 8
@ -180,7 +180,7 @@ static void initISR(timer16_Sequence_t timer) {
} }
#endif #endif
#ifdef _useTimer5 #if ENABLED(_useTimer5)
if (timer == _timer5) { if (timer == _timer5) {
TCCR5A = 0; // normal counting mode TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8 TCCR5B = _BV(CS51); // set prescaler of 8

@ -3,7 +3,7 @@
#include "Marlin.h" #include "Marlin.h"
#ifdef U8GLIB_ST7920 #if ENABLED(U8GLIB_ST7920)
//set optimization so ARDUINO optimizes this file //set optimization so ARDUINO optimizes this file
#pragma GCC optimize (3) #pragma GCC optimize (3)

@ -19,7 +19,7 @@
#include <math.h> #include <math.h>
#include "Marlin.h" #include "Marlin.h"
#ifdef ENABLE_AUTO_BED_LEVELING #if ENABLED(ENABLE_AUTO_BED_LEVELING)
#include "vector_3.h" #include "vector_3.h"
vector_3::vector_3() : x(0), y(0), z(0) { } vector_3::vector_3() : x(0), y(0), z(0) { }

@ -19,7 +19,7 @@
#ifndef VECTOR_3_H #ifndef VECTOR_3_H
#define VECTOR_3_H #define VECTOR_3_H
#ifdef ENABLE_AUTO_BED_LEVELING #if ENABLED(ENABLE_AUTO_BED_LEVELING)
class matrix_3x3; class matrix_3x3;
struct vector_3 struct vector_3

@ -1,6 +1,6 @@
#include "Marlin.h" #include "Marlin.h"
#ifdef USE_WATCHDOG #if ENABLED(USE_WATCHDOG)
#include <avr/wdt.h> #include <avr/wdt.h>
#include "watchdog.h" #include "watchdog.h"
@ -18,15 +18,15 @@
/// intialise watch dog with a 4 sec interrupt time /// intialise watch dog with a 4 sec interrupt time
void watchdog_init() void watchdog_init()
{ {
#ifdef WATCHDOG_RESET_MANUAL #if ENABLED(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();
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE); _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S; _WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
#else #else
wdt_enable(WDTO_4S); wdt_enable(WDTO_4S);
#endif #endif
} }
/// 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.
@ -40,7 +40,7 @@ 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 WATCHDOG_RESET_MANUAL #if ENABLED(WATCHDOG_RESET_MANUAL)
ISR(WDT_vect) ISR(WDT_vect)
{ {
SERIAL_ERROR_START; SERIAL_ERROR_START;

@ -3,7 +3,7 @@
#include "Marlin.h" #include "Marlin.h"
#ifdef USE_WATCHDOG #if ENABLED(USE_WATCHDOG)
// initialize watch dog with a 1 sec interrupt time // initialize watch dog with a 1 sec interrupt time
void watchdog_init(); 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.. // pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or AVR will go into emergency procedures..

Loading…
Cancel
Save