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

📄 host2131.lst

📁 keyword:usb host sl8
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.10  HOST2131                                                               09/04/2002 22:22:07 PAGE 1   


C51 COMPILER V6.10, COMPILATION OF MODULE HOST2131
OBJECT MODULE PLACED IN .\host2131.OBJ
COMPILER INVOKED BY: f:\Keil\C51\BIN\C51.EXE .\host2131.c OPTIMIZE(6,SPEED) INCDIR(c:\cypress\usb\target\inc) DEBUG OBJE
                    -CTEXTEND

stmt level    source

   1          #pragma NOIV					            // Do not generate interrupt vectors
   2          ////////////////////////////////////////////////////////////////////////////////
   3          // File:		host2131.c
   4          // Purpose:	    8051 firmware to master SL811 Embedded Host.
   5          //              Derived from periph.c frameworks file.
   6          //              Contains USB peripheral-related firmware.
   7          //              Contains PC host command interface.
   8          //              Based on SL811HST code written by cxn.
   9          //
  10          // $Header: /USB/ez811/firmware/Emb_Host/host2131.c 8     5/17/02 6:09p Tpm $
  11          // Copyright (c) 2002 Cypress Semiconductor. May not be reproduced without permission.
  12          // See the license agreement for more details.
  13          ////////////////////////////////////////////////////////////////////////////////
  14          
  15          #include "ezusb.h"
*** ERROR 318 IN LINE 15 OF .\host2131.c: can't open file 'ezusb.h'
  16          #include "ezregs.h"
*** ERROR 318 IN LINE 16 OF .\host2131.c: can't open file 'ezregs.h'
  17          #include "host_811.h"
*** ERROR 318 IN LINE 9 OF host_811.h: can't open file 'ezusb.h'
*** ERROR 318 IN LINE 10 OF host_811.h: can't open file 'ezregs.h'
*** ERROR C141 IN LINE 55 OF HOST_811.H: syntax error near 'WORD'
*** ERROR C129 IN LINE 55 OF HOST_811.H: missing ';' before 'wVID'
  18          
  19          extern BOOL	GotSUD;			// Received setup data flag
  20          extern BOOL	Sleep;
  21          extern BOOL	Rwuen;
  22          extern BOOL	Selfpwr;
  23          
  24          extern BOOL SLAVE_ENUMERATED;
  25          extern BOOL	BULK_OUT_DONE;
  26          extern BOOL DESC_XFER;
  27          extern BOOL DATA_XFER;
  28          extern xdata BYTE DataBufLen;
  29          extern xdata BYTE DBUF[];
  30          extern xdata BYTE HOSTCMD[];
  31          extern xdata BYTE REGBUFF[];
  32          extern xdata BYTE remainder;
  33          extern void sl811h_init(void);
  34          extern int slave_detect(void);
  35          extern BOOL	CONFIG_DONE;
  36          
  37          extern BOOL DATA_XFER_OUT;
  38          extern xdata BYTE DBUFOut[];
  39          extern BOOL dsPoll;
  40          extern BOOL bDataToggle;
  41          
  42          extern xdata pDevDesc  	pDev;			// Device descriptor struct
  43          extern xdata pCfgDesc  	pCfg;			// Config descriptor struct
  44          extern xdata pStrDesc 	pStr;			// String descriptor struct
  45          extern xdata pHidDesc 	pHid;			// HID class descriptor struct
  46          extern xdata pHubDesc 	pHub;			// HUD class descriptor struct
  47          extern xdata pIntfDesc 	pIfc;			// Interface descriptor struct
  48          extern xdata pHUBDEV    uHub;			// Struct for downstream device on HUB
