本帖最后由 forlinx2013 于 2014-1-24 09:16 编辑
欢迎大家来到飞凌爱板网专区,对嵌入式技术感兴趣的朋友不妨多多关注一下,我们提供了公司所有开发板的所有资料,也会更新大量技术文章,欢迎大家一块学习提高!!!
看门狗测试应用程序
硬件平台:飞凌OK6410-A 操作系统:飞凌光盘中的BSP,WINCE6.0 编译工具:VS2005 + WINCE6.0 + BSP 打开VS2005,新建一个工程为watchdog_test // watchdog_testDlg.cpp : 实现文件 //
#include "stdafx.h" #include "watchdog_test.h" #include "watchdog_testDlg.h" #include <ceddk.h> #ifdef _DEBUG #define new DEBUG_NEW #endif
#define IOCTL_wdg_wdg1_OPEN 0x04002060 #define IOCTL_wdg_wdg1_CLOSE 0x04002061
BOOL flag_wdg = 1; HANDLE hwdg; HANDLE hThread; DWORD convalue = 4; CString str; //int i; DWORD WINAPI wdgThread (PVOID);
// Cwatchdog_testDlg 对话框
Cwatchdog_testDlg::Cwatchdog_testDlg(CWnd* pParent /*=NULL*/) : CDialog(Cwatchdog_testDlg::IDD, pParent) , value_wdg(_T("")) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); }
void Cwatchdog_testDlg: oDataExchange(CDataExchange* pDX) { CDialog: oDataExchange(pDX); DDX_Control(pDX, IDC_start_wdg, m_ctrl_start); DDX_Text(pDX, IDC_EDIT1, value_wdg); }
BEGIN_MESSAGE_MAP(Cwatchdog_testDlg, CDialog) #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP) ON_WM_SIZE() #endif //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_start_wdg, &Cwatchdog_testDlg::OnBnClickedstartwdg) ON_WM_TIMER() END_MESSAGE_MAP()
// Cwatchdog_testDlg 消息处理程序
BOOL Cwatchdog_testDlg::OnInitDialog() { CDialog::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码 hwdg = CreateFile(TEXT("wdg1:"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if (hwdg == INVALID_HANDLE_VALUE) { printf ("can't open wdg1\r\n"); } else { printf ("Open wdg1\r\n"); } SetTimer(1,1000,NULL); hThread = CreateThread (NULL, 0, wdgThread, NULL, 0, NULL);
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP) void Cwatchdog_testDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/) { if (AfxIsDRAEnabled()) { DRA::RelayoutDialog( AfxGetResourceHandle(), this->m_hWnd, DRA::GetDisplayMode() != DRA: ortrait ? MAKEINTRESOURCE(IDD_WATCHDOG_TEST_DIALOG_WIDE) : MAKEINTRESOURCE(IDD_WATCHDOG_TEST_DIALOG)); } } #endif
DWORD WINAPI wdgThread (PVOID hdcMain) {
Cwatchdog_testDlg *pdlg =(Cwatchdog_testDlg*)(AfxGetApp()->m_pMainWnd);
while (1) { str.Format(_T("%d"),convalue);
pdlg->SetDlgItemTextW(IDC_EDIT1,str); }
return 0;
} void Cwatchdog_testDlg::OnBnClickedstartwdg() { // TODO: Add your control notification handler code here if (flag_wdg) { m_ctrl_start.SetWindowText( TEXT("FEED" ) ); //flag_wdg =0; convalue =4; DeviceIoControl(hwdg,IOCTL_wdg_wdg1_OPEN,NULL, sizeof(DWORD), NULL, 0, 0, NULL); } } void Cwatchdog_testDlg::OnTimer(UINT nIDEvent) { convalue--; }
|