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

📄 mos.cpp

📁 有关树WDM 驱动的编程.里面包含了许多实例,学习硬件的可以参考哦
💻 CPP
字号:
// mos.cpp : implementation file
//
#include "stdafx.h"
#include "pctest.h"
#include "mos.h"
#include "adc.h"
#include "address.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern  PCHAR mDynVxDName ;
#define add_0832  0x31;
#define add_08321  0x30;
int sanj[21]={100,110,120,130,140,150,160,170,180,190,200,190,180,170,160,150,140,130,120,110,100};
int zhs[36]={100,117,134,150,164,176,186,193,198,200,193,186,176,164,150,134,117,100,83,64,50,38,24,14,7,2,0,2,7,20,24,36,50,66,83,100};
/////////////////////////////////////////////////////////////////////////////
// Cmos dialog
Cmos::Cmos(CWnd* pParent /*=NULL*/)
	: CDialog(Cmos::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cmos)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
hDevice=NULL;
}
void Cmos::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cmos)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cmos, CDialog)
	//{{AFX_MSG_MAP(Cmos)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cmos message handlers

void Cmos::OnButton1() 
{
	// TODO: Add your control notification handler code here
for(int j=0;j<5000;j++)
{
	for(int i=0;i<21;i++)
	{
	W_AD->Address =add_0832;
	W_AD->Data=sanj[i];
	DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
    W_AD->Address =add_08321;
	W_AD->Data=0;
	DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
	}

}
	
}
void Cmos::OnButton2() 
{
	// TODO: Add your control notification handler code here
for(int o=0;o<5000;o++)
{
	for(int i=0;i<36;i++)
	{
	W_AD->Address =add_0832;
	W_AD->Data=zhs[i];
	DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
    W_AD->Address =add_08321;
	W_AD->Data=0;
	DeviceIoControl(
					hDevice, 
					IOCTL_IOW,
					W_AD, 
					sizeof(W_AD)+1, 
					NULL, 
					0,
					&nRet, 
 					NULL);
	}
}
	
}
BOOL Cmos::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));
		}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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