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

📄 halusbhost.h

📁 威望公司MP3 + USB MCU 的参考软件
💻 H
字号:
/****************************************************************
*                      Viaon Technology (Suzhou) Co.,Ltd
*
*    Copyright 2007, Viaon Technology (Suzhou) Co.,Ltd,Suzhou,China
*                    All rights reserved.
*
*
* Filename:      	halusbhost.h
*
* Programmer:    	Greg 
*
* Created: 	 	1/2/2008
*
* Description: 		public functions 
*              
*        
* Change History (most recent first):	2008.1.2
****************************************************************/
#ifndef __HALUSBHOST_H__
#define __HALUSBHOST_H__
//#include "ABSACC.H"
#include "utiltypedef.h"
#include "va4010regsdk.h"
////////////////////////////////////
//////////////////////////////////////
#define USB_DEV_ADDR		0x01
#define RD_FLAG_BUF			0x00
#define RD_FLAG_TEMP		0x01


#define ISO_BIT     0x10
#define MAX_EP    	0x05     // maximum number of endpoints (Ep0 + max of 4 data endpoints)
#define INT_CLEAR   0xff
//*****************************************************************************************
// Constant Defines
//*****************************************************************************************

#define TIMEOUT_RETRY	0x06	// Maximum no. of timeout retries during USB xfer
// USB device descriptors
typedef struct
{
    WORD  wVID, wPID;       // Vendor ID and Product ID
    BYTE  bClass;           // 
    BYTE  bNumOfEPs;        // actual number endpoint from slave
    BYTE  iMfg;				// Manufacturer ID
    BYTE  iPdt;				// Product ID
    BYTE  bId1;
    BYTE  bId2;
    BYTE  bEPAddr[MAX_EP];   // bit 7 = 1 = use PID_IN, 
    BYTE  bAttr[MAX_EP];     // ISO | Bulk | Interrupt | Control
    WORD  wPayLoad[MAX_EP];  // ISO range: 1-1023, Bulk: 1-64, etc
//    WORD  bInterval[MAX_EP]; // polling interval (for LS)
    BYTE  bData1[MAX_EP];    // DataToggle value
} USBDEV, *pUSBDEV;

// USB specific request
typedef struct
{
    BYTE bmRequest;
    BYTE bRequest;
    WORD wValue;
    WORD wIndex;
    WORD wLength;
} SetupPKG, *pSetupPKG;

typedef struct
{
    BYTE usbaddr;
    //BYTE endpoint;
    BYTE pid;
    BYTE wPayload;
    WORD  wLen;
    BYTE *buffer;	
    SetupPKG setup;
    BYTE epbulkin;
    BYTE epbulkout;
 
    BYTE bRdFlag;			//0: read to buffer, 1: read to tmp
    BYTE	bPhyBlkSizeExp;		
    WORD wPhyBlkSize; 	
    BYTE bOffset;	
    BYTE bMaxOffset;		
//    DWORD dwLba;	
 
} XXGPKG, *pXXGPKG;

// Standard Device Descriptor
typedef struct	           //14 fields and 18 bytes;
{   BYTE bLength;		   //Descriptor size in bytes  --descriptor
    BYTE bDescriptorType;  //The constant DEVICE(01h)  --descriptor
    WORD bcdUSB;		   //The USB specification number that the Device and the descriptor comply with;
    BYTE bDeviceClass;     //device class
    BYTE bDeviceSubClass;
    BYTE bDeviceProtocol;
    BYTE bMaxPacketSize0;  //maximum packet size for endpoint 0;
    WORD idVendor;		   
    WORD idProduct;
    WORD bcdDevice;		   //the device's release number;
    BYTE iManufacturer;	   //an index that points to a string describing the manufacture;
    BYTE iProduct;		   //an index that points to a string describing the product;
    BYTE iSerialNumber;	    
    BYTE bNumConfigurations;   //the number of configuration the device supports;
} sDevDesc, *pDevDesc;
// Standard Configuration Descriptor describes the device's feature and abilities;
typedef struct
{	
    BYTE bLength;                // Size of descriptor in Byte
	BYTE bType;					 // the constant Configuration(02h)
	WORD wLength;                // the number of data bytes that the device returns,
	BYTE bNumIntf;				 // Number of interfaces the configuration supports;
	BYTE bCV;             		 // bConfigurationValue,identifies the configuration for Get_Configuration and Set_Configuration;
	BYTE bIndex;          		 // iConfiguration,index to a string that describes the configuration;
	BYTE bAttr;                  // Self power/bus power and remote wakeup;
	BYTE bMaxPower;				 // Power config
} sCfgDesc, *pCfgDesc;

