📄 csl_wdtaux.h
字号:
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/** @file csl_wdtAux.h
*
* @brief WDT controller CSL implementation on ARM side.
*
* Path: \\(CSLPATH)\\ipmodules\\wdt\\src
*
*/
/* =============================================================================
* Revision History
* ===============
* 28-April-2005 HMM Added one control command function to set WDT mode.
* 01-Sep-2004 Hmm File created.
* =============================================================================
*/
#ifndef _CSL_WDTAUX_H_
#define _CSL_WDTAUX_H_
#include <csl_wdt.h>
#ifdef __cplusplus
extern "C" {
#endif
/** ============================================================================
* @n@b CSL_wdtGetWdflagStat
*
* @b Description
* This API returns the status about whether the watchdog timer
* is running or stopped
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
* @endverbatim
*
* <b> Return Value </b> CSL_WdtFlagBitStatus
CSL_WDT_WDFLAG_NOTIMEOUT -Watchdog timer is stopped
CSL_WDT_WDFLAG_TIMEOUT -Watchdog timer is running
*
* <b> Pre Condition </b>
* @n Timer should be set to Watchdog timer mode
*
* <b> Post Condition </b>
* @n Returns the status about whether watchdog timer is running or not
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
CSL_WdtFlagBitStatus stStat;
...
stStat = CSL_wdtGetWdflagStat (hWdt);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
CSL_WdtFlagBitStatus CSL_wdtGetWdflagStat (
CSL_WdtHandle hWdt
)
{
CSL_WdtFlagBitStatus stStat;
/* Read the WDFLAG bit in the WDTCR register */
stStat = (CSL_WdtFlagBitStatus)CSL_FEXT (hWdt->regs->WDTCR, \
WDT_WDTCR_WDFLAG);
return stStat;
}
/** ============================================================================
* @n@b CSL_wdtGetTim12Count
*
* @b Description
* This API returns snapshot of watchdog timer counter value
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
Unit32 * counter pointer
* @endverbatim
*
* <b> Return Value </b> TIMx counter snapshot value
*
* <b> Pre Condition </b>
* @n Timer should be set to Watchdog timer active mode
*
* <b> Post Condition </b>
* @n None
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint32 *countTimx;
...
stStat = CSL_wdtGetTim12Count (hWdt);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtGetTim12Count (
CSL_WdtHandle hWdt,
Uint32 *countTimx
)
{
/* Read the Tim12 registers value */
*countTimx = (Uint32)hWdt->regs->TIM12;
}
/** ============================================================================
* @n@b CSL_wdtGetTim34Count
*
* @b Description
* This API returns snapshot of watchdog timer counter 12 value
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
Unit32 * counter pointer
* @endverbatim
*
* <b> Return Value </b> TIM34 counter snapshot value
*
* <b> Pre Condition </b>
* @n Timer should be set to Watchdog timer active mode
*
* <b> Post Condition </b>
* @n None
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint32 *countTimx;
...
stStat = CSL_wdtGetTim34Count (hWdt, countTimx);
...
@endverbatim
* ===========================================================================
*/
static inline
void CSL_wdtGetTim34Count (
CSL_WdtHandle hWdt,
Uint32 *countTimx
)
{
/* Read the Tim34 registers value */
*countTimx = (Uint32)hWdt->regs->TIM34;
}
/** ============================================================================
* @n@b CSL_wdtGetPidNumber
*
* @b Description
* This API returns watchdog timer Peripheral Identification number
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
CSL_WdtPidNumber struct pointer to PID
* @endverbatim
*
* <b> Return Value </b> Peripheral Identification number
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n None
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
CSL_WdtPidNumber *pidNumber;
...
stStat = CSL_wdtGetPidNumber (hWdt , pidNumber);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtGetPidNumber (
CSL_WdtHandle hWdt,
CSL_WdtPidNumber *pidNumber
)
{
/* Identifies the type of peripheral */
pidNumber->wdtType = CSL_FEXT(hWdt->regs->PID12, WDT_PID12_TYPE);
/* Identifies the class of peripheral */
pidNumber->wdtClass = CSL_FEXT(hWdt->regs->PID12, WDT_PID12_CLASS);
/* Identifies the revision level of the timer */
pidNumber->wdtRevision = CSL_FEXT(hWdt->regs->PID12, WDT_PID12_REVISION);
}
/**
* Control command functions of the watchdog timer
*/
/** ============================================================================
* @n@b CSL_wdtLoad12
*
* @b Description
* Loads the watchdog timer period register
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
loadVal Value to be loaded to the watchdog timer period register
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer period register is loaded with the given value.
* General-purpose timer mode:
* The new value is effected when the timer passes through 0 or when it
* starts.
*
* Watchdog timer mode:
* The new value is effected immediately.
*
* @b Modifies
* @n Watchdog timer period register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint32 *loadVal;
...
CSL_wdtLoad12 (hWdt, loadVal);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtLoad12 (
CSL_WdtHandle hWdt,
Uint32 *loadVal
)
{
/* Load period register 12 */
hWdt->regs->PRD12 = *(loadVal);
}
/** ============================================================================
* @n@b CSL_wdtLoad34
*
* @b Description
* Loads the watchdog timer period register 34
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
loadVal Value to be loaded to the watchdog timer period register
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer period register 34 is loaded with the given value.
* General-purpose timer mode:
* The new value is effected when the timer passes through 0 or when it
* starts.
*
* Watchdog timer mode:
* The new value is effected immediately.
*
* @b Modifies
* @n Watchdog timer period register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint32 *loadVal;
...
CSL_wdtLoad (hWdt, loadVal);
...
@endverbatim
* ===========================================================================
*/
static inline
void CSL_wdtLoad34 (
CSL_WdtHandle hWdt,
Uint32 *loadVal
)
{
/* Load period register 34 */
hWdt->regs->PRD34 = *(loadVal);
}
/** ============================================================================
* @n@b CSL_wdtStart
*
* @b Description
* In the general purpose mode, this API starts the watchdog timer
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer is started
*
* @b Modifies
* @n Watchdog timer control register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
...
CSL_wdtStart (hWdt);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtStart (
CSL_WdtHandle hWdt
)
{
CSL_FINST (hWdt->regs->WDTCR, WDT_WDTCR_WDEN, ENABLE);
}
/** ============================================================================
* @n@b CSL_wdtAllowIdle
*
* @b Description
* The watchdog timer will be put into idle mode.
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer is in idle mode
*
* @b Modifies
* @n Watchdog timer control register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
...
CSL_wdtStart (hWdt);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtAllowIdle (
CSL_WdtHandle hWdt
)
{
/* writes 01b value to watchdog control register */
CSL_FINST (hWdt->regs->WDTCR, WDT_WDTCR_WDIKEY, GO_IDLE_START);
/* writes 10b value to watchdog control register */
CSL_FINST (hWdt->regs->WDTCR, WDT_WDTCR_WDIKEY, GO_IDLE);
}
/** ============================================================================
* @n@b CSL_wdtDisallowIdle
*
* @b Description
* The watchdog timer will not be put into idle mode.
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer is in active mode
*
* @b Modifies
* @n Watchdog timer control register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
...
CSL_wdtStart (hWdt);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtDisallowIdle (
CSL_WdtHandle hWdt
)
{
/* writes 00b value to watchdog control register */
CSL_FINST (hWdt->regs->WDTCR, WDT_WDTCR_WDIKEY, NO_IDLE);
}
/** ============================================================================
* @n@b CSL_wdtCmdKey
*
* @b Description
* The watchdog timer will be put different state.
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer in specified state
*
* @b Modifies
* @n Watchdog timer control register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint16 cmd;
...
CSL_wdtStart (hWdt, cmd);
...
@endverbatim
* ===========================================================================
*/
CSL_IDEF_INLINE
void CSL_wdtCmdKey (
CSL_WdtHandle hWdt,
Uint16 cmd
)
{
/* writes cmd value to watchdog control register */
CSL_FINS (hWdt->regs->WDTCR, WDT_WDTCR_WDKEY, cmd);
}
/** ============================================================================
* @n@b CSL_wdtSetWdtMode
*
* @b Description
* This function sets the time in to watchdog mode.
*
* @b Arguments
* @verbatim
hWdt Handle to the watchdog timer instance
cmd WDT mode information to set the timer mode
@endverbatim
*
* <b> Return Value </b>
* None
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Watchdog timer in specified state
*
* @b Modifies
* @n Watchdog timer control register
*
* @b Example
* @verbatim
CSL_WdtHandle hWdt;
Uint16 cmd;
...
CSL_wdtSetWdtMode (hWdt, cmd);
...
@endverbatim
* ===========================================================================
*/
static inline
void CSL_wdtSetWdtMode (
CSL_WdtHandle hWdt,
CSL_WdtTmrMode cmd
)
{
/* sets the timer to watchgod mode */
CSL_FINS (hWdt->regs->TGCR, WDT_TGCR_TIMMODE, cmd);
}
#ifdef __cplusplus
}
#endif
#endif /* _CSL_WDTAUX_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -