// WatchDog.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "PACSDK.h" #include "stdio.h" #include "conio.h" int main(int argc, char* argv[]) { int num,refresh_interval; long WDTTime,WDTType; bool bQuit=false; unsigned long refresh_fre=0; //Choose watch dog type printf("Choose watch dog type:\n\r" "1.OS\n" "2.Hardware\n" "input number:"); scanf("%d",&num); if(num==1) { //Get watch dog time printf("Input watch dog time(unit is second):"); scanf("%ld",&WDTTime); //Get refresh interval printf("Input refresh interval:"); scanf("%d",&refresh_interval); //millisecond for Sleep() refresh_interval=refresh_interval*1000; WDTType=1; //Enable watch dog pac_EnableWatchDog(WDTType,WDTTime); } else if(num==2) { //Get watch dog time printf("Input watch dog time(unit is 0.5 second),range is 0~63:"); scanf("%ld",&WDTTime); //Get refresh interval printf("Input refresh time interval(unit is 0.5 second),range is 0~63:"); scanf("%d",&refresh_interval); //millisecond for Sleep() refresh_interval=refresh_interval*1000/2; WDTType=0; //Enable watch dog pac_EnableWatchDog(WDTType,WDTTime); } printf("1: Stop refreshing watch dog\n" "2: Disable and stop refreshing watch dog\n" ); int data; while(!bQuit) { Sleep(refresh_interval); //Refresh watch dog pac_RefreshWatchDog(WDTType); printf("Refresh frequency:%lu\r",++refresh_fre); if(kbhit()) { data=getch(); //49='1' if(data==49) { //1: Stop refreshing watch dog bQuit=true; printf("\nWait to reboot."); } else if(data==50) //50='2' { //2: Disable and stop refreshing watch dog pac_DisableWatchDog(WDTType); bQuit=true; printf("\nDisable watch dog."); } } } printf("\npress any key to exit"); getch(); return 0; }