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

📄 host_811.h

📁 ARM44B0+sl811(包含所有固件程序和源码)调试通过
💻 H
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////////////////////////
//	File:		host_811.h
//
// $Header: /USB/ez811/firmware/Emb_Host/host_811.h 6     5/14/02 8:37p Tpm $
// Copyright (c) 2002 Cypress Semiconductor. May not be reproduced without permission.
// See the license agreement for more details.
////////////////////////////////////////////////////////////////////////////////

#include "ezusb.h"
#include "ezregs.h"
//#include "ezusb.h"
//#include "..\sl811\ezregs.h"
#define NULL		0
#define TRUE   		1
#define FALSE  		0
#define ISO_BIT     0x10
#define MAX_DEV    	0x06     // maximum number of devices (Address #0 + Slave + 4 Hub's device)
#define MAX_EP    	0x05     // maximum number of endpoints (Ep0 + max of 4 data endpoints)

//*****************************************************************************************
// Constant Defines
//*****************************************************************************************
#define	ACTIVE_BLINK		0x40	// Port B bit 6 - Active LED, blink when no device attach
#define	IRQ_INPUT			0x10	// Port B bit 4 - Active high interrupt input from SL811HST
#define	nHOST_SLAVE_MODE	0x02	// Port B bit 1 - f/w control of nHost/Slave pin
#define	nRESET				0x01	// Port B bit 0 - f/w control of nReset pin

#define HUB_ADDR			0x01	// fix hub address
#define TIMEOUT_RETRY		0x06	// Maximum no. of timeout retry during USB xfer
#define XFERSTOP0			0xDE	// code to indicate stop button pressed
#define XFERSTOP1			0xAF	// "OxDEAF"
#define NONEXIST0			0xDE	// code to indicate device does not exist for data start/stop
#define NONEXIST1			0xAD	// "OxDEAD"
#define NOT_APPL			0xFF	// indicate not applicable, in string & class descp

#define	PORTX_LED			0xF0	// Turn off all Port A LEDs
#define	PORT1_LED			0x80	// Port A bit 7 - Port #1
#define	PORT2_LED			0x40	// Port A bit 6 - Port #2
#define	PORT3_LED			0x20	// Port A bit 5 - Port #3
#define	PORT4_LED			0x10	// Port A bit 4 - Port #4

#define SL_RESET			0xD0	// EZUSB's host command for reset
#define SL_DEVICE_DESCP		0xD1	// EZUSB's host command for get device descriptor
#define SL_CONFIG_DESCP		0xD2	// EZUSB's host command for get config descriptor
#define SL_CLASS_DESCP		0xD3	// EZUSB's host command for get class descriptor
#define SL_STRING_DESCP		0xD4	// EZUSB's host command for get string descriptor
#define SL_REFRESH			0xD5	// EZUSB's host command for auto device attach/detach refresh
#define SL_DATA_XFER_START	0xD6	// EZUSB's host command for data transfer begin
#define SL_DATA_XFER_STOP	0xD7	// EZUSB's host command for data transfer end
#define SL_TOGGLE_DS_REFRESH 0xD8
#define SL_SHOW_REGS        0xD
BYTE epbulkout;
BYTE epbulkin;
typedef __packed 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
} pUSBDEV, *PUSBDEV;

typedef __packed struct					// USB Address #0(enum), #1(Hub), #2..#5(device behind hub)
{								// [X] = device address, valid #2..#5 only, #0 is used during enum
	BYTE  bPortPresent[MAX_DEV];	// '1' present, '0' absent
	BYTE  bPortNumber[MAX_DEV];	// contain port number at which device is attached 
	BYTE  bPortSpeed[MAX_DEV]; 	// '1' LowSpeed, '0' FullSpeed
} pHUBDEV, *PHUBDEV;

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

// Standard Device Descriptor
typedef __packed struct
{   BYTE bLength;
    BYTE bDescriptorType;
    WORD bcdUSB;
    BYTE bDeviceClass;
    BYTE bDeviceSubClass;
    BYTE bDeviceProtocol;
    BYTE bMaxPacketSize0;
    WORD idVendor;
    WORD idProduct;
    WORD bcdDevice;
    BYTE iManufacturer;
    BYTE iProduct;
    BYTE iSerialNumber;
    BYTE bNumConfigurations;
} sDevDesc, *pDevDesc;

