rt-thread/bsp/essemi/es8p508x/libraries/Library/Include/lib_wdt.h

101 lines
3.6 KiB
C
Raw Normal View History

2019-11-07 10:00:14 +08:00
/***************************************************************
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lib_wdt.c
*<EFBFBD><EFBFBD> <EFBFBD>ߣ<EFBFBD> Liut
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> V1.00
*<EFBFBD><EFBFBD> <EFBFBD>ڣ<EFBFBD> 2017/02/04
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508xоƬ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
***************************************************************/
#ifndef __LIBWDT_H__
#define __LIBWDT_H__
#include "system_ES8P508x.h"
#include "ES8P508x.h"
#include "type.h"
/* WDTʱ<54><CAB1>ѡ<EFBFBD><D1A1> */
typedef enum
{
WDT_CLOCK_PCLK = 0x0, //PCLK
WDT_CLOCK_WDT = 0x1, //WDTʱ<54><CAB1>Դ<EFBFBD><D4B4>32kHz
} WDT_TYPE_CLKS;
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E1B9B9> */
typedef struct
{
uint32_t WDT_Tms; //<2F><>ʱʱ<CAB1><EFBFBD><E4A3AC>λms
TYPE_FUNCEN WDT_IE; //<2F>ж<EFBFBD>ʹ<EFBFBD><CAB9>
TYPE_FUNCEN WDT_Rst; //<2F><>λʹ<CEBB><CAB9>
WDT_TYPE_CLKS WDT_Clock;//ʱ<><CAB1>ѡ<EFBFBD><D1A1>
} IWDT_InitStruType;
typedef enum
{
WDT_WIN_25 = 0x0, //25%<25><><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD>ֹι<D6B9><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
WDT_WIN_50 = 0x1, //50%<25><><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD>ֹι<D6B9><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
WDT_WIN_75 = 0x2, //75%<25><><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD>ֹι<D6B9><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
WDT_WIN_100 = 0x3, //<2F><><EFBFBD><EFBFBD>ֹι<D6B9><CEB9><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
} WDT_TYPE_WIN;
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E1B9B9> */
typedef struct
{
uint32_t WDT_Tms; //<2F><>ʱʱ<CAB1><EFBFBD><E4A3AC>λms
TYPE_FUNCEN WDT_IE; //<2F>ж<EFBFBD>ʹ<EFBFBD><CAB9>
TYPE_FUNCEN WDT_Rst; //<2F><>λʹ<CEBB><CAB9>
WDT_TYPE_CLKS WDT_Clock;//ʱ<><CAB1>ѡ<EFBFBD><D1A1>
WDT_TYPE_WIN WDT_Win; //<2F><>ֹι<D6B9><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
} WWDT_InitStruType;
#define IWDT_RegUnLock() (IWDT->LOCK.Word = 0x1ACCE551)
#define IWDT_RegLock() (IWDT->LOCK.Word = 0x0)
#define IWDT_Enable() {IWDT_RegUnLock();IWDT->CON.EN = 1;IWDT_RegLock();}
#define IWDT_Disable() {IWDT_RegUnLock();IWDT->CON.EN = 0;IWDT_RegLock();}
#define IWDT_Clear() {IWDT_RegUnLock();IWDT->INTCLR.INTCLR = 0;IWDT_RegLock();}
#define IWDT_ITEnable() {IWDT_RegUnLock();IWDT->CON.IE = 1;IWDT_RegLock();}
#define IWDT_ITDisable() {IWDT_RegUnLock();IWDT->CON.IE = 0;IWDT_RegLock();}
#define IWDT_RstEnable() {IWDT_RegUnLock();IWDT->CON.RSTEN = 1;IWDT_RegLock();}
#define IWDT_RstDisable() {IWDT_RegUnLock();IWDT->CON.RSTEN = 0;IWDT_RegLock();}
#define IWDT_CLOCK_PCLK() {IWDT_RegUnLock();IWDT->CON.CLKS = 0;IWDT_RegLock();}
#define IWDT_CLOCK_WDT() {IWDT_RegUnLock();IWDT->CON.CLKS = 1;IWDT_RegLock();}
#define WWDT_RegUnLock() (WWDT->LOCK.Word = 0x1ACCE551)
#define WWDT_RegLock() (WWDT->LOCK.Word = 0x0)
#define WWDT_Enable() {WWDT_RegUnLock();WWDT->CON.EN = 1;WWDT_RegLock();}
#define WWDT_Disable() {WWDT_RegUnLock();WWDT->CON.EN = 0;WWDT_RegLock();}
#define WWDT_Clear() {WWDT_RegUnLock();WWDT->INTCLR.INTCLR = 0;WWDT_RegLock();}
#define WWDT_ITEnable() {WWDT_RegUnLock();WWDT->CON.IE = 1;WWDT_RegLock();}
#define WWDT_ITDisable() {WWDT_RegUnLock();WWDT->CON.IE = 0;WWDT_RegLock();}
#define WWDT_RstEnable() {WWDT_RegUnLock();WWDT->CON.RSTEN = 1;WWDT_RegLock();}
#define WWDT_RstDisable() {WWDT_RegUnLock();WWDT->CON.RSTEN = 0;WWDT_RegLock();}
#define WWDT_CLOCK_PCLK() {WWDT_RegUnLock();WWDT->CON.CLKS = 0;WWDT_RegLock();}
#define WWDT_CLOCK_WDT() {WWDT_RegUnLock();WWDT->CON.CLKS = 1;WWDT_RegLock();}
void IWDT_Init(IWDT_InitStruType *IWDT_InitStruct);
void IWDT_SetReloadValue(uint32_t Value);
uint32_t IWDT_GetValue(void);
FlagStatus IWDT_GetFlagStatus(void);
FlagStatus IWDT_GetITStatus(void);
void WWDT_Init(WWDT_InitStruType *WDT_InitStruct);
void WWDT_SetReloadValue(uint32_t Value);
uint32_t WWDT_GetValue(void);
FlagStatus WWDT_GetFlagStatus(void);
FlagStatus WWDT_GetITStatus(void);
#endif
/*************************END OF FILE**********************/