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

📄 frequd.cpp

📁 有关树WDM 驱动的编程.里面包含了许多实例,学习硬件的可以参考哦
💻 CPP
字号:
// frequd.cpp : implementation file
//

#include "stdafx.h"
#include "pctest.h"
#include "frequd.h"
#include "address.h"
#include "adc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern HANDLE	hDevice;
extern HANDLE	hDevice1;
extern  PCHAR mDynVxDName ;
/////////////////////////////////////////////////////////////////////////////
// Cfrequd dialog


Cfrequd::Cfrequd(CWnd* pParent /*=NULL*/)
	: CDialog(Cfrequd::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cfrequd)
	//}}AFX_DATA_INIT
     hDevice1=hDevice=NULL;
}


void Cfrequd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cfrequd)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cfrequd, CDialog)
	//{{AFX_MSG_MAP(Cfrequd)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cfrequd message handlers
void Cfrequd::OnCancel()
{
}
BOOL Cfrequd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	 	if(hDevice==NULL)
	{
	hDevice = CreateFile(mDynVxDName, 0,0,0,
                        CREATE_NEW, 
                        FILE_FLAG_DELETE_ON_CLOSE,
                        0);
	if (hDevice == INVALID_HANDLE_VALUE)
	{
		AfxMessageBox("请检查板卡和驱动程序");
		CDialog::OnCancel();
		return FALSE;
	}
		W_AD=(Write_AD*)malloc(sizeof(Write_AD));
		}

	W_AD->Data=0x082;
	W_AD->Address=IC_8255_type;
    DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void Cfrequd::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	if(hDevice==NULL)
	{
		AfxMessageBox("无效操作");
		return ;
	}

	W_AD->Data=0x16;
	W_AD->Address=IC_8253_type;
    DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
    W_AD->Data=0x30;
	W_AD->Address=IC_8253;
    DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
    W_AD->Data=0x0ff;
	W_AD->Address=IC_8255_A;
    DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);

}

void Cfrequd::OnRadio2() 
{
	// TODO: Add your control notification handler code here
}

void Cfrequd::OnOK() 
{
	// TODO: Add extra validation here
	 W_AD->Data=0;
	W_AD->Address=IC_8255_A;
    DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
	if(hDevice!=NULL)
	{
	CloseHandle( hDevice);
	hDevice=NULL;
	}
		if(hDevice1!=NULL)
	{
	CloseHandle( hDevice1);
	hDevice1=NULL;
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

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