TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
Data Structures | Macros | Typedefs | Enumerations | Functions
Watchdog.h File Reference

Detailed Description

Watchdog driver interface.

===========================================================================

The Watchdog header file should be included in an application as follows:

Operation

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.

Opening the driver

handle = Watchdog_open(Watchdog_configIndex, &params);
if (!handle) {
System_printf("Watchdog did not open");
}
// handle may now be used to interact with the Watchdog just created

Implementation

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:

Instrumentation

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>
Include dependency graph for Watchdog.h:
This graph shows which files directly or indirectly include this file:

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_ConfigWatchdog_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 Documentation

Watchdog Handle.

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.

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.

Watchdog Parameters.

Watchdog parameters are used to with the Watchdog_open() call. Default values for these parameters are set using Watchdog_Params_init().

See also
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().

The definition of a Watchdog function table that contains the required set of functions to control a specific Watchdog driver implementation.

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.

See also
Watchdog_init()

Enumeration Type Documentation

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

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

Function Documentation

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.

Parameters
handleWatchdog 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.

Precondition
Watchdog_open() has to be called first.
Parameters
handleA Watchdog_Handle returned from Watchdog_open
See also
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.

Precondition
Watchdog_open() has to be called first.
Parameters
handleA Watchdog handle returned from Watchdog_open()
cmdWatchdog.h or Watchdog*.h commands.
argAn optional R/W (read/write) command argument accompanied with cmd
Returns
Implementation specific return codes. Negative values indicate unsuccessful operations.
See also
Watchdog_open()
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.

Parameters
indexLogical peripheral number for the Watchdog indexed into the Watchdog_config table
paramsPointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).
Returns
A Watchdog_Handle on success or a NULL on an error or if it has been opened already.
See also
Watchdog_init()
Watchdog_close()
void Watchdog_Params_init ( Watchdog_Params params)

Function to initialize the Watchdog_Params structure to its defaults.

Parameters
paramsAn 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.

Parameters
handleWatchdog Handle
valueValue to be loaded into Watchdog timer
Copyright 2016, Texas Instruments Incorporated