TI-RTOS Drivers
tidrivers_cc32xx_2_16_01_13
|
Watchdog driver interface.
===========================================================================
The Watchdog header file should be included in an application as follows:
The Watchdog driver simplifies configuring and starting the Watchdog peripherals. The Watchdog can be set up to produce a reset signal after a timeout, or simply cause a hardware interrupt at a programmable interval. The driver provides the ability to specify a callback function that is called when the Watchdog causes an interrupt.
When resets are turned on, it is the user application's responsibility to call Watchdog_clear() in order to clear the Watchdog and prevent a reset. Watchdog_clear() can be called at any time.
The Watchdog driver does not configure the board peripherals. This must be done before any calls to the Watchdog driver. The examples include a board-specific Board_initWatchdog() functions in the board .c and .h files.
This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to a Watchdog_FxnTable.
The Watchdog driver interface module is joined (at link time) to a NULL-terminated array of Watchdog_Config data structures named Watchdog_config. Watchdog_config is implemented in the application with each entry being an instance of a Watchdog peripheral. Each entry in Watchdog_config contains a:
The Watchdog driver interface produces log statements if instrumentation is enabled.
Diagnostics Mask | Log details |
---|---|
Diags_USER1 | basic Watchdog operations to be performed |
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | Watchdog_Params |
Watchdog Parameters. More... | |
struct | Watchdog_FxnTable |
The definition of a Watchdog function table that contains the required set of functions to control a specific Watchdog driver implementation. More... | |
struct | Watchdog_Config |
Watchdog Global configuration. More... | |
Macros | |
#define | Watchdog_CMD_RESERVED 32 |
#define | Watchdog_STATUS_RESERVED -32 |
#define | Watchdog_STATUS_SUCCESS 0 |
Successful status code returned by Watchdog_control(). More... | |
#define | Watchdog_STATUS_ERROR -1 |
Generic error status code returned by Watchdog_control(). More... | |
#define | Watchdog_STATUS_UNDEFINEDCMD -2 |
An error status code returned by Watchdog_control() for undefined command codes. More... | |
Typedefs | |
typedef struct Watchdog_Config * | Watchdog_Handle |
Watchdog Handle. More... | |
typedef enum Watchdog_DebugMode | Watchdog_DebugMode |
Watchdog debug stall settings. More... | |
typedef enum Watchdog_ResetMode | Watchdog_ResetMode |
Watchdog reset mode settings. More... | |
typedef void(* | Watchdog_Callback) (uintptr_t) |
Watchdog callback pointer. More... | |
typedef struct Watchdog_Params | Watchdog_Params |
Watchdog Parameters. More... | |
typedef void(* | Watchdog_ClearFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_clear(). More... | |
typedef void(* | Watchdog_CloseFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_close(). More... | |
typedef int(* | Watchdog_ControlFxn) (Watchdog_Handle handle, unsigned int cmd, void *arg) |
A function pointer to a driver specific implementation of Watchdog_control(). More... | |
typedef void(* | Watchdog_InitFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_init(). More... | |
typedef Watchdog_Handle(* | Watchdog_OpenFxn) (Watchdog_Handle handle, Watchdog_Params *params) |
A function pointer to a driver specific implementation of Watchdog_open(). More... | |
typedef void(* | Watchdog_SetReloadFxn) (Watchdog_Handle handle, uint32_t value) |
A function pointer to a driver specific implementation of Watchdog_setReload(). More... | |
typedef struct Watchdog_FxnTable | Watchdog_FxnTable |
The definition of a Watchdog function table that contains the required set of functions to control a specific Watchdog driver implementation. More... | |
typedef struct Watchdog_Config | Watchdog_Config |
Watchdog Global configuration. More... | |
Enumerations | |
enum | Watchdog_DebugMode { Watchdog_DEBUG_STALL_ON, Watchdog_DEBUG_STALL_OFF } |
Watchdog debug stall settings. More... | |
enum | Watchdog_ResetMode { Watchdog_RESET_OFF, Watchdog_RESET_ON } |
Watchdog reset mode settings. More... | |
Functions | |
void | Watchdog_clear (Watchdog_Handle handle) |
Clears the Watchdog. More... | |
void | Watchdog_close (Watchdog_Handle handle) |
Function to close a Watchdog peripheral specified by the Watchdog handle.It stops (holds) the Watchdog counting on applicable platforms. More... | |
int | Watchdog_control (Watchdog_Handle handle, unsigned int cmd, void *arg) |
Function performs implementation specific features on a given Watchdog_Handle. More... | |
void | Watchdog_init (void) |
Initializes the Watchdog module. More... | |
Watchdog_Handle | Watchdog_open (unsigned int index, Watchdog_Params *params) |
Opens a Watchdog. More... | |
void | Watchdog_Params_init (Watchdog_Params *params) |
Function to initialize the Watchdog_Params structure to its defaults. More... | |
void | Watchdog_setReload (Watchdog_Handle handle, uint32_t value) |
Sets the Watchdog reload value. More... | |
typedef struct Watchdog_Config* Watchdog_Handle |
Watchdog Handle.
typedef enum Watchdog_DebugMode Watchdog_DebugMode |
Watchdog debug stall settings.
This enumeration defines the debug stall modes for the Watchdog. On some targets, the Watchdog timer will continue to count down while a debugging session is halted. To avoid unwanted resets, the Watchdog can be set to stall while the processor is stopped by the debugger.
typedef enum Watchdog_ResetMode Watchdog_ResetMode |
Watchdog reset mode settings.
This enumeration defines the reset modes for the Watchdog. The Watchdog can be configured to either generate a reset upon timeout or simply produce a periodic interrupt.
typedef void(* Watchdog_Callback) (uintptr_t) |
Watchdog callback pointer.
This is the typedef for the function pointer that will allow a callback function to be specified in the Watchdog_Params structure. The function will take a Watchdog_Handle of the Watchdog causing the interrupt (cast as a uintptr_t) as an argument.
typedef struct Watchdog_Params Watchdog_Params |
Watchdog Parameters.
Watchdog parameters are used to with the Watchdog_open() call. Default values for these parameters are set using Watchdog_Params_init().
typedef void(* Watchdog_ClearFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_clear().
typedef void(* Watchdog_CloseFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_close().
typedef int(* Watchdog_ControlFxn) (Watchdog_Handle handle, unsigned int cmd, void *arg) |
A function pointer to a driver specific implementation of Watchdog_control().
typedef void(* Watchdog_InitFxn) (Watchdog_Handle handle) |
A function pointer to a driver specific implementation of Watchdog_init().
typedef Watchdog_Handle(* Watchdog_OpenFxn) (Watchdog_Handle handle, Watchdog_Params *params) |
A function pointer to a driver specific implementation of Watchdog_open().
typedef void(* Watchdog_SetReloadFxn) (Watchdog_Handle handle, uint32_t value) |
A function pointer to a driver specific implementation of Watchdog_setReload().
typedef struct Watchdog_FxnTable Watchdog_FxnTable |
The definition of a Watchdog function table that contains the required set of functions to control a specific Watchdog driver implementation.
typedef struct Watchdog_Config Watchdog_Config |
Watchdog Global configuration.
The Watchdog_Config structure contains a set of pointers used to characterize the Watchdog driver implementation.
This structure needs to be defined before calling Watchdog_init() and it must not be changed thereafter.
enum Watchdog_DebugMode |
Watchdog debug stall settings.
This enumeration defines the debug stall modes for the Watchdog. On some targets, the Watchdog timer will continue to count down while a debugging session is halted. To avoid unwanted resets, the Watchdog can be set to stall while the processor is stopped by the debugger.
Enumerator | |
---|---|
Watchdog_DEBUG_STALL_ON |
Watchdog will be stalled at breakpoints |
Watchdog_DEBUG_STALL_OFF |
Watchdog will keep running at breakpoints |
enum Watchdog_ResetMode |
Watchdog reset mode settings.
This enumeration defines the reset modes for the Watchdog. The Watchdog can be configured to either generate a reset upon timeout or simply produce a periodic interrupt.
Enumerator | |
---|---|
Watchdog_RESET_OFF |
Timeouts generate interrupts only |
Watchdog_RESET_ON |
Generates reset after timeout |
void Watchdog_clear | ( | Watchdog_Handle | handle | ) |
Clears the Watchdog.
Clears the Watchdog to to prevent a reset signal from being generated if the module is in Watchdog_RESET_ON reset mode.
handle | Watchdog Handle |
void Watchdog_close | ( | Watchdog_Handle | handle | ) |
Function to close a Watchdog peripheral specified by the Watchdog handle.It stops (holds) the Watchdog counting on applicable platforms.
handle | A Watchdog_Handle returned from Watchdog_open |
int Watchdog_control | ( | Watchdog_Handle | handle, |
unsigned int | cmd, | ||
void * | arg | ||
) |
Function performs implementation specific features on a given Watchdog_Handle.
Commands for Watchdog_control can originate from Watchdog.h or from implementation specific Watchdog*.h (WatchdogCC26XX.h, WatchdogTiva.h, etc.. ) files. While commands from Watchdog.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific Watchdog*.h files add unique driver capabilities but are not API portable across all Watchdog driver implementations.
Commands supported by Watchdog.h follow a Watchdog_CMD_<cmd> naming convention.
Commands supported by Watchdog*.h follow a Watchdog*_CMD_<cmd> naming convention.
Each control command defines arg differently. The types of arg are documented with each command.
See Watchdog_control command codes for command codes.
See Watchdog_control return status codes for status codes.
handle | A Watchdog handle returned from Watchdog_open() |
cmd | Watchdog.h or Watchdog*.h commands. |
arg | An optional R/W (read/write) command argument accompanied with cmd |
void Watchdog_init | ( | void | ) |
Initializes the Watchdog module.
The application-provided Watchdog_config must be present before the Watchdog_init function is called. The Watchdog_config must be persistent and not changed after Watchdog_init is called. This function must be called before any of the other Watchdog driver APIs.
Watchdog_Handle Watchdog_open | ( | unsigned int | index, |
Watchdog_Params * | params | ||
) |
Opens a Watchdog.
Opens a Watchdog object with the index and parameters specified, and returns a Watchdog_Handle.
index | Logical peripheral number for the Watchdog indexed into the Watchdog_config table |
params | Pointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only). |
void Watchdog_Params_init | ( | Watchdog_Params * | params | ) |
Function to initialize the Watchdog_Params structure to its defaults.
params | An pointer to Watchdog_Params structure for initialization |
Default parameters: callbackFxn = NULL resetMode = Watchdog_RESET_ON debugStallMode = Watchdog_DEBUG_STALL_ON
void Watchdog_setReload | ( | Watchdog_Handle | handle, |
uint32_t | value | ||
) |
Sets the Watchdog reload value.
Sets the value from which the Watchdog will countdown after it reaches zero. This is how the reload value can be changed after the Watchdog has already been opened. The new reload value will be loaded into the Watchdog timer when this function is called. Watchdog_setReload is not reentrant.
This API is not applicable for all platforms. See the page for your specific driver implementation for details.
handle | Watchdog Handle |
value | Value to be loaded into Watchdog timer |