?? drv_watchdog.c
字號:
#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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -