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

📄 host_811.lst

📁 完整的usb_host_device源代码直接在keil下编译
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.50   HOST_811                                                              10/27/2005 20:00:37 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE HOST_811
OBJECT MODULE PLACED IN host_811.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE host_811.c OPTIMIZE(6,SPEED) INCDIR(c:\cypress\usb\target\inc) DEBUG OBJECT
                    -EXTEND

line level    source

   1          ////////////////////////////////////////////////////////////////////////////////
   2          // Cypress Semiconductor - Customer Design Center 
   3          ////////////////////////////////////////////////////////////////////////////////
   4          // File:                host_811.c
   5          // Purpose:         8051 firmware to master SL811 Embedded Host. 
   6          //              Contains SL811-related control firmware. 
   7          //              Based on SL811HST code written by cxn.
   8          // H/W Target:  SL811HST(Rev 1.5) + EZUSB DEV KIT
   9          // IMPORTANT :  Turn ON SW4 of S6-DIP-SWITCH 
  10          //              to enable upper 32K memory on EZUSB Dev Kit
  11          //
  12          // $Header: /USB/ez811/firmware/Emb_Host/host_811.c 8     5/14/02 8:30p Tpm $
  13          // Copyright (c) 2002 Cypress Semiconductor. May not be reproduced without permission.
  14          // See the license agreement for more details.
  15          ////////////////////////////////////////////////////////////////////////////////
  16          
  17          #include "ezusb.h"
  18          #include "ezregs.h"
  19          #include "host_811.h"
  20          
  21          ////////////////////////////////////////////////////////////////////////////////
  22          // Code and Xdata Memory Space
  23          ////////////////////////////////////////////////////////////////////////////////
  24          //
  25          // ** Upper 32K external memory **
  26          // (PROGRAM'S CODE/XDATA MEMORY ALLOCATION)
  27          // Program xdata Space  : 0x2000 ~ 0x23FF -> ALL XDATA (size:0x0400,1K)(ISO unused data mem)
  28          // Program Code Space1  : 0x8000 ~ 0x9EFF -> ?FW, ?EZ811 (size:0x1F00,7K) (ext. code memory) 
  29          // Program Code Space2  : 0xA000 ~ 0xDFFF -> ?SL811H (size:0x4000,16K)(ext. code memory) 
  30          // (MONITOR'S CODE/XDATA MEMORY ALLOCATION) (SHOULD NEVER BE USED)
  31          // Monitor xdata Space  : 0x9F00 ~ 0x9FFF (size:0x0100,256)(ext. code memory) 
  32          // Monitor Code Space   : 0xE000 ~ 0xFFFF (size:0x2000,8K) (ext. code memory) 
  33          //
  34          // ** Lower 32K external memory **
  35          // SL811H_ADDR address  : 0x4000
  36          // SL811H_DATA address  : 0x4001
  37          //
  38          // ** Internal 8K EZUSB code/xdata memory **
  39          // Both USBJmpTb.a51 and Dscr.a51 code are located to EZUSB internal 8K memory
  40          //
  41          // (See Project -> Options for Target 'Target 1' for detail settings)
  42          //
  43          //*****************************************************************************************
  44          // SL811H Modules (major routines only): 
  45          //*****************************************************************************************
  46          // 1) usbXfer()         : handles usd data transfer, SETUP,IN, OUT
  47          // 2) ep0Xfer()         : handles endpoint zero control pipe
  48          // 3) DataRW()          : handles data endpoint transfer pipe
  49          // 4) EnumUsbDev()      : device enum(HID/HUB), excl. multi-interface
  50          // 5) HubPortEnum()     : hub port device enum, incl. dynamic USB address
  51          // 6) speed_detect(): SL811H slave device attach/speed detect
  52          // 7) slave_detect(): Main loop control between SL811H & EZUSB & GUI
  53          // 8) host_811.c        : Entire code size
  54          
