39#include "dev/watchdog.h"
43#include <ti/drivers/Watchdog.h>
44#include <ti/drivers/dpl/ClockP.h>
46#include <ti/devices/DeviceFamily.h>
47#include DeviceFamily_constructPath(driverlib/watchdog.h)
54#define WATCHDOG_DIV_RATIO 32
55#define WATCHDOG_TIMEOUT_MARGIN 1500
57#if (WATCHDOG_DISABLE == 0)
58static Watchdog_Handle wdt_handle;
70#if (WATCHDOG_DISABLE == 0)
73 Watchdog_Params wdt_params;
74 Watchdog_Params_init(&wdt_params);
76 wdt_params.resetMode = Watchdog_RESET_ON;
77 wdt_params.debugStallMode = Watchdog_DEBUG_STALL_ON;
79 wdt_handle = Watchdog_open(Board_WATCHDOG0, &wdt_params);
86 if(!WatchdogRunning()) {
91 ClockP_getCpuFreq(&freq);
92 uint64_t value = (uint64_t)WatchdogValueGet();
93 uint32_t timeout = (uint32_t)((value * 1000 * 1000 * WATCHDOG_DIV_RATIO) / freq.lo);
101 if(timeout <= WATCHDOG_TIMEOUT_MARGIN) {
104 return timeout - WATCHDOG_TIMEOUT_MARGIN;
114#if (WATCHDOG_DISABLE == 0)
125#if (WATCHDOG_DISABLE == 0)
126 uint32_t timeout_ticks = Watchdog_convertMsToTicks(wdt_handle, WATCHDOG_TIMEOUT_MS);
127 Watchdog_setReload(wdt_handle, timeout_ticks);
138#if (WATCHDOG_DISABLE == 0)
139 Watchdog_clear(wdt_handle);
149#if (WATCHDOG_DISABLE == 0)
void watchdog_stop(void)
Stop the Watchdog such that it won't timeout and cause a system reset.
uint32_t watchdog_arch_next_timeout(void)
Return the next expiration time for the Watchdog.
void watchdog_reboot(void)
Keeps control until the WDT throws a reset signal.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
void watchdog_periodic(void)
Writes the WDT clear sequence.
void watchdog_init(void)
Initialisation function for the WDT.
Header file of the CC13xx/CC26xx watchdog driver.