亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? seeddecusb.cpp

?? HOST和DSP利用USB通信
?? CPP
字號:
/**********************************************************************/
/* this file is the function for test the seeddec55XX driver and devic*/
/*	author lifeng Duan												  */
/*	Lt.d	SEED													  */
/**********************************************************************/
#include "stdafx.h"
#include "winioctl.h"
#include "stdio.h"
#include <conio.h>
#include <malloc.h>
#include <assert.h>
#include "ezusbsys.h"
#include "seeddecusb.h"

const PCHAR StaticDriverName = "\\\\.\\decusb-0";

/*全局的驅動句柄*/
HANDLE  hDevice = NULL;
DWORD Sx2_devdesc[200];
DWORD Sx2_strdesc[200];
DWORD Sx2_configdesc[200];
/*USB的接口信息*/
USBD_INTERFACE_INFORMATION Sx2InterfaceInfo;
PUSBD_INTERFACE_INFORMATION	pSx2InterfaceInfo = &Sx2InterfaceInfo;
PUSBD_PIPE_INFORMATION pPipe;

BOOLEAN	Sx2BulkdataTrans(PVOID bulkControl,
						 char *buffer,
						 int bufferSize,
						 int *recnBytes);
/**************************************************/
/* OpenDriver()		                              */
/* Purpose:                                       */ 
/*      Opens the device driver using symbolic    */
/*      name provided                             */
/* Input:                                         */
/*			none								  */
/* Return Value:                                  */
/*      Boolean that indicates if the driver was  */
/*      successfully opened or not.               */
/**************************************************/
BOOLEAN	OpenDriver()
{
	/*打開驅動程序*/
	hDevice = CreateFile(	StaticDriverName,/*驅動程序的符號連接*/
		                    GENERIC_READ | GENERIC_WRITE,
		                    FILE_SHARE_WRITE,
		                    NULL,
		                    OPEN_EXISTING,
		                    0,
		                    NULL);
    if (hDevice == INVALID_HANDLE_VALUE) 
	{
        return (FALSE);
    }
	/*獲得USB的接口信息*/
	Sx2GetPipeInfo((PVOID)&Sx2InterfaceInfo);
	return (TRUE);
}
/**********************************************************************/
/* CloseDriver()													  */
/* Purpose:															  */ 
/*      Close the device driver using symbolic						  */
/* Input:															  */
/*			none													  */
/* Return Value:													  */
/*			none													  */
/**********************************************************************/
void CloseDriver()
{
	// Close the handle
	CloseHandle (hDevice);
	//清空狀態區
	pSx2InterfaceInfo= NULL;
}
/**********************************************************************/
/*	get the device descriptor										  */
/*	purpose:														  */
/*			get the device descriptor for the CY7c68001			      */
/*	Input:															  */
/*			none													  */
/* Return Value:												      */
/*      the point for device descriptor								  */
/**********************************************************************/
PVOID Sx2GetDeviceDesc()
{
	DWORD * pvBuffer = 0;
	int     nBytes   = 0;
	BOOLEAN bResult  = FALSE;
	int     i        = 0;
	// Get some memory, plus some guardband area
	pvBuffer = (DWORD *)malloc (sizeof (Usb_Device_Descriptor) + 128);
	// Perform the Get-Descriptor IOCTL
	bResult = DeviceIoControl ( hDevice,
								IOCTL_Ezusb_GET_DEVICE_DESCRIPTOR,
								pvBuffer,
								sizeof (Usb_Device_Descriptor),
								pvBuffer,
								sizeof (Usb_Device_Descriptor),
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{
		free (pvBuffer); 
		return NULL;
	}
	for(i =0;i<sizeof(Usb_Device_Descriptor);i++)
	{
		Sx2_devdesc[i] =pvBuffer[i];
	}
	// Free the memory
	free (pvBuffer); 
	return (PVOID)&Sx2_devdesc[0];
}
/**********************************************************************/
/*	get the string descriptor										  */
/*	purpose:														  */
/*			get the string descriptor for the CY7c68001			      */
/*	Input:															  */
/*			none													  */
/* Return Value:												      */
/*      the point for string descriptor								  */
/**********************************************************************/
PVOID Sx2GetStringDesc(int stringindex)
{
	DWORD * pvBuffer = 0;
	int     nBytes   = 0;
	BOOLEAN bResult  = FALSE;
	int     i        = 0;
	int   ulLength = 0;
	GET_STRING_DESCRIPTOR_IN input;
	input.Index = stringindex;
	// NOTE: frameworks ignores it anyway
	input.LanguageId = 0; 
	
	// Get some memory, plus some guardband area
	pvBuffer = (DWORD *)malloc (sizeof (Usb_String_Descriptor) + 128);
	// The string descriptor is obtained using two separate calls.  
	// The first call is done to determine the size of the entire string descriptor,
	// The second call is done with that total size specified. 

	// Get the first bytes of the descriptor to determine the size of the entire descriptor.
	// Perform the Get-Descriptor IOCTL
	bResult = DeviceIoControl (	hDevice,
								IOCTL_Ezusb_GET_STRING_DESCRIPTOR,
								&input,
								sizeof (GET_STRING_DESCRIPTOR_IN),
								pvBuffer,
								sizeof (Usb_String_Descriptor),
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{
		free(pvBuffer);
		return NULL;
	}
	ulLength = GET_STRING_DESCRIPTOR_LENGTH(pvBuffer);
	assert (ulLength >= 0);
	// Now get the entire descriptor
	//重新分配內存
	pvBuffer = (DWORD *)realloc (pvBuffer, ulLength);
	// Perform the Get-Descriptor IOCTL
	bResult = DeviceIoControl ( hDevice,
								IOCTL_Ezusb_GET_STRING_DESCRIPTOR,
								&input,
								ulLength,
								pvBuffer,
								ulLength,
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{
		free (pvBuffer); 
		return NULL;
	}
	for(i =0;i<ulLength;i++)
	{
		Sx2_strdesc[i] =pvBuffer[i];
	}
	free (pvBuffer); // Free the memory
	return (PVOID)&Sx2_strdesc[0];
}
/**********************************************************************/
/*	get the configuration descriptor    							  */
/*	purpose:														  */
/*			get the configuration descriptor for the CY7c68001	      */
/*	Input:															  */
/*			none													  */
/* Return Value:												      */
/*      the point for string descriptor								  */
/**********************************************************************/
PVOID Sx2GetconfigDesc()
{
	DWORD * pvBuffer = 0;
	int     nBytes   = 0;
	BOOLEAN bResult  = FALSE;
	int     i        = 0;
	int   ulLength = 0;
	// The configuration descriptor is obtained using two separate calls.  
	// The first call is done to determine the size of the entire configuration descriptor,
	// The second call is done with that total size specified.
	pvBuffer = (DWORD *)malloc (sizeof (Usb_Configuration_Descriptor) + 128);
	// Get the first bytes of the configuration descriptor to determine the size of
	// the entire configuration descriptor.
	// Perform the Get-Descriptor IOCTL
	bResult = DeviceIoControl (	hDevice,
								IOCTL_Ezusb_GET_CONFIGURATION_DESCRIPTOR,
								pvBuffer,
								sizeof (Usb_Configuration_Descriptor),
								pvBuffer,
								sizeof (Usb_Configuration_Descriptor),
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{
		free(pvBuffer);
		return NULL;
	}
	ulLength = GET_CONFIG_DESCRIPTOR_LENGTH(pvBuffer);
	assert (ulLength >= 0);
	// Now get the entire descriptor
	//重新分配內存
	pvBuffer = (DWORD *)realloc (pvBuffer, ulLength);
	// Perform the Get-Descriptor IOCTL
	bResult = DeviceIoControl ( hDevice,
								IOCTL_Ezusb_GET_CONFIGURATION_DESCRIPTOR,
								pvBuffer,
								ulLength,
								pvBuffer,
								ulLength,
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{
		free (pvBuffer); 
		return NULL;
	}
	for(i =0;i<ulLength;i++)
	{
		Sx2_configdesc[i] =pvBuffer[i];
	}
	free (pvBuffer); // Free the memory
	return (PVOID)&Sx2_configdesc[0];
}
/**********************************************************************/
/*	get the USB's interface 		    							  */
/*	purpose:														  */
/*				get the interface desc of the CY7c68001  		      */
/*	Input:															  */
/*			the interface's struct  								  */
/*																	  */
/* Return Value:												      */
/*      the point for string descriptor								  */
/**********************************************************************/
BOOLEAN Sx2GetPipeInfo(PVOID pInterface)
{
	BOOLEAN bResult  = FALSE;
	int     nBytes   = 0;

	bResult = DeviceIoControl ( hDevice,
								IOCTL_Ezusb_GET_PIPE_INFO,
								NULL,
								0,
								pInterface,
								sizeof(USBD_INTERFACE_INFORMATION),
								(unsigned long *)&nBytes,
								NULL);
	if(bResult ==FALSE)
	{ 
		return FALSE;
	}
	return TRUE;
}
/**********************************************************************/
/*	send the vendor request			    							  */
/*	purpose:														  */
/*				send the vendor request to the CY7c68001		      */
/*	Input:															  */
/*			the point of myRest struct								  */
/*																	  */
/* Return Value:												      */
/*      the point for string descriptor								  */
/**********************************************************************/
BOOLEAN Sx2SendVendorReq(PVOID myRequest,
						 char *buffer,
						 int bufferSize,
						 int *recnBytes)
{
	int nBytes = 0;
	bool bResult = FALSE;
	// 引發usb SX2_INT_SETUP中斷,在中斷中讀取8個字節的request數據
	bResult = DeviceIoControl (	hDevice,
								IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST,
								myRequest,
								sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL),
								buffer,
								bufferSize,
								(unsigned long *)&nBytes,
								NULL);
	if(bResult == FALSE)
	{
		return FALSE;
	}
	*recnBytes = nBytes;
	return TRUE;
}
/**********************************************************************/
/*	bulk date translate  			    							  */
/*	purpose:														  */
/*				stranslate the data between PC and the CY7c68001      */
/*	Input:															  */
/*			the point of myRest struct								  */
/*																	  */
/* Return Value:												      */
/*      the point for string descriptor								  */
/**********************************************************************/
BOOLEAN	Sx2BulkdataTrans(PVOID bulkControl,
						 char *buffer,
						 int bufferSize,
						 int *recnBytes)
{
	int nBytes = 0;
	bool bResult = FALSE;
	PUSBD_PIPE_INFORMATION pPipe = pSx2InterfaceInfo->Pipes;
	// 寫usb pipe,引發usb SX2_INT_FLAGS 中斷
	DWORD ioctl_val = IOCTL_EZUSB_BULK_WRITE;
	printf("endpoint::%d\n",pPipe[((PBULK_TRANSFER_CONTROL)bulkControl)->pipeNum].EndpointAddress >> 7);
	if(pPipe[((PBULK_TRANSFER_CONTROL)bulkControl)->pipeNum].EndpointAddress >> 7)
	{
		ioctl_val = IOCTL_EZUSB_BULK_READ;// 讀usb pipe,不會引發中斷
		
	}
	bResult = DeviceIoControl ( hDevice,
								ioctl_val, 
								bulkControl,
								sizeof (BULK_TRANSFER_CONTROL),
								buffer,
								bufferSize,
								(unsigned long *)&nBytes,
								NULL);
	if(bResult == FALSE)
	{
		return FALSE;
	}
	*recnBytes = nBytes;
	return TRUE;
}

	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91免费精品国自产拍在线不卡| 自拍偷拍亚洲欧美日韩| 精品一二三四区| 2020国产精品自拍| 国产乱码精品一区二区三区五月婷 | 欧美一区二区福利视频| 日韩电影在线看| 欧美精品一区二区三区蜜桃视频| 韩国三级电影一区二区| 国产日韩欧美不卡| 91丨九色porny丨蝌蚪| 亚洲图片欧美综合| 日韩天堂在线观看| 国产高清无密码一区二区三区| 国产精品久久久久久一区二区三区| 91麻豆蜜桃一区二区三区| 五月天一区二区| 久久蜜桃av一区精品变态类天堂 | 伊人开心综合网| 91精品国产综合久久福利软件| 麻豆一区二区在线| 中文字幕av一区二区三区免费看| 色8久久精品久久久久久蜜| 爽好多水快深点欧美视频| 欧美成人乱码一区二区三区| 不卡av电影在线播放| 亚洲一区二区三区三| 欧美不卡在线视频| 91一区二区三区在线播放| 免费人成黄页网站在线一区二区| 中文字幕乱码日本亚洲一区二区| 欧美在线一二三| 国产在线一区二区| 亚洲国产成人精品视频| 欧美精彩视频一区二区三区| 欧美系列亚洲系列| 国产黄色精品网站| 爽好久久久欧美精品| 国产精品电影院| 精品入口麻豆88视频| 欧洲人成人精品| www.激情成人| 国产一区二区精品久久99| 亚洲一区二区三区免费视频| 国产午夜精品一区二区| 日韩视频在线观看一区二区| 91免费看片在线观看| 国产成人a级片| 久久激情五月婷婷| 一区二区三区中文在线观看| 国产亚洲精品aa午夜观看| 欧美日韩亚洲不卡| 色哟哟在线观看一区二区三区| 国内精品在线播放| 人妖欧美一区二区| 亚洲sss视频在线视频| 亚洲乱码一区二区三区在线观看| 久久久精品黄色| 欧美不卡一二三| 日韩一级视频免费观看在线| 欧美唯美清纯偷拍| 91国偷自产一区二区使用方法| 成人黄色小视频| 国产suv精品一区二区883| 国产永久精品大片wwwapp| 激情偷乱视频一区二区三区| 琪琪一区二区三区| 免费美女久久99| 麻豆精品一区二区| 久久99久久久欧美国产| 日韩高清在线一区| 日本aⅴ亚洲精品中文乱码| 日韩精品三区四区| 日韩二区三区在线观看| 亚洲成人777| 五月天视频一区| 蜜臀久久久久久久| 麻豆精品国产91久久久久久| 蜜臀av在线播放一区二区三区| 免费观看在线色综合| 蜜臀久久99精品久久久久宅男| 欧美aaa在线| 美日韩一区二区| 韩日av一区二区| 岛国av在线一区| 91丨九色丨蝌蚪丨老版| 在线欧美一区二区| 欧美高清精品3d| 日韩一区二区在线观看视频播放| 欧美大度的电影原声| 国产亚洲欧美色| 亚洲欧洲美洲综合色网| 一区二区三区电影在线播| 午夜欧美2019年伦理| 青椒成人免费视频| 国产精品99久久久久| 91丨porny丨户外露出| 欧美日韩亚洲另类| 欧美变态凌虐bdsm| 中文字幕一区二区三区精华液| 亚洲综合在线第一页| 麻豆精品在线播放| 成人少妇影院yyyy| 色综合av在线| 日韩久久免费av| 国产精品欧美一区喷水| 一区二区三区 在线观看视频| 香港成人在线视频| 激情伊人五月天久久综合| 粉嫩嫩av羞羞动漫久久久| 91久久精品一区二区三| 欧美一区二区三区免费大片| 中文字幕乱码日本亚洲一区二区 | 美女一区二区久久| 丁香啪啪综合成人亚洲小说| 在线视频亚洲一区| 欧美mv日韩mv亚洲| 一区二区三区四区亚洲| 蜜臀a∨国产成人精品| 91网站最新网址| 精品美女在线播放| 亚洲精品久久久蜜桃| 久久99国产精品久久99果冻传媒| 97精品国产露脸对白| 日韩欧美国产不卡| 亚洲精品国产一区二区三区四区在线 | 国产夫妻精品视频| 欧美亚洲动漫另类| 日本一二三不卡| 免费看精品久久片| 色8久久精品久久久久久蜜| xf在线a精品一区二区视频网站| 一区二区三区四区不卡视频| 国产精品一二三区| 日韩视频国产视频| 亚洲成人av免费| 91老师片黄在线观看| 国产亚洲精品超碰| 久久激情五月激情| 欧美一区二区国产| 亚洲一二三四久久| www.欧美精品一二区| 久久久久9999亚洲精品| 欧美aaaaaa午夜精品| 欧美日韩国产综合一区二区三区| 一区在线播放视频| 成人激情免费视频| 国产婷婷色一区二区三区在线| 美女高潮久久久| 欧美一区二区性放荡片| 一二三四区精品视频| 91年精品国产| 亚洲丝袜美腿综合| 9i在线看片成人免费| 欧美国产一区在线| 国产成人夜色高潮福利影视| 精品国产乱码久久久久久久 | 国产精品一区二区91| 精品国产91久久久久久久妲己| 五月综合激情婷婷六月色窝| 91色在线porny| 中文字幕一区二区三区在线观看 | 亚洲一线二线三线视频| 91香蕉视频mp4| 亚洲特级片在线| 91免费精品国自产拍在线不卡| 亚洲啪啪综合av一区二区三区| av午夜精品一区二区三区| 国产精品欧美一区喷水| 99精品在线免费| 亚洲另类在线制服丝袜| 欧洲av在线精品| 亚洲成人综合网站| 欧美精品精品一区| 美女视频黄 久久| 亚洲精品在线观看视频| 狠狠久久亚洲欧美| 中文字幕不卡一区| 色综合视频在线观看| 亚洲柠檬福利资源导航| 欧美日韩一区二区三区四区 | 欧美在线观看一区二区| 亚洲一二三四区| 日韩亚洲欧美综合| 国产成人av自拍| 亚洲女人小视频在线观看| 91福利国产精品| 美国毛片一区二区三区| 国产亚洲女人久久久久毛片| 99久久99久久精品国产片果冻| 亚洲线精品一区二区三区八戒| 日韩欧美的一区二区| 高清国产一区二区三区| 亚洲国产日韩综合久久精品| 欧美电视剧在线看免费| 99re66热这里只有精品3直播| 亚洲成人激情综合网| 精品久久一二三区| 99热精品国产| 免费欧美高清视频|