![FTDI FT51A Скачать руководство пользователя страница 126](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158126.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
125
Copyright © 2015 Future Technology Devices International Limited
CLEAR_WDG);
// Start the watchdog.
WRITE_IO_REG(TIMER_CONTROL_2,
MSTART_WDG);
}
/**
@brief Watchdog Feed
@details The function feeds the watchdog in order to prevent it from
resetting the system.
@return void
**/
void
watchdog_feed
()
{
// Clear the watchdog. **/
WRITE_IO_REG(TIMER_CONTROL_2,
CLEAR_WDG);
}
/**
@enum RESET_REASON
@brief Explains the cause of the most recent reset.
**/
typedef enum
{
// Power supply was removed or interrupted.
NORMAL_RESET,
// Watchdog was not fed in time.
WATCHDOG_RESET
}
RESET_REASON;
/**
@brief Reset cause.
@details A function to check what caused the reset:
i.e. whether the system started after a normal reset
or a watchdog reset.
@param[in] reason Explains most-recent reset.
@return 0 - success, 1 - failure
**/
int
reset_cause
(RESET_REASON *reason)
{
uint8_t data;
if (reason == NULL)
return 1;
*reason = NORMAL_RESET; // Assume normal reset until found otherwise.
// Check if a watchdog overflow occurred.
READ_IO_REG(TIMER_CONTROL_2,
1,
&data);
// Ensure that only the watchdog interrupt bit gets checked.
data &= WDG_INT;
if (data == WDG_INT)
{
*reason = WATCHDOG_RESET;
}