Support, 6 watchdog example, Ktt20/pitx software guide – Kontron KTT20-pITX User Manual
Page 51
KTD-S0045-D
Page 47 Windows® Embedded Compact 7 (WEC7) BSP
KTT20/pITX Software Guide
11.5 I
2
C
TM
Support
Do not use the BSP I
2
C
TM
example. The connector J2000 involves the camera interface and likely this con-
nector is not assembled in the future.
11.6 Watchdog Example
#include
#include
#define WDT_CNT_MAX
10
#define WDT_CNT_TIME
1000
// 1 second
#define WDT_CNT_ABORT
20
int _tmain (int argc, TCHAR *argv[])
{
HANDLE hWdt;
LPCWSTR pszWdtName = L"wdtdemo";
DWORD dwWdtPeriod = 5000;
// 5 seconds
DWORD dwWdtWait = 1000;
// 1 second
DWORD dwCount;
wprintf (TEXT ("Start watchdog demo\r\n"));
hWdt = CreateWatchDogTimer (pszWdtName, dwWdtPeriod, dwWdtWait, WDOG_RESET_DEVICE, 0, 0);
if (! hWdt)
{
wprintf (TEXT ("Error: invalid handle\r\n"));
return
1;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
wprintf (TEXT ("Error: watchdog name already exists\r\n"));
return
FALSE;
}
if (! StartWatchDogTimer (hWdt, 0))
{
wprintf (TEXT ("Error: StartWatchDogTimer failed\r\n"));
CloseHandle
(hWdt);
return
FALSE;
}
dwCount = 0;
while ((dwCount++) < WDT_CNT_MAX)
{
wprintf (TEXT ("Refreshing watchdog timer. Count = %d of %d\r\n"), dwCount, WDT_CNT_MAX);
if (! RefreshWatchDogTimer (hWdt, 0))
{
wprintf (TEXT("Error: RefreshWatchDogTimer failed\r\n"));
CloseHandle
(hWdt);
return
FALSE;
}