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

📄 usbdevicecommand.cpp

📁 51单片机众多优秀的开发源程序:ZLG7290例程*ZLG7290汇编例程*蜂鸣器音乐例程*蜂鸣器响例程*读EEPROM并显示例程*16×2LCD模块例程*128×64点阵LCD模块例程*直连KEY和
💻 CPP
字号:

#include "stdafx.h"

#include "E2PROM_1581Dlg.h"
#include "UsbDeviceCommand.h"
#include "EasyISP1581Ex.h"


UINT BulkReadPipe(void * pParam) 
{  

    char temp [80],cc[80];
	int nResult=0;
	int nBytes = 0;
	UINT totaltoTx=0, toTxNow=0, exitFlag=0;
	THREADPARAM * threadParam;
	CE2PROM_1581Dlg* testDlg;
	
	threadParam=(THREADPARAM *)pParam;
	testDlg = threadParam->testDlg;
				

	nResult=Ex_Vender_E2prom(0x01,threadParam->startaddr,threadParam->length);
	if(nResult!=0)
	{
		wsprintf (cc, "Requesting data transfer on ");
		strcat( cc, "PIPE02");
		strcat( cc, " failed! Aborted.");
		testDlg->MessageBox((LPCSTR)cc, "Test Error");
		goto readexit;
	}
	
	nBytes=Ex_ReadData(2,threadParam->buffer,threadParam->length,1000);

	if (nBytes<=0) 
	{
		wsprintf (cc, "Data transfer on ");
		strcat( cc, "PIPE02");
		strcat( cc, " failed! Aborted.");
		testDlg->MessageBox((LPCSTR)cc, "Test Error");
	}			 
	else
	{
		testDlg->UpdateReadData();		
	}
readexit:	
	testDlg->EnableButton(true,true,true,true);
    return 0; 	
} 

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

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


	nResult=Ex_Vender_E2prom(0x00,threadParam->startaddr,threadParam->length);

	if(nResult!=0)
	{
		wsprintf (cc, "Requesting data transfer on ");
		strcat( cc, "PIPE03");
		strcat( cc, " failed! Aborted.");
		testDlg->MessageBox((LPCSTR)cc, "Test Error");
		goto writeexit;
	}
	
	nBytes=Ex_WriteData(3,threadParam->buffer,threadParam->length,1000);

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

writeexit:
	testDlg->EnableButton(true,true,true,true);
	return 0; 
} 

UINT ControlIn(void * pParam)
{ 
	
    BOOLEAN bResult = FALSE;
    ULONG nBytes = 0;
	unsigned char version=0;
	THREADPARAM * threadParam;
	CE2PROM_1581Dlg* testDlg;
	
	threadParam=(THREADPARAM *)pParam;
	testDlg = (CE2PROM_1581Dlg*)threadParam->testDlg;
	
	if(Ex_Vender_Read(version)==0)
	{
		if(version==0x21)
		{
			testDlg->SetWindowText("   DP-1581");
			testDlg->EnableButton(true,false,true,false);
		}
		else if(version==0x22)
		{
			testDlg->SetWindowText("   USBPACK 2.0");
			testDlg->EnableButton(true,false,true,false);
		}
		else
		{
			testDlg->SetWindowText("Unknown Board");
			testDlg->EnableButton(false,false,false,false);
			return 0;
		}
	}
	else
	{
		testDlg->SetWindowText("No Board Attached ");
		testDlg->EnableButton(false,false,false,false);
		return 0;
	}
	
	testDlg->EnableButton(true,true,true,true);
	
	return 0;
}

⌨️ 快捷键说明

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