📄 csl_wdt.h
字号:
/** ============================================================================
* @file csl_wdt.h
*
* @path $(CSLPATH)\arm\wdt\src
*
* @desc API header file for watchdog timer CSL
*
*/
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/* @(#) PSP/CSL 3.00.01.00[5912] (2004-05-27) */
/* =============================================================================
* Revision History
* ===============
* 27-May-2004 ka File Created.
* 28-Jun-2004 ka Changes for new CSL architecture
*
* =============================================================================
*/
#ifndef _CSL_WDT_H_
#define _CSL_WDT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <csl.h>
#include <cslr_wdt.h>
/**
* watchdog timer global typedef declarations
*/
/**
* The enum describes the modes of the watchdog timer. The watchdog timer can
* be programmed in general purpose timer mode or in watchdog timer mode
*/
typedef enum {
/** The watchdog timer is configured in general purpose timer mode */
CSL_WDT_MODE_GPT = CSL_WDT_MODE_WATCHDOG_GPT_MODE,
/** The watchdog timer is configured in watchdog timer mode */
CSL_WDT_MODE_WDT = CSL_WDT_MODE_WATCHDOG_WDT_MODE
} CSL_WdtMode;
/**
* This enum describes the load modes of the watchdog timer. The watchdog timer
* can be programmed in auto-reload mode or in one shot mode
*/
typedef enum {
/** In one-shot mode, the watchdog timer stops when the count in the down
* counter reaches zero
*/
CSL_WDT_LOADMODE_ONESHOT = CSL_WDT_CNTL_AR_DISABLE,
/** In auto reload mode, the down counter is loaded with the value in the
* load register (MPU_LOAD_TIMER), whenever the count passes through zero
*/
CSL_WDT_LOADMODE_AR = CSL_WDT_CNTL_AR_ENABLE
} CSL_WdtLoadMode;
/** This enum describes the values that controls the sensitivity of the watchdog
* timer to the suspend signal (emulation)
*/
typedef enum {
/** The watchdog timer freezes its internal logic upon suspend assertion */
CSL_WDT_EMUMODE_STOP = CSL_WDT_CNTL_FREE_RESET,
/** The watchdog timer ignores the suspend signal */
CSL_WDT_EMUMODE_FREERUN = CSL_WDT_CNTL_FREE_SET
} CSL_WdtEmuMode;
/**
* This enum describes the divisor values that can be configured in the watchdog
* timer prescaler block
*/
typedef enum {
/** Watchdog timer input clock is divided by 2 */
CSL_WDT_PRESCALE_CLKBY2 = CSL_WDT_CNTL_PTV_CLKBY2,
/** Watchdog timer input clock is divided by 4 */
CSL_WDT_PRESCALE_CLKBY4 = CSL_WDT_CNTL_PTV_CLKBY4,
/** Watchdog timer input clock is divided by 8 */
CSL_WDT_PRESCALE_CLKBY8 = CSL_WDT_CNTL_PTV_CLKBY8,
/** Watchdog timer input clock is divided by 16 */
CSL_WDT_PRESCALE_CLKBY16 = CSL_WDT_CNTL_PTV_CLKBY16,
/** Watchdog timer input clock is divided by 32 */
CSL_WDT_PRESCALE_CLKBY32 = CSL_WDT_CNTL_PTV_CLKBY32,
/** Watchdog timer input clock is divided by 64 */
CSL_WDT_PRESCALE_CLKBY64 = CSL_WDT_CNTL_PTV_CLKBY64,
/** Watchdog timer input clock is divided by 128 */
CSL_WDT_PRESCALE_CLKBY128 = CSL_WDT_CNTL_PTV_CLKBY128,
/** Watchdog timer input clock is divided by 256 */
CSL_WDT_PRESCALE_CLKBY256 = CSL_WDT_CNTL_PTV_CLKBY256
} CSL_WdtPreScaleValue;
/**
* This enum describes the running status of watchdog timer
*/
typedef enum {
/** Watchdog timer is stopped */
CSL_WDT_STOPPED = CSL_WDT_CNTL_ST_RESET,
/** Watchdog timer is running */
CSL_WDT_RUNNING = CSL_WDT_CNTL_ST_SET
} CSL_WdtStStat;
/**
* This enum describes the commands used to control the watchdog timer through
* CSL_wdtHwControl ()
*/
typedef enum {
/**
* @brief Loads the watchdog timer load register (MPU_LOAD_TIMER)
* @param Uint16
*/
CSL_WDT_CMD_LOAD = 0,
/**
* @brief Starts the watchdog timer
* @param None
*/
CSL_WDT_CMD_START = 1,
/**
* @brief Stops the watchdog timer
* @param None
*/
CSL_WDT_CMD_STOP = 2,
/**
* @brief Disable the watchdog timer
* @param None
*/
CSL_WDT_CMD_DISABLE = 3
} CSL_WdtHwControlCmd;
/**
* This enum describes the commands used to get status of various parameters of the
* watchdog timer. These values are used in CSL_wdtGetHwStatus ()
*/
typedef enum {
/**
* @brief Gets the current value of the watchdog timer read register
* @param Uint16
*/
CSL_WDT_QUERY_COUNT = 0,
/**
* @brief In general purpose mode, this query command returns the status
* about whether the watchdog timer is running or stopped
* @param CSL_WdtStStat
*/
CSL_WDT_QUERY_ST_STAT = 1
} CSL_WdtHwStatusQuery;
/** Hardware setup structure */
typedef struct CSL_WdtHwSetup {
/** 16 bit load value to be loaded to (MPU_LOAD_TIMER) register*/
Uint16 loadVal;
/** Configures the watchdog timer in watchdog mode or in general purpose
* timer mode
*/
CSL_WdtMode timerMode;
/** Pre-scale value for the watchdog timer's input clock */
CSL_WdtPreScaleValue preScaleValue;
/** Configure the watchdog timer in one-shot mode or auto reload mode */
CSL_WdtLoadMode loadMode;
/** Sensitivity to suspend signal */
CSL_WdtEmuMode emuMode;
} CSL_WdtHwSetup;
/**
* Config-structure
*
* Used to configure the watchdog timer using CSL_wdtHwSetupRaw()
*/
typedef struct CSL_WdtConfig {
/** Watchdog timer control register */
volatile Uint32 CNTL;
/** Watchdog timer load register */
volatile Uint32 LOADREAD;
/** Watchdog timer mode register */
volatile Uint32 MODE;
} CSL_WdtConfig;
/** Module specific context information. Present implementation of watchdog
* timer CSL doesn't have any context information.
*/
typedef struct {
/** Context information of watchdog timer CSL.
* The below declaration is just a place-holder for future implementation.
*/
Uint16 contextInfo;
} CSL_WdtContext;
/** Module specific parameters. Present implementation of watchdog timer CSL
* doesn't have any module specific parameters.
*/
typedef struct {
/** Bit mask to be used for module specific parameters. The below
* declaration is just a place-holder for future implementation.
*/
CSL_BitMask16 flags;
} CSL_WdtParam;
/** This structure contains the base-address information for the peripheral
* instance
*/
typedef struct {
/** Base-address of the configuration registers of the peripheral
*/
CSL_WdtRegsOvly regs;
} CSL_WdtBaseAddress;
/** Watchdog timer object structure */
typedef struct CSL_WdtObj {
/** Pointer to the register overlay structure of the watchdog timer */
CSL_WdtRegsOvly regs;
/** Instance of watchdog timer being referred by this object */
CSL_InstNum perNum;
} CSL_WdtObj;
/** Default values for config structure */
#define CSL_WDT_CONFIG_DEFAULTS { \
CSL_WDT_CNTL_RESETVAL, \
CSL_WDT_LOADREAD_RESETVAL, \
CSL_WDT_MODE_RESETVAL \
}
/** Default hardware setup parameters */
#define CSL_WDT_HWSETUP_DEFAULTS { \
0xFFFF, \
CSL_WDT_MODE_WDT, \
CSL_WDT_PRESCALE_CLKBY256, \
CSL_WDT_LOADMODE_ONESHOT, \
CSL_WDT_EMUMODE_FREERUN \
}
/**
* This data type is used to return the handle to the CSL of the watchdog
* timer
*/
typedef struct CSL_WdtObj *CSL_WdtHandle;
/*******************************************************************************
* Watchdog global function declarations
******************************************************************************/
/*
* =============================================================================
* @func CSL_wdtInit
*
* @desc
* @n This is the initialization function for the watchdog timer CSL. This
* function needs to be called before any watchdog timer CSL functions
* are to be called. This function is idem-potent.
*
* @arg pContext
* Context information of watchdog timer CSL
*
* @ret CSL_Status
* CSL_SOK - Always returns
*
* @eg
* CSL_wdtInit(NULL)
* =============================================================================
*/
extern CSL_Status CSL_wdtInit (
CSL_WdtContext * pContext
);
/*
* =============================================================================
* @func CSL_wdtOpen
*
* @desc
* @n This function returns the handle to the watchdog timer instance. This
* handle is passed to all other CSL APIs.
*
* @arg wdtObj
* Pointer to the watchdog timer object - to be allocated by the
* user
* @arg wdtNum
* Instance number of the watchdog timer to be opened
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -