📄 watchdog_a.h
字号:
/************************************************************************/
/* File: watchdog_a.h */
/* */
/* Purpose: File containing the structures and prototypes for the */
/* Watchdog_A device driver */
/* */
/* (C) Copyright Motorola Inc, 2000. All rights reserved. */
/* */
/* $RCSfile: watchdog_a.h,v $ */
/* $Revision: 1.1 $ */
/* $Date: 2000/06/23 20:22:22 $ */
/* $Author: jeffk $ */
/* */
/************************************************************************/
#ifndef _Watchdog_A_H
#define _Watchdog_A_H
#include "mcore.h"
/*----------------------------------------------------------------------*/
/* Structures - Derived Data Type Definitions */
/*----------------------------------------------------------------------*/
/* Watchdog Timer Register Definition */
typedef struct
{
UINT16 WCR; /* Watchdog control register */
UINT16 WMR; /* Watchdog modulus register */
volatile UINT16 WCNTR; /* Watchdog counter register */
UINT16 WSR; /* Watchdog service register */
} Watchdog_A_t, *pWatchdog_A_t;
/*----------------------------------------------------------------------*/
/* Enumerations */
/*----------------------------------------------------------------------*/
/* Error Messages */
typedef enum {
WATCHDOG_A_ERR_NONE, /* No error. */
WATCHDOG_A_ERR_INVALID_HANDLE, /* Base addr parameter is 0. */
WATCHDOG_A_ERR_BAD_RESULT_ADDR, /* Result Pointer is zero. */
WATCHDOG_A_ERR_INVALID_REGISTER, /* Selection is invalid. */
WATCHDOG_A_ERR_INVALID_ENABLE_VALUE, /* Enable mode value out of range. */
WATCHDOG_A_ERR_INVALID_DEBUG_MODE_VALUE, /* DEBUG mode value out of range. */
WATCHDOG_A_ERR_INVALID_DOZE_MODE_VALUE, /* DOZE mode value out of range. */
WATCHDOG_A_ERR_INVALID_WAIT_MODE_VALUE /* Wait mode value out of range. */
} Watchdog_A_ReturnCode_t;
/* Watchdog Timer Register Selection */
typedef enum {
WATCHDOG_A_WCR, /* Select WATCHDOG control Register */
WATCHDOG_A_WMR, /* Select WATCHDOG modulus Register */
WATCHDOG_A_WCNTR, /* Select WATCHDOG counter Register */
WATCHDOG_A_WSR /* Select Service Register */
} Watchdog_A_Registers_t;
/* Watchdog_A_Control_t - Watchdog enable selection. */
typedef enum {
WATCHDOG_A_DISABLE, /* Disable Watchdog Timer */
WATCHDOG_A_ENABLE /* Enable Watchdog Timer */
} Watchdog_A_Control_t;
/* Watchdog_A_Debug_t - Watchdog Debug mode control. */
typedef enum {
WATCHDOG_A_FUNCTION_UNAFFECTED_DEBUG_MODE, /* Not affected during DEBUG */
WATCHDOG_A_FUNCTION_STOPPED_DEBUG_MODE /* Stopped during DEBUG */
} Watchdog_A_Debug_t;
/* Watchdog_A_DOZE_t - DOZE Mode Selection. */
typedef enum {
WATCHDOG_A_FUNCTION_UNAFFECTED_DOZE_MODE, /* Not affected during DOZE */
WATCHDOG_A_FUNCTION_STOPPED_DOZE_MODE /* Stopped during DOZE */
} Watchdog_A_DOZE_t;
/* Watchdog_A_Wait_t - Wait Mode Selection. */
typedef enum {
WATCHDOG_A_FUNCTION_UNAFFECTED_WAIT_MODE, /* Not affected during Wait */
WATCHDOG_A_FUNCTION_STOPPED_WAIT_MODE /* Stopped during Wait */
} Watchdog_A_Wait_t;
/* Register Macros */
/* Watchdog Control Register */
#define WCR_EN_BITNO 0
#define WCR_EN_MASK (1 << WCR_EN_BITNO)
#define WCR_DBG_BITNO 1
#define WCR_DBG_MASK (1 << WCR_DBG_BITNO)
#define WCR_DOZE_BITNO 2
#define WCR_DOZE_MASK (1 << WCR_DOZE_BITNO)
#define WCR_WAIT_BITNO 3
#define WCR_WAIT_MASK (1 << WCR_WAIT_BITNO)
#define WCR_RESET_MASK 0x000F
/* Watchdog Modulus Register */
#define WMR_WM_MAX 0xFFFF
#define WMR_WM_BITNO 0
#define WMR_WM_MASK (WMR_WM_MAX << WMR_WM_BITNO)
#define WMR_RESET_MASK 0xFFFF
/* Watchdog Count Register */
#define WCNTR_WC_MAX 0xFFFF
#define WCNTR_WC_BITNO 0
#define WCNTR_WC_MASK (WCNTR_WC_MAX << WCNTR_WC_BITNO)
/* Watchdog Service Register */
#define WSR_WS_MAX 0xFFFF
#define WSR_WS_BITNO 0
#define WSR_WS_MASK (WSR_WS_MAX << WSR_WS_BITNO)
#define WSR_RESET_MASK 0x0000
#define WSR_FIRST_SERVICE_SEQUENCE_VALUE 0x5555
#define WSR_SECOND_SERVICE_SEQUENCE_VALUE 0xAAAA
/*----------------------------------------------------------------------*/
/* Prototypes */
/*----------------------------------------------------------------------*/
Watchdog_A_ReturnCode_t Watchdog_A_Init_f (
pWatchdog_A_t,
Watchdog_A_Control_t,
Watchdog_A_Debug_t,
Watchdog_A_DOZE_t,
Watchdog_A_Wait_t
);
Watchdog_A_ReturnCode_t Watchdog_A_ConfigureModulus_f (
pWatchdog_A_t,
UINT16
);
Watchdog_A_ReturnCode_t Watchdog_A_GetCounterValue_f (
pWatchdog_A_t,
UINT16 *
);
Watchdog_A_ReturnCode_t Watchdog_A_ServiceWatchdog_f (
pWatchdog_A_t
);
Watchdog_A_ReturnCode_t Watchdog_A_SetRegister_f (
pWatchdog_A_t,
Watchdog_A_Registers_t,
UINT16
);
Watchdog_A_ReturnCode_t Watchdog_A_GetRegister_f (
pWatchdog_A_t,
Watchdog_A_Registers_t,
UINT16 *
);
/*----------------------------------------------------------------------*/
/* Macro: Watchdog_A_Init */
/* */
/* Purpose: Call Watchdog_A_Init_f function with optional */
/* parameter checking. */
/* */
/* Input: */
/* WATCHDOGPtr : Watchdog Timer base address associated */
/* with this driver */
/* EnableValue : Enable/Disable watchdog timer. */
/* DebugModeValue : Control function of watchdog timer in DEBUG mode. */
/* DOZEModeValue : Control function of watchdog timer in DOZE mode. */
/* WaitModeValue : Control function of timer in wait mode. */
/* */
/* Output: */
/* WATCHDOG_A_ERR_NONE : No error. */
/* WATCHDOG_A_ERR_INVALID_HANDLE : Watchdog Timer base address */
/* parameter is zero. */
/* WATCHDOG_A_ERR_INVALID_ENABLE_VALUE : The enable mode value is out */
/* of range. */
/* WATCHDOG_A_ERR_INVALID_DEBUG_MODE_VALUE : The DEBUG mode value is */
/* out of range. */
/* WATCHDOG_A_ERR_INVALID_DOZE_MODE_VALUE : The DOZE mode value is out */
/* of range. */
/* WATCHDOG_A_ERR_INVALID_WAIT_MODE_VALUE : The Wait mode value is out */
/* of range. */
/*----------------------------------------------------------------------*/
#define Watchdog_A_Init( WATCHDOGPtr, \
EnableValue, \
DebugModeValue, \
DOZEModeValue, \
WaitModeValue \
) \
( \
(WATCHDOG_A_PARAM_CHECKING) ? \
( \
((WATCHDOGPtr) == NULL) ? \
WATCHDOG_A_ERR_INVALID_HANDLE : \
(((EnableValue) < WATCHDOG_A_DISABLE) || \
((EnableValue) > WATCHDOG_A_ENABLE)) ? \
WATCHDOG_A_ERR_INVALID_ENABLE_VALUE : \
(((DebugModeValue) < WATCHDOG_A_FUNCTION_UNAFFECTED_DEBUG_MODE) || \
((DebugModeValue) > WATCHDOG_A_FUNCTION_STOPPED_DEBUG_MODE)) ? \
WATCHDOG_A_ERR_INVALID_DEBUG_MODE_VALUE : \
(((DOZEModeValue) < WATCHDOG_A_FUNCTION_UNAFFECTED_DOZE_MODE) || \
((DOZEModeValue) > WATCHDOG_A_FUNCTION_STOPPED_DOZE_MODE)) ? \
WATCHDOG_A_ERR_INVALID_DOZE_MODE_VALUE : \
(((WaitModeValue) < WATCHDOG_A_FUNCTION_UNAFFECTED_WAIT_MODE) || \
((WaitModeValue) > WATCHDOG_A_FUNCTION_STOPPED_WAIT_MODE)) ? \
WATCHDOG_A_ERR_INVALID_WAIT_MODE_VALUE : \
Watchdog_A_Init_f( (WATCHDOGPtr), \
(EnableValue), \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -