Watchdog driver implementation for CC13XX/CC26XX.
The Watchdog header file should be included in an application as follows:
Refer to Watchdog.h for a complete description of APIs.
The general Watchdog API should be used in application code, i.e. Watchdog_open() should be used instead of WatchdogCC26XX_open(). The board file will define the device specific config, and casting in the general API will ensure that the correct device specific functions are called.
This Watchdog driver implementation is designed to operate on a CC13XX/CC26XX device. Before using the Watchdog in CC13XX/CC26XX, the Watchdog driver is initialized by calling Watchdog_init(). The Watchdog HW is configured by calling Watchdog_open(). Once opened, the Watchdog will count down from the reload value specified in WatchdogCC26XX_HWAttrs. If it times out, a non-maskable interrupt will be triggered, the Watchdog interrupt flag will be set, and a user-provided callback function will be called. If reset is enabled in the Watchdog_Params and the Watchdog timer is allowed to time out again while the interrupt flag is still pending, a reset signal will be generated. To prevent a reset, Watchdog_clear() must be called to clear the interrupt flag and to reload the timer.
The Watchdog counts down at a rate of the device clock SCLK_HF (48 MHz) divided by a fixed-division ratio of 32, which equals to 1.5 MHz. The Watchdog rate will change if SCLK_HF deviates from 48 MHz.
The reload value from which the Watchdog timer counts down may be changed during runtime using Watchdog_setReload(). This value should be specified in Watchdog clock ticks and should not exceed the maximum value of 32 bits, which corresponds to a timeout period of 2863.3 seconds at the Watchdog rate of 1.5 MHz. If the reload value is set to zero, the Watchdog interrupt is immediately generated.
Since the device is not reset on the first Watchdog timeout, the maximum time lapse between the time when the device gets locked up and the time when it is reset can be up to two Watchdog timeout periods.
Watchdog_close() is not supported by this driver implementation. Once started, the Watchdog timer can only be stopped by a hardware reset.
No CC13XX/CC26XX specific command has been implemented. Any call to Watchdog_control() will receive the return code Watchdog_STATUS_UNDEFINEDCMD.
By default the Watchdog driver has reset enabled. However, it may be disabled in the Watchdog_Params which allows the Watchdog Timer to be used like another timer interrupt. This functionality is not supported by all platforms, refer to device specific documentation for details.
Once started, the Watchdog will keep running in Active or Idle mode. When the device enters Standby mode, the Watchdog timer will stop counting down but the counter value will be preserved. When the device wakes up from Standby, the Watchdog timer will continue to count down from the previous counter value.
This means that if a system goes into Standby 50% of the time and the Watchdog reload value is set to 1 second, the Watchdog timer will actually time out in 2 seconds. A system which is only in Active/Idle mode for 1% of the time, the Watchdog timer will time out in 100 seconds. However, if a bug locks up the application in Active mode, the Watchdog timer will time out in the configured time.
| Generic API Function | API Function | Description | |---------------------------— |-------------------------------— |------------------------------------------------—| | Watchdog_init() | WatchdogCC26XX_init() | Initialize Watchdog driver | | Watchdog_open() | WatchdogCC26XX_open() | Initialize Watchdog HW and set system dependencies| | Watchdog_clear() | WatchdogCC26XX_clear() | Clear Watchdog interrupt flag and reload counter | | Watchdog_setReload() | WatchdogCC26XX_setReload() | Set Watchdog timer reload value in clock ticnks | | Watchdog_convertMsToTicks() | WatchdogCC26XX_convertMsToTicks() | Converts milliseconds to clock ticks |
In this basic watchdog example, the application is expected to define a Watchdog callback function and start the Watchdog timer by calling Watchdog_open(). If needed, Watchdog_setReload() may be called to change the timeout period. If all monitored tasks are doing alright, Watchdog_clear() should be called regularly to reload the counter so as to restart the timeout period and to avoid the Watchdog interrupt being triggered. If the Watchdog_clear() is missed and the Watchdog timer is allowed to timeout, the user-defined callback function is called. In this function, the user may do whatever is appropriate for the application. Here are some suggestions:
The following code example shows how to define the callback function and to start the Watchdog timer.
#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/dpl/HwiP.h>
Go to the source code of this file.
Data Structures | |
struct | WatchdogCC26XX_HWAttrs |
Watchdog hardware attributes for CC26XX. More... | |
struct | WatchdogCC26XX_Object |
Watchdog Object for CC26XX. More... | |
Variables | |
const Watchdog_FxnTable | WatchdogCC26XX_fxnTable |
Watchdog function table for CC26XX. More... | |
const Watchdog_FxnTable WatchdogCC26XX_fxnTable |
Watchdog function table for CC26XX.