rt-thread/bsp/essemi/es8p508x/libraries/Library/Source/lib_wdt.c

173 lines
4.0 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>
***************************************************************/
#include "lib_wdt.h"
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT_Init
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT<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>
**************************************/
void IWDT_Init(IWDT_InitStruType *WDT_InitStruct)
{
uint32_t tmp;
if (WDT_InitStruct->WDT_Clock != WDT_CLOCK_PCLK)
tmp = (uint32_t)(32 * WDT_InitStruct->WDT_Tms);
else
tmp = SystemCoreClock / 1000 * WDT_InitStruct->WDT_Tms;
IWDT->LOAD.LOAD = tmp;
IWDT->CON.CLKS = WDT_InitStruct->WDT_Clock;
IWDT->CON.IE = WDT_InitStruct->WDT_IE;
IWDT->CON.RSTEN = WDT_InitStruct->WDT_Rst;
return;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT_SetReloadValue
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WDT<EFBFBD><EFBFBD><EFBFBD>صij<EFBFBD>ֵ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼֵ<EFBFBD><EFBFBD>32-bit<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
**************************************/
void IWDT_SetReloadValue(uint32_t Value)
{
IWDT->LOAD.LOAD = Value;
return;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT_GetValue
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDT<EFBFBD><EFBFBD>ǰֵ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰֵ
**************************************/
uint32_t IWDT_GetValue(void)
{
return (uint32_t)IWDT->VALUE.VALUE;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT_GetFlagStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDT<EFBFBD>ж<EFBFBD>״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET/RESET
**************************************/
FlagStatus IWDT_GetFlagStatus(void)
{
FlagStatus bitstatus = RESET;
if (IWDT->RIS.WDTIF != RESET)
bitstatus = SET;
return bitstatus;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IWDT_GetITStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDTʹ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET/RESET
**************************************/
FlagStatus IWDT_GetITStatus(void)
{
FlagStatus bitstatus = RESET;
if (IWDT->CON.IE != RESET)
bitstatus = SET;
return bitstatus;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT_Init
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT<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>
**************************************/
void WWDT_Init(WWDT_InitStruType *WDT_InitStruct)
{
uint32_t tmp;
if (WDT_InitStruct->WDT_Clock != WDT_CLOCK_PCLK)
tmp = (uint32_t)(32 * WDT_InitStruct->WDT_Tms);
else
tmp = SystemCoreClock / 1000 * WDT_InitStruct->WDT_Tms;
WWDT->LOAD.LOAD = tmp;
WWDT->CON.CLKS = WDT_InitStruct->WDT_Clock;
WWDT->CON.IE = WDT_InitStruct->WDT_IE;
WWDT->CON.RSTEN = WDT_InitStruct->WDT_Rst;
WWDT->CON.WWDTWIN = WDT_InitStruct->WDT_Win;
return;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT_SetReloadValue
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WDT<EFBFBD><EFBFBD><EFBFBD>صij<EFBFBD>ֵ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼֵ<EFBFBD><EFBFBD>32-bit<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
**************************************/
void WWDT_SetReloadValue(uint32_t Value)
{
WWDT->LOAD.LOAD = Value;
return;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT_GetValue
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDT<EFBFBD><EFBFBD>ǰֵ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰֵ
**************************************/
uint32_t WWDT_GetValue(void)
{
return (uint32_t)WWDT->VALUE.VALUE;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT_GetFlagStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDT<EFBFBD>ж<EFBFBD>״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET/RESET
**************************************/
FlagStatus WWDT_GetFlagStatus(void)
{
FlagStatus bitstatus = RESET;
if (WWDT->RIS.WWDTIF != RESET)
bitstatus = SET;
return bitstatus;
}
/*************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WWDT_GetIEStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡWDT<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET/RESET
**************************************/
FlagStatus WWDT_GetITStatus(void)
{
FlagStatus bitstatus = RESET;
if (WWDT->CON.IE != RESET)
bitstatus = SET;
return bitstatus;
}
/*************************END OF FILE**********************/