// Standard Interface Descriptor 9 bytes
typedef struct
{	BYTE bLength;	    
	BYTE bType;		     //the constant INTERFACE(04h);
	BYTE iNum;		     //Number identifying this interface;
	BYTE iAltString;	 //Value used to select an alternate setting;
	BYTE bEndPoints;	 //Number of endpoints supported in addition to Endpoint0;
	BYTE iClass;		 //class code
	BYTE iSub; 		     //subclass code
	BYTE iProto;		 //protocol code
	BYTE iIndex; 		 //index of string descriptor for interface;
} sIntfDesc, *pIntfDesc;

// Standard EndPoint Descriptor 7 bytes
typedef struct
{	BYTE bLength;
	BYTE bType;		     //the constant endpoint(05h);
	BYTE bEPAdd;		 //includes the endpoint number(bits 0 through 3) and direction(bit 7);
	BYTE bAttr;		     //bits 1 and 0 specify the type of transfer the endpoint supports.00=control,10=bulk...;
	WORD wPayLoad;       //maximum packet size supported; low-speed this must be 0x08
	BYTE bInterval;	     //for full-speed bulk and control transfers,the value is ignored.
} sEPDesc, *pEPDesc;

/*-------------------------------------------------------------------------
 * Standard Chapter 9 definition
 *-------------------------------------------------------------------------
 */
#define GET_STATUS      0x00																  
#define CLEAR_FEATURE   0x01
#define SET_FEATURE     0x03
#define SET_ADDRESS     0x05
#define GET_DESCRIPTOR  0x06
#define SET_DESCRIPTOR  0x07
#define GET_CONFIG      0x08
#define SET_CONFIG      0x09
#define GET_INTERFACE   0x0a
#define SET_INTERFACE   0x0b
#define SYNCH_FRAME     0x0c


#define DEVICE          0x01
#define CONFIGURATION   0x02
#define STRING          0x03
#define INTERFACE       0x04
#define ENDPOINT        0x05

#define STDCLASS        0x00
/*-------------------------------------------------------------------------
 * USB Host control command definitions
 *-------------------------------------------------------------------------
 */
 //cmd                       
#define WRITE0      0x42
#define WRITE1      0xc2   //// out + data + toggle 
#define READ        0x04	// in

#define SETUP       0x41	//setup + data0
#define SEND_ACK    0x20
//pid
#define PID_SETUP   0xD0 
#define PID_IN      0x90
#define PID_OUT     0x10
//flag
#define DEV_TGL     0x01
#define PKT_VLD     0x04
#define PKT_ERR		0x02
#define PKT_DATA    0x40
#define PKT_SENT    0x02
#define DEV_ACK     0x20
#define DEV_NAK     0x10
#define DEV_STALL   0x08
#define DEV_TO      0x80

BYTE epBulkSend(BYTE *pBuffer,WORD len);
BYTE epBulkRcv(BYTE *pBuffer,WORD len);

BYTE halUsbInit(void);
BYTE halUsbEnum(void);

///////////////////
BYTE _halInTrans(void);
BYTE _halOutTrans(void);
void _halSetupTrans(void);
BYTE _halHostEp0Xfer(void);
BYTE halUsbDevEnum(void);
BYTE _halStdDevReq(BYTE bmReq, BYTE bReq, WORD wVal, WORD wIdx, WORD wLen);

#define _halBufRst(rst) 	BufRst=rst
//void _halBufRst(BYTE rst);

void halUsbPhyBlksize(WORD size);

//BYTE halUsbCheck(void);
void _halUsbReset(void);


#endif


⌨️ 快捷键说明

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