watchdog.h

Watchdog timer control facilities.  See also auto_watchdog.h.

Summary
watchdog.hWatchdog timer control facilities.
Macros
WATCHDOG_DISABLE_ON_MCU_RESETDefines a watchdog-disabling routine that is executed automatically at MCU reset.
WATCHDOG_DISABLE_ON_MCU_RESET_SAVE_FLAGSDefines a watchdog-disabling routine that is executed automatically at MCU reset.
Variables
watchdog_saved_mcu_reset_flagsWhen the watchdog is disabled via WATCHDOG_DISABLE_ON_MCU_RESET_SAVE_FLAGS, the contents of the MCUSR register are stored here before the register is cleared.
Functions
watchdog_reset_mcuUses the watchdog timer to trigger a reset of the MCU.

Macros

WATCHDOG_DISABLE_ON_MCU_RESET

Defines a watchdog-disabling routine that is executed automatically at MCU reset.  The routine is executed before main is called.  The routine clears the MCUSR register to ensure that no reset flag that implicitly enables the watchdog timer remains set.  After MCUSR has been cleared, the routine disables the watchdog timer and then firmware initialization continues.  Function definition macro.

NOTE: This macro can be implicitly expanded in a code file by including the header auto_watchdog.h (with both WATCHDOG_AUTODISABLE_SAVE_FLAGS and WATCHDOG_DO_NOT_AUTODISABLE undefined).

WATCHDOG_DISABLE_ON_MCU_RESET_SAVE_FLAGS

Defines a watchdog-disabling routine that is executed automatically at MCU reset.  The routine is executed before main is called.  The routine first saves the contents of the MCUSR register in watchdog_saved_mcu_reset_flags, then clears the register to ensure that no reset flag that implicitly enables the watchdog timer remains set.  After MCUSR has been cleared, the routine disables the watchdog timer and then firmware initialization continues.  Function definition macro.

NOTE: This macro can be implicitly expanded in a code file by defining the macro WATCHDOG_AUTODISABLE_SAVE_FLAGS and then including the header auto_watchdog.h.

Variables

watchdog_saved_mcu_reset_flags

extern uint8_t watchdog_saved_mcu_reset_flags __attribute__ ((address (RAMEND)))

When the watchdog is disabled via WATCHDOG_DISABLE_ON_MCU_RESET_SAVE_FLAGS, the contents of the MCUSR register are stored here before the register is cleared.

Functions

watchdog_reset_mcu

void watchdog_reset_mcu(void) __attribute__ ((noreturn))

Uses the watchdog timer to trigger a reset of the MCU.  There is a delay of about 16 milliseconds before the reset happens, the function will disable interrupts and then busy-loop to wait out this delay.

CAUTION: The watchdog timer remains enabled after the MCU reset.  To prevent repeated resets, the watchdog timer MUST be disabled (or reset or reconfigured) as soon as possible when the firmware is restarted after a call to this function (e.g. via WATCHDOG_DISABLE_ON_MCU_RESET).

extern uint8_t watchdog_saved_mcu_reset_flags __attribute__ ((address (RAMEND)))
When the watchdog is disabled via WATCHDOG_DISABLE_ON_MCU_RESET_SAVE_FLAGS, the contents of the MCUSR register are stored here before the register is cleared.
Defines a watchdog-disabling routine that is executed automatically at MCU reset.
void watchdog_reset_mcu(void) __attribute__ ((noreturn))
Uses the watchdog timer to trigger a reset of the MCU.
When this header is included in a firmware code file, the watchdog timer will be automatically disabled (via WATCHDOG_DISABLE_ON_MCU_RESET) during firmware initialization, before main is called.
Defines a watchdog-disabling routine that is executed automatically at MCU reset.
Close