diff --git a/common/wdt.h b/common/wdt.h new file mode 100644 index 0000000..2f6843e --- /dev/null +++ b/common/wdt.h @@ -0,0 +1,35 @@ +/* + * This file is part of arduino-headers. + * + * arduino-headers is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or(at your option) any later version. + * + * arduino-headers is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with arduino-headers. If not, see . + */ + +#ifndef _ARDUINO_WDT_H +#define _ARDUINO_WDT_H + +#include +#include + +#if defined(WDTCSR) +# define _WDT_REG WDTCSR +#else +# define _WDT_REG WDTCR +#endif + +static inline void wdt_interrupt_enable() { _WDT_REG |= _BV(WDIE); } +static inline void wdt_interrupt_disable() { _WDT_REG &= ~_BV(WDIE); } + +#define wdt_interrupt() ISR(WDT_vect) + +#endif diff --git a/wdt.h b/wdt.h new file mode 100644 index 0000000..8704f6f --- /dev/null +++ b/wdt.h @@ -0,0 +1,31 @@ +/* + * This file is part of arduino-headers. + * + * arduino-headers is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or(at your option) any later version. + * + * arduino-headers is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with arduino-headers. If not, see . + */ + +#if defined(__AVR_ATmega8__) +# error "arduino/wdt.h: Not implemented for ATmega8 chips yet" +#elif defined(__AVR_ATmega168__) \ + || defined(__AVR_ATmega328P__) +# include +#elif defined(__AVR_ATmega1280__) +# error "arduino/wdt.h: Not implemented for ATmega1280 chips yet" +#elif defined(__AVR_ATtiny25__) \ + || defined(__AVR_ATtiny45__) \ + || defined(__AVR_ATtiny85__) +# include +#else +# error "arduino/wdt.h: Unknown chip type" +#endif