drv_watchdog.c
来自「CC1000 Rf modem C codes for philips sLpc」· C语言 代码 · 共 67 行
C
67 行
#include "config_GD61.h"
#include "include_GD61.h"
//#include <stdio.h>
//////////////////////////////////////////////////////////////////
void WatchDog_Start(uint32 Xms);
void WatchDogStart(uint32 Xms);
void WatchDogClear(void);
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
void __irq IRQ_WATCHDOG(void)
{
VICIntEnClr = 1<<INT_WDT;
WDMOD = 0x02; //change the watchdog to reset mode
VICVectAddr = 0x00000000; //end the interrupt process
}
//////////////////////////////////////////////////////////////////
void WatchDog_Start(uint32 Xms)
{
IRQDisable();
/* 设置watchdog中断IRQ */
// VICIntSelect = 0x00000000; /* 所有中断通道设置为IRQ中断*/
VICVectCntl7 = 0x20|INT_WDT; /* 设置watchdog中断通道*/
VICVectAddr7 = (uint32)IRQ_WATCHDOG; /* 设置中断服务程序地址*/
VICIntEnable = 1<<INT_WDT; /* watchdog中断*/
//
WDMOD = 0x01; // 设置看门狗模式:中断
WDTC = (LPC_FPCLK/4000)*Xms; // 设置看门狗定时器参数 LPC_FPCLK
WDFEED = 0xAA; // 第一次喂狗启动WDT
WDFEED = 0x55;
IRQEnable(); // 使能IRQ中断
}
/////////////////////////////////////////////////////////////////
/*
void WatchDogStart(uint32 Xms)
{
char dbuffer[100];
WatchDog_Start(Xms);
sprintf(dbuffer,"Startup WatchDog, Set reset time = %d ms",Xms);
Uart0SendString(dbuffer);
}
*/
/////////////////////////////////////////////////////////////////
void WatchDogClear(void)
{
IRQDisable();
WDFEED = 0xAA; //reset the WDT
WDFEED = 0x55;
IRQEnable(); // 使能IRQ中断
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
/////////////////////// end of file ///////////////////////////
////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?