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

📄 usbdevicecommand.cpp

📁 周立功公司的USB2.0芯片ISP1581的键盘上位机VC编的源程序
💻 CPP
字号:

#include "stdafx.h"

#include "TimeAndKeyDlg.h"
#include "UsbDeviceCommand.h"
#include "EasyISP1581Ex.h"


UINT BulkReadPipe(void * pParam) 
{  
	int nResult=0;
	int nBytes = 0;
	UINT totaltoTx=0, toTxNow=0, exitFlag=0;
	THREADPARAM * threadParam;
	CTimeAndKeyDlg* testDlg;
	
	threadParam=(THREADPARAM *)pParam;
	testDlg = threadParam->testDlg;
					

	while(threadParam->bInThread&&testDlg->m_nboard)
	{
		Sleep(1);
		nBytes=Ex_ReadData(0,threadParam->buffer,4);
		if(testDlg->m_nboard==0)
			break;
		if(nBytes>0)
			testDlg->UpdateReadData();
		else
			break;
	}

	threadParam->bInThread=false;
    return 0; 	
} 

UINT BulkWritePipe(void * pParam) 
{  
    char cc[80];
	int nResult=0;
	int nBytes = 0;
	THREADPARAM * threadParam;
	CTimeAndKeyDlg* testDlg;

	threadParam=(THREADPARAM *)pParam;
	testDlg = threadParam->testDlg;

	nBytes=Ex_WriteData(1,threadParam->buffer,8,50);

	if (nBytes<=0) 
	{
		wsprintf (cc, "Data transfer on ");
		strcat( cc, "PIPE01");
		strcat( cc, " failed! Aborted.");
		testDlg->MessageBox((LPCSTR)cc, "Test Error");			
	}
	return 0; 
} 

UINT ControlIn(void * pParam)
{ 
	
    BOOLEAN bResult = FALSE;
    ULONG nBytes = 0;
	unsigned char version=0;
	THREADPARAM * threadParam;
	CTimeAndKeyDlg* testDlg;
	
	threadParam=(THREADPARAM *)pParam;
	testDlg = (CTimeAndKeyDlg*)threadParam->testDlg;
	
	if(testDlg->m_nboard)
	{
		if(Ex_Vender_Read(version)==0)
		{
			return 0;
		}
	}
	testDlg->m_nboard=0;
	testDlg->m_readparam.hThread=NULL;
/*	if(ISP1581_Init()!=0)
	{
		testDlg->SetWindowText("No Board Attached ");
		testDlg->EnableButton(false);
		return 0;
	}
	testDlg->m_devhandle = ISP1581_OpenDev();
	if(testDlg->m_devhandle == INVALID_HANDLE_VALUE)
	{
		testDlg->SetWindowText("No Board Attached ");
		testDlg->EnableButton(false);
		return 0;		
	}
*/
	if(Ex_Vender_Read(version)==0)
	{
		if(version==0x21)
		{
			testDlg->SetWindowText("   DP-1581");
		}
		else
		{
			testDlg->SetWindowText("Unknown Board");
			testDlg->EnableButton(false);
			return 0;
		}
	}
	else
	{
		testDlg->SetWindowText("No Board Attached ");
		testDlg->EnableButton(false);
		return 0;
	}
	
	testDlg->EnableButton(true);
	testDlg->m_nboard=1;
	
	testDlg->m_readparam.bInThread=true;
	CWinThread *wt=AfxBeginThread(BulkReadPipe,&(testDlg->m_readparam));
	testDlg->m_readparam.hThread=wt->m_hThread;

	return 0;
}

⌨️ 快捷键说明

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