C51 COMPILER V6.10  HOST2131                                                               09/04/2002 22:22:07 PAGE 2   

  49          extern xdata pUSBDEV    uDev[];	// Multiple USB devices attributes, Max 5 devices
  50          
  51          void dsOut(void);
  52          int DataRW(BYTE usbaddr, BYTE epaddr, WORD wPayload, WORD wLen, BYTE *pData);
  53          WORD GetDevInfo(BYTE *DevInfo);
  54          
  55          int	desc_next;
  56          int	data_next;
  57          void TD_Poll(void);
  58          
  59          BYTE	Configuration;		// Current configuration
  60          BYTE	AlternateSetting;	// Alternate settings
  61          
  62          //-----------------------------------------------------------------------------
  63          // Task Dispatcher hooks
  64          //	The following hooks are called by the task dispatcher.
  65          //-----------------------------------------------------------------------------
  66          // IN2 	=>  1 bytes max, Refresh data update from ezusb to host
  67          //-----------------------------------------------------------------------------
  68          void TD_Init(void) 				// Called once at startup
  69          {
  70          	Rwuen = TRUE;				// Enable remote-wakeup
  71          	ISOCTL |= 0x01;				// free up iso endpoints for external data space (1024)
  72          
  73          	IN07VAL |= bmEP1;			// Enable endpoint 1 IN
  74          	IN07VAL |= bmEP2;			// Enable endpoint 2 IN
  75          	IN07VAL |= bmEP3;			// Enable endpoint 3 IN
  76          	OUT07VAL |= bmEP1;			// Enable endpoint 1 OUT 
  77             	OUT07IEN |= bmEP1;			// Enable endpoint 1 OUT interrupt
  78          	OUT1BC = 0;					// Arm Endpoint 1 OUT to recieve data
  79          	OUT07VAL |= bmEP3;			// Enable endpoint 3 OUT 
  80             	OUT07IEN |= bmEP3;			// Enable endpoint 3 OUT interrupt
  81          	OUT3BC = 0;					// Arm Endpoint 3 OUT to recieve data
  82          	
  83          	BPADDR = (WORD)TD_Poll;     // Setup breakpoint to trigger on TD_Poll()
  84          	USBBAV |= bmBPEN;			// Enable the breakpoint
  85          	USBBAV &= ~bmBPPULSE;
  86          
  87          	sl811h_init();				// setup SL811H chip variables
  88          	desc_next = 0;
  89          	data_next = 0;
  90          
  91          }
  92          
  93          //*****************************************************************************************
  94          // ENDPOINT FUNCTION :
  95          // EP2-IN  -> Return a byte of 0x01 to ezusb host to indicate a attach/detach for refresh
  96          //*****************************************************************************************
  97          void TD_Poll(void) 
  98          {
  99          	int	i,count;
 100              BYTE DescBufLen;		    // EZUSB's IN #1 descriptor buffer length
 101          
 102          	slave_detect();				// Poll for any slave USB device attached to "SL811HS" Embedded Host
 103          
 104              if(BULK_OUT_DONE && !DESC_XFER)
 105              {
 106          			BULK_OUT_DONE = FALSE;
 107          				switch(HOSTCMD[0])							// type of commands from EZUSB host
 108          				{
 109          					case SL_REFRESH:
 110          	                    DescBufLen = GetDevInfo(DBUF);
C51 COMPILER V6.10  HOST2131                                                               09/04/2002 22:22:07 PAGE 3   

 111                                  if(!DescBufLen)				
 112                                  { // there is nothing to transfer - keep the host app from pending
 113          	                      DBUF[0] = 0;		
 114          	                      DescBufLen = 1;			// arming the IN1 is done in the slave_detect loop               
             -         
 115                                  }
 116          						DESC_XFER = TRUE;					// set DESC_XFER to start transfer
 117          						break;
 118          
 119          					default: break;							// default break;
 120                          }
 121              }
 122          
 123          	if(DESC_XFER && !(IN1CS & bmEPBUSY))
 124          	{													// ensure DESC_XFER & IN1 not busy
 125          		if(DescBufLen)									// check for any data length
 126          		{												//
 127          			count = (int)((DescBufLen>=64) ? 64:DescBufLen);	// select data length, max allowed is 64 bytes
 128          			for(i=0; i<count; i++)						// copy data into IN buffer
 129          				IN1BUF[i] = DBUF[i+desc_next];			// 
 130          			IN1BC = count;								// arm IN data transfer
 131          			DescBufLen -= count;						// update remaining data len
 132          			desc_next += count;
 133                      if(!DescBufLen)
 134                      {
 135          			  desc_next = 0;
 136          			  DESC_XFER = FALSE;					    // reset DESC_XFER to stop transfer
 137                      }
 138          		}
 139          	}
 140          }
 141          
 142          //---------------------------------------
 143          BOOL TD_Suspend(void) 			// Called before the device goes into suspend mode
 144          {
 145          	return(TRUE);
 146          }
 147          
 148          BOOL TD_Resume(void) 			// Called after the device resumes
 149          {
 150          	return(TRUE);
 151          }
 152          
 153          //-----------------------------------------------------------------------------
 154          // Device Request hooks
 155          //	The following hooks are called by the end point 0 device request parser.
 156          //-----------------------------------------------------------------------------
 157          
 158          BOOL DR_GetDescriptor(void)
 159          {
 160          	return(TRUE);
 161          }
 162          
 163          BOOL DR_SetConfiguration(void)	// Called when a Set Configuration command is received
 164          {
 165          	Configuration = SETUPDAT[2];
 166             CONFIG_DONE = TRUE;
 167          	return(TRUE);				// Handled by user code
 168          }
 169          
 170          BOOL DR_GetConfiguration(void)	// Called when a Get Configuration command is received
 171          {
C51 COMPILER V6.10  HOST2131                                                               09/04/2002 22:22:07 PAGE 4   

 172          	IN0BUF[0] = Configuration;
 173          	EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
 174          	return(TRUE);				// Handled by user code
 175          }
 176          
 177          BOOL DR_SetInterface(void) 		// Called when a Set Interface command is received
 178          {
 179          	AlternateSetting = SETUPDAT[2];
 180          	return(TRUE);				// Handled by user code
 181          }
 182          
 183          BOOL DR_GetInterface(void) 		// Called when a Set Interface command is received
 184          {
 185          	IN0BUF[0] = AlternateSetting;
 186          	EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
 187          	return(TRUE);				// Handled by user code
 188          }
 189          
 190          BOOL DR_GetStatus(void)
 191          {
 192          	return(TRUE);
 193          }
 194          
 195          BOOL DR_ClearFeature(void)
 196          {
 197          	return(TRUE);
 198          }
 199          
 200          BOOL DR_SetFeature(void)
 201          {
 202          	return(TRUE);
 203          }
 204          
 205          #define EP0BUFF_SIZE	0x40
 206          
 207          BOOL DR_VendorCmnd(void)
 208          {
 209            WORD addr, len, bc;
 210            BYTE EpAddr, EpIdx;
 211            WORD i;
 212            BYTE RegAddr;
 213            xdata BYTE OUT_DATA[EP0BUFF_SIZE];	// OUT data buffer
 214            int retDataRW = FALSE;
 215            BYTE DescBufLen = 0;
 216            WORD ReqLen = 0;
 217          
 218            switch(SETUPDAT[1])
 219            { // NOTE" 0xA0 is reserved: 0xA0 = Anchor Download (handled by core)
 220              case SL_RESET:
 221          	{
 222                sl811h_init();            // initialize SL811HST
 223                *IN0BUF = SETUPDAT[1];    // return command type
 224                IN0BC = 0x01;             // arm endp, # bytes to xfr
 225                EP0CS |= bmBIT1;          // ack handshake phase of device request
 226                break;
 227              }
 228              case SL_DEVICE_DESCP:                                      // GetDevDesc
 229              case SL_CONFIG_DESCP:                                      // GetConfDesc
 230              case SL_CLASS_DESCP:                                      // GetClassDesc
 231              case SL_STRING_DESCP:                                      // GetStringDesc
 232          	{
 233          		EpAddr = SETUPDAT[2];		                // Get address
C51 COMPILER V6.10  HOST2131                                                               09/04/2002 22:22:07 PAGE 5   

 234          		ReqLen = SETUPDAT[6];
 235          		ReqLen |= SETUPDAT[7] << 8;                    // Get requested length
 236          
 237          		if(SETUPDAT[1] == SL_DEVICE_DESCP)
 238          		{
 239          		  pDev =(pDevDesc)DBUF;
 240          		  if(GetDesc(EpAddr,DEVICE,0,18,DBUF))	    // Device Descp - 18 bytes 
 241          		    DescBufLen = (WORD)pDev->bLength;		// update buffer length 
 242          		}
 243          		if(SETUPDAT[1] == SL_CONFIG_DESCP)
 244          		{
 245          		  pCfg =(pCfgDesc)DBUF;				
 246          		  if (GetDesc(EpAddr,CONFIGURATION,0,255,DBUF))
 247          		    DescBufLen = WordSwap(pCfg->wLength); 				
 248          		}
 249          		if(SETUPDAT[1] == SL_CLASS_DESCP)
 250          		{
 251                    if (GetDesc(EpAddr,CONFIGURATION,0,255,DBUF))	// Configuration Descp
 252                    {
 253          	        pIfc = (pIntfDesc)(DBUF + 9);				// point to Interface Descp
 254                      if(pIfc->iClass==HIDCLASS)			// HID_CLASS
 255                      {
 256                        pHid = (pHidDesc)(DBUF + 9 + 9);		// get HID's report descriptor
 257                        DescBufLen = (pHid->wItemLength <= 255) ? pHid->wItemLength : 255; 
 258                        if(!GetHid_Desc(EpAddr,HID_REPORT,DescBufLen,DBUF))
 259                          DescBufLen = 0;
 260                      }
 261                      else if(pIfc->iClass==HUBCLASS)		// HUB_CLASS
 262                      {
 263                        pHub =(pHubDesc)DBUF;					// get HUB class descriptor
 264                        DescBufLen = (pHub->bLength <= 255) ? pHub->bLength : 255; 
 265                        if(!GetHubDesc(EpAddr,0,9,DBUF)) 
 266                          DescBufLen = 0;
 267                      }
 268          			else
 269                          DescBufLen = 0;                 // Undefined Class
 270                    }
 271          		}

⌨️ 快捷键说明

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