cop.h
来自「MC56F802BLDC 可以使用的算法 就是电机启动有点慢」· C头文件 代码 · 共 129 行
H
129 行
/*****************************************************************************
*
* Motorola Inc.
* (c) Copyright 2001 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
******************************************************************************
*
* File Name: cop.h
*
* Description: COP (Computer Operating Properly - Watchdog) driver macros
* and definitions
*
* Modules Included: none
*
*****************************************************************************/
#ifndef __COP_H
#define __COP_H
/************************************************************
* COP module identifier, corresponds to module base address
*************************************************************/
#define COP (&ArchIO.Cop)
/***************************************************
* COP ioctl commands
****************************************************/
/* command | Param */
/* COP peripheral initialization according static config in AppConfig.h */
#define COP_INIT /* null */
/* COP peripheral enable/disable - functional only if COP Write protect Bit (CWP) is not set */
/* - functional only if COP Write protect Bit (CWP) is not set */
#define COP_DEVICE /* enable(1)/disable(0) */
/* COP peripheral write protect - functional only if COP Write protect Bit (CWP) is not set */
/* if this command is issued any subsequent write to COPCTL (COP Control Reg.) is blocked */
/* untill the chip RESET */
#define COP_WRITE_PROTECT
/* write COP timeout interval - Tout = 1/(CPUclock/(16384*ToutValue)) */
/* - functional only if COP Write protect Bit (CWP) is not set */
#define COP_SET_TIMEOUT /* ToutValue */
/* control the state of COP in WAIT and STOP mode */
/* - functional only if COP Write protect Bit (CWP) is not set */
#define COP_RUN_IN_STOP /* run enable(1)/disable(0) in STOP mode */
#define COP_RUN_IN_WAIT /* run enable(1)/disable(0) in WAIT mode */
/* clear COP counter - service to be used in program */
/* loop before COP timeout expiration to prevent COP reset */
#define COP_CLEAR_COUNTER /* NULL */
/****************************************************************************
* COP constants and type declarations used in the ioctl functions
*****************************************************************************/
#define COP_CSEN 0x0008
#define COP_CWEN 0x0004
#define COP_CEN 0x0002
#define COP_CWP 0x0001
#define COP_ENABLE 1
#define COP_DISABLE 0
/****************************************************************************
* COP function prototypes
*****************************************************************************/
extern void cop_Init(arch_sCOP *pCopBase);
/***********************************************************************
* COP control command macros
***********************************************************************/
/* COP initialization */
#define ioctlCOP_INIT(pCopBase,param) cop_Init((arch_sCOP*)pCopBase)
/* COP peripheral enable/disable - functional only if COP Write protect Bit (CWP) is not set */
#define ioctlCOP_DEVICE(pCopBase,param) \
if (param) periphBitSet(COP_CEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg); \
else periphBitClear(COP_CEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg)
/* COP peripheral write protect - functional only if COP Write protect Bit (CWP) is not set */
/* if this command issued any subsequent write to COPCTL (COP Control Reg.) is blocked */
#define ioctlCOP_WRITE_PROTECT(pCopBase,param) periphBitSet(COP_CWP, \
(UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg)
/* COP Run in Stop mode enable/disable */
#define ioctlCOP_RUN_IN_STOP(pCopBase,param) \
if (param) periphBitSet(COP_CSEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg); \
else periphBitClear(COP_CSEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg)
/* COP Run in Stop mode enable/disable */
#define ioctlCOP_RUN_IN_WAIT(pCopBase,param) \
if (param) periphBitSet(COP_CWEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg); \
else periphBitClear(COP_CWEN, (UWord16 *) &((arch_sCOP*)pCopBase)->ControlReg)
/* set COP timeout interval, param value is decremented before write to timeout reg */
#define ioctlCOP_SET_TIMEOUT(pCopBase,param) periphMemWrite(((UWord16)(param)-1) & 0x0FFF, \
(UWord16 *) &((arch_sCOP*)pCopBase)->TimeoutReg)
/* clear(service) COP timer */
#define ioctlCOP_CLEAR_COUNTER(pCopBase,param) {periphMemWrite(0x5555, \
(UWord16 *) &((arch_sCOP*)pCopBase)->ServiceReg);\
periphMemWrite(0xAAAA, \
(UWord16 *) &((arch_sCOP*)pCopBase)->ServiceReg);}
/***********************************************************************
* COP static configuration items
***********************************************************************/
/* these items should be added to AppConfig.h config file and appropriate
init values should be chosen. It is also possible to generate AppConfig.h
by graphic configuration tool
*/
/*
#define COP_TIMEOUT_REG 0x0FFF
#define COP_CONTROL_REG 0x0002
*/
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?