// Standard Configuration Descriptor
typedef __packed struct
{	
    BYTE bLength;                 // Size of descriptor in Byte
	BYTE bType;					 // Configuration
	WORD wLength;                // Total length
	BYTE bNumIntf;				 // Number of interface
	BYTE bCV;             		 // bConfigurationValue
	BYTE bIndex;          		 // iConfiguration
	BYTE bAttr;                  // Configuration Characteristic
	BYTE bMaxPower;				 // Power config
} sCfgDesc, *pCfgDesc;

// Standard Interface Descriptor
typedef __packed struct
{	BYTE bLength;
	BYTE bType;
	BYTE iNum;
	BYTE iAltString;
	BYTE bEndPoints;
	BYTE iClass;
	BYTE iSub; 
	BYTE iProto;
	BYTE iIndex; 
} sIntfDesc, *pIntfDesc;

// Standard EndPoint Descriptor
typedef __packed struct
{	BYTE bLength;
	BYTE bType;
	BYTE bEPAdd;
	BYTE bAttr;
	WORD wPayLoad;               // low-speed this must be 0x08
	BYTE bInterval;
} sEPDesc, *pEPDesc;

// Standard String Descriptor
typedef __packed struct
{	BYTE bLength;
	BYTE bType;
	WORD wLang;
} sStrDesc, *pStrDesc;


/*-------------------------------------------------------------------------
 * Structure for USB HUB
 *------------------------------------------------------------------------*/
// Hub Standard Descriptor
typedef __packed struct
{
    BYTE bLength;
    BYTE DType;
    BYTE bNbrPort;               // Number of Downstream ports
    WORD wHubCharacteristic;     // See chapter 11
    BYTE bbPwrOn2PwrGood;        // Time in 2ms interval
    BYTE bHubContrCurrent;       // Max current in mA
    BYTE bDeviceRemovable;       // Idicate if a port has a removable
    BYTE bPortPwrCtlMask;        
} sHubDesc, *pHubDesc;

typedef __packed struct 
{
    WORD wHubStatus;
    WORD wHubChange;
} sHubStatus, *pHubStatus;

typedef __packed struct 
{
    BYTE wPortStatus_Lo;
    BYTE wPortStatus_Hi;
    BYTE wPortChange_Lo;	
    BYTE wPortChange_Hi;	
} sPortStatus, *pPortStatus;

/*-------------------------------------------------------------------------
 * Structure for USB HID
 *------------------------------------------------------------------------*/
// HID Standard Descriptor
typedef __packed struct
{
    BYTE bLength;
    BYTE bDescriptorType;
    WORD bcdHID;
    BYTE bCountryCode;
    BYTE bNumDescriptors;
    BYTE bDescriptorType2;
    BYTE wItemLength;
} sHidDesc, *pHidDesc;





//------------------------------------------------------------------------
// EP0 use for configuration and Vendor Specific command interface
//------------------------------------------------------------------------
#define EP0_Buf		    0x10	// define start of EP0 64-byte buffer
#define EP1_Buf		    0x40	// define start of EP1 64-byte buffer

/*-------------------------------------------------------------------------
 * SL811H Register Control memory map
 * --Note: 
 *      --SL11H only has one control register set from 0x00-0x04
 *      --SL811H has two control register set from 0x00-0x04 and 0x08-0x0c
 *------------------------------------------------------------------------*/

#define EP0Control      0x00
#define EP0Address      0x01
#define EP0XferLen      0x02
#define EP0Status       0x03
#define EP0Counter      0x04

#define EP1Control      0x08
#define EP1Address      0x09
#define EP1XferLen      0x0a
#define EP1Status       0x0b
#define EP1Counter      0x0c

#define CtrlReg         0x05
#define IntEna          0x06
                               // 0x07 is reserved
#define IntStatus       0x0d
#define cDATASet        0x0e
#define cSOFcnt         0x0f   // Master=1 Slave=0, D+/D-Pol Swap=1 0=not [0-5] SOF Count 
                               // 0xAE = 1100 1110
                               // 0xEE = 1110 1110

#define IntMask         0x57   /* Reset|DMA|EP0|EP2|EP1 for IntEna */
#define HostMask        0x47   /* Host request command  for IntStatus */

⌨️ 快捷键说明

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