1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include "Platform.h"
- /* ---------------------------------------------------------------------------------------------------
- //看门狗计数器对应的初值
- (0x0)0000:0x FFFF
- (0x1)0001:0x 1FFFF
- (0x2)0010:0x 3FFFF
- (0x3)0011:0x 7FFFF
- (0x4)0100:0x FFFFF
- (0x5)0101:0x 1FFFFF
- (0x6)0110:0x 3FFFFF
- (0x7)0111:0x 7FFFFF
- (0x8)1000:0x FFFFFF----约2S
- (0x9)1001:0x 1FFFFFF----约5S
- (0xA)1010:0x 3FFFFFF----约10S
- (0xB)1011:0x 7FFFFFF----约20S
- (0xC)1100:0x FFFFFFF
- (0xD)1101:0x1FFFFFFF
- (0xE)1110:0x3FFFFFFF
- (0xF)1111:0x7FFFFFFF
- ----------------------------------------------------------------------------------------------------*/
- /* ---------------------------------------------------------------------------------------------------
- - 函数名称: xc_wdog_init
- - 函数功能: 初始化看门狗
- - 函数形参:看门狗计数器重装值
- - 创建日期: 2019-04-22
- - 创 建 人:陈俊伟
- ----------------------------------------------------------------------------------------------------*/
- void xc_wdog_init(uint32_t counter_value)
- {
- __write_hw_reg32(CPR_CTLAPBCLKEN_GRCTL,0x10001); //WDT_PCLK 时钟使能
- __write_hw_reg32(CPR_RSTCTL_CTLAPB_SW,0x40000); //WDT 模块软复位
- __write_hw_reg32(CPR_RSTCTL_CTLAPB_SW,0x40004);
- __write_hw_reg32(CPR_RSTCTL_WDTRST_MASK,0x20);//屏蔽 WDT 引起的 M0 的软复位,不屏蔽 WDT 引起的系统的软复位
- __write_hw_reg32(WDT_CR,0x7);// WDT 使能 ,M0 复位信号,维持4个 pclk 时钟周期,工作模式 0,直接产生复位信号送给 CPR
- __write_hw_reg32(WDT_TORR,counter_value);
- __write_hw_reg32(WDT_CRR,0x76); //重启计数器
- }
- /* ---------------------------------------------------------------------------------------------------
- - 函数名称: xc_wdog_feed
- - 函数功能: 喂看门狗
- - 函数形参:无
- - 创建日期: 2019-04-22
- - 创 建 人:陈俊伟
- ----------------------------------------------------------------------------------------------------*/
- void xc_wdog_feed(void)
- {
- __write_hw_reg32(WDT_CRR,0x76); //重启计数器
- }
|