C51 COMPILER V7.50   HOST_811                                                              10/27/2005 20:00:37 PAGE 2   

  55          //*****************************************************************************************
  56          // SL811HST+EZUSB Hardware Resources :
  57          //*****************************************************************************************
  58          // SL811HST             <-->    AN2131QC        <-->    FUNCTIONS (looking from SL811H side)
  59          // A0                   <-->    A0                      <-->    (I) Address entry for SL811H, '0'-addr, '1'-data
  60          // D0 ~ D7              <-->    D0 ~ D7         <-->    (B) 8-bit Data Bus
  61          // nCS                  <-->    A15                     <-->    (I) Enable lower 32K memory(where SL811H is mapped)
  62          // nRD                  <-->    nRD (PC7)       <-->    (I) Read (active low)
  63          // nWR                  <-->    nWR (PC6)       <-->    (I) Write (active low)
  64          // nRST                 <-->    PB0                     <-->    (I) SL811HST's reset (active low)
  65          // MS_SEL               <-->    PB1                     <-->    (I) SL811HST's master/slave select, '0'-host
  66          // INTR                 <-->    INT4 (PB4)      <-->    (O) SL811HST's interrupt (active high) not used
  67          // ACTIVE_LED   <-->    PB6                     <-->    Blink - waiting for enum, On - enumerated
  68          //
  69          // For Downstream Port LEDs on Hub (not present on Demo Board):
  70          // DOWNSTREAM PORT1 LED                 0x80    // PA bit 7
  71          // DOWNSTREAM PORT2 LED                 0x40    // PA bit 6
  72          // DOWNSTREAM PORT3 LED                 0x20    // PA bit 5
  73          // DOWNSTREAM PORT4 LED                 0x10    // PA bit 4
  74          //
  75          //*****************************************************************************************
  76          // Monitor (Serial Port 1) Hardware Resources :
  77          //*****************************************************************************************
  78          // PB2 - (I) RxD1 (looking from EZUSB side)
  79          // PB2 - (0) TxD1
  80          // PC6 - (O) nWR
  81          // PC7 - (O) nRD
  82          
  83          //*****************************************************************************************
  84          // xdata variables
  85          //*****************************************************************************************
  86          xdata BYTE SL811H_ADDR          _at_    0x4000;         // A0 = '0' to external memory
  87          xdata BYTE SL811H_DATA          _at_    0x4001;     // A0 = '1' (EZ-USB Dev Kit - SW4 ON)
  88          
  89          xdata BYTE                      DBUF[256];              // at 0x2000 for general descriptors data
  90          xdata BYTE                      STATUS[8];              // for status data buffer
  91          xdata BYTE          REGBUFF[16];    // Buffer for Register Data
  92          xdata BYTE                      HOSTCMD[8];             // EZUSB's OUT1 host command data
  93          xdata BYTE                      pHOSTCMD[8];    // previous data transfer info, during data transfer
  94          xdata BYTE                      HubChange[1];   // Hub port endpoint 1 data status
  95          xdata BYTE                      DataBufLen;             // EZUSB's IN #3 data transfer buffer length
  96          xdata BYTE                      pNumPort;               // Number of downstream ports on hub
  97          xdata BYTE                      remainder;              // Remaining byte in a USB transfer
  98          xdata pUSBDEV           uDev[MAX_DEV];  // Multiple USB devices attributes, Max 5 devices
  99          xdata pHUBDEV           uHub;                   // Struct for downstream device on HUB
 100          xdata pDevDesc          pDev;                   // Device descriptor struct
 101          xdata pCfgDesc          pCfg;                   // Configuration descriptor struct
 102          xdata pIntfDesc         pIfc;                   // Interface descriptor struct
 103          xdata pEPDesc           pEnp;                   // Endpoint descriptor struct
 104          xdata pStrDesc          pStr;                   // String descriptor struct
 105          xdata pHidDesc          pHid;                   // HID class descriptor struct
 106          xdata pHubDesc          pHub;                   // HUD class descriptor struct
 107          xdata pPortStatus       pStat;                  // HID ports status
 108          
 109          //*****************************************************************************************
 110          // Boolean Logic Defines
 111          //*****************************************************************************************
 112          BOOL    SLAVE_FOUND;                            // Slave USB device found
 113          BOOL    SLAVE_ENUMERATED;                       // slave USB device enumeration done
 114          BOOL    FULL_SPEED;                                     // Full-Speed = TRUE, Low-Speed = FALSE
 115          BOOL    HUB_DEVICE;                                     // HUB device = TRUE
 116          BOOL    BULK_OUT_DONE;                          // Set when EZUSB's OUT1 hostcmd xfer is done
C51 COMPILER V7.50   HOST_811                                                              10/27/2005 20:00:37 PAGE 3   

 117          BOOL    DESC_XFER;                                      // Set when there is data for EZUSB's IN1 desc xfer
 118          BOOL    DATA_XFER;                                      // Set when there is data for EZUSB's IN3 data xfer
 119          BOOL    DATA_XFER_OUT;                          // Set when there is data for EZUSB's OUT3 data xfer
 120          BOOL    CONFIG_DONE;                            // Set when EZUSB completes its enumeration process.
 121          BOOL    TIMEOUT_ERR;                            // timeout error during data endpoint transfer
 122          BOOL    DATA_STOP;                                      // device unplugged during data transfer
 123          BOOL    DATA_INPROCESS;                         // set when we are in a data pipe transfer
 124          BOOL    pLS_HUB;                                        // indicate previous command is a LS device on hub
 125          
 126          BOOL    dsPoll;                                 // poll downstream port conections
 127          
 128          BOOL bData1;
 129          
 130          //*****************************************************************************************
 131          // Byte Read from SL811H
 132          // a = register address
 133          // return = data in register
 134          //*****************************************************************************************
 135          BYTE SL811Read(BYTE a)
 136          {  
 137   1              SL811H_ADDR = a;                        
 138   1              return (SL811H_DATA);
 139   1      }
 140          
 141          //*****************************************************************************************
 142          // Byte Write to SL811H
 143          // a = register address
 144          // d = data to be written to this register address
 145          //*****************************************************************************************
 146          void SL811Write(BYTE a, BYTE d)
 147          {  
 148   1              SL811H_ADDR = a;        
 149   1              SL811H_DATA = d;
 150   1      }
 151          
 152          //*****************************************************************************************
 153          // Buffer Read from SL811H
 154          // addr = buffer start address

⌨️ 快捷键说明

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