SY883x_For_Client_JLAB_JS07/UsrSrc/watchdog/watchdog.c

96 lines
2.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
******************************************************************************
*
* @file watchdog.c
* @brief watchdog module
*
*
* @version 1.0
* @date 2022/08/04 15:00:40
* @author Alex Xu
*
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
* All Rights Reserved
*
* History:
* Revision Date Author Desc
* 1.0.0 2022/08/04 Alex build this file
******************************************************************************/
/*_____ I N C L U D E S ____________________________________________________*/
#include "watchdog.h"
#if 0
/*_____ D E F I N I T I O N S ______________________________________________*/
/******************************************************************************\
Macro definitions
\******************************************************************************/
/******************************************************************************\
Variables definitions
\******************************************************************************/
/******************************************************************************\
Functions definitions
\******************************************************************************/
/*_____ F U N C T I O N S __________________________________________________*/
/*
*******************************************************************************
* void Watchdog_Init(uint8_t watchdog_time)
*
* Description : watchdog Initialization. WDT_TM = 0则看门狗时钟为系统时钟的12分频否则为系统时钟。
wdtrel.7=1 则看门狗计数器时钟为Sys_Fre/12*32wdtrel.7=0 则看门狗计数器时钟为Sys_Fre/12*2.
Sys_Fre = 12MHzwdtrel.7=0时定时器范围
(1/Sys_Fre)*12*2*256~(1/Sys_Fre)*12*2*256*128 = 5ms~65ms
Sys_Fre = 12MHzwdtrel.7=1时定时器范围
(1/Sys_Fre)*12*32*256~(1/Sys_Fre)*12*32*256*128 = 80ms~1s
*
* Arguments :
* Returns :
* Notes :
*
*******************************************************************************
*/
void Watchdog_Init(uint8_t watchdog_time)
{
switch(watchdog_time)
{
case _WDT_TIME_65ms_:
WDTREL = 0x00; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
break;
case _WDT_TIME_1s_:
WDTREL = 0x80; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
break;
}
SWDT = 1; //Watchdog Start
}
/*
*******************************************************************************
* void Watchdog_Clear(void)
*
* Description : Feed watchdog 在系统初始化时未进行看门狗初始化,则不能在程序中进行喂狗操作!!!
*
* Arguments :
* Returns :
* Notes :
*
*******************************************************************************
*/
void Watchdog_Clear(void)
{
WDT = 1;
SWDT = 1;
}
#endif