⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchdogtdlg.cpp

📁 WINCE 三星2440看门狗程序
💻 CPP
字号:
// WatchdogTDlg.cpp : implementation file
//

#include "stdafx.h"
#include "WatchdogT.h"
#include "WatchdogTDlg.h"
#include "afxmt.h"
#include <atlconv.h>
#include <stdio.h>
#include <Afxtempl.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWatchdogTDlg dialog

CWatchdogTDlg::CWatchdogTDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CWatchdogTDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CWatchdogTDlg)
	m_nTCNT = 0x8000;
	m_nTDAT = 0x8000;
	m_nTCON = 0x8021;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	count = 0;
}

void CWatchdogTDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CWatchdogTDlg)
	DDX_Text(pDX, IDC_ETCNT, m_nTCNT);
	DDX_Text(pDX, IDC_ETCON, m_nTCON);
	DDX_Text(pDX, IDC_ETDAT, m_nTDAT);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CWatchdogTDlg, CDialog)
	//{{AFX_MSG_MAP(CWatchdogTDlg)
	ON_BN_CLICKED(IDC_BT_START, OnBtStart)
	ON_BN_CLICKED(IDC_BT_STOP, OnBtStop)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWatchdogTDlg message handlers

BOOL CWatchdogTDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	v_pWTPRegs = (volatile WTPreg *)VirtualAlloc(0, sizeof(WTPreg), MEM_RESERVE, PAGE_NOACCESS);
	VirtualCopy((PVOID)v_pWTPRegs, (PVOID)WTP_BASE, sizeof(WTPreg), PAGE_READWRITE|PAGE_NOCACHE);
	//v_pWTPRegs->rGWTCNT = m_nTCNT;
	//v_pWTPRegs->rGWTCON = m_nTCON;  
	//v_pWTPRegs->rGWTDAT = m_nTDAT;
	
//	v_pIOPRegs = (volatile IOPreg *)VirtualAlloc(0, sizeof(IOPreg), MEM_RESERVE, PAGE_NOACCESS);
//	VirtualCopy((PVOID)v_pIOPRegs, (PVOID)IOP_BASE, sizeof(IOPreg), PAGE_READWRITE|PAGE_NOCACHE);

//	m_nTimer = SetTimer(1, 5, 0);	
	return TRUE;  // return TRUE  unless you set the focus to a control
}


void CWatchdogTDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void CWatchdogTDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}



void CWatchdogTDlg::OnBtStart() 
{
	// TODO: Add your control notification handler code here
	m_nTimer = SetTimer(1, 5, 0);	
	UpdateData(true);
	v_pWTPRegs->rGWTCNT = m_nTCNT;
	v_pWTPRegs->rGWTCON = m_nTCON;  
	v_pWTPRegs->rGWTDAT = m_nTDAT;
		
}

void CWatchdogTDlg::OnBtStop() 
{
	// TODO: Add your control notification handler code here
	KillTimer(m_nTimer);  	
}

void CWatchdogTDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CDC* my_pDC = GetDC();
	CString s;
	v_pWTPRegs->rGWTCNT = m_nTCNT;
	s.Format(_T(" %d"),count);
	count++;
	my_pDC->DrawText(s, -1,CRect(10, 80, 160, 180), 0);
	ReleaseDC(my_pDC);
	CDialog::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -