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

📄 main.lst

📁 DK3200 USB DEMO for KEIL C
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V7.10   MAIN                                                                  04/30/2004 12:57:59 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE BROWSE DEBUG OBJECTEXTEND SRC(.\main.SRC)

line level    source

   1          /* `=========================================================================`
   2          main.c
   3          
   4          USB IAP (In Application Programming) Demo for uPSD32xx
   5          
   6          Version:
   7          April 30, 2004 - Beta Version 1.0 
   8          
   9          Description:
  10          The demo code provided is considered beta.  It provides a good example of the
  11          uPSD32xx operating as a low speed, HID class device performing IAP features.
  12          The firmware is for the uPSD32xx device on a DK3200 for IAP communicating 
  13          over USB to a Windows application.
  14          
  15          USB Compliance:
  16          This beta code passes the Chapter 9 and HID tests provided by the USB Command
  17          Verifier program (USBCV R1.2.1).  USBCV is available from the USB IF website at:
  18          http://www.usb.org/developers/developers/tools/
  19          
  20          The Passing test result reports for the Chapter 9 and HID tests run on this
  21          firmware in the DK3200 are included in the "..\USBCV Test Reports" subdirectory.
  22          Regarding the warnings in the test reports, see the known limitations listed
  23          below.
  24          
  25          Known Limitations:
  26          1. The uPSD32xx hardware does not support remote wakeup but does support host
  27             resume.
  28          
  29          2. This version of the demo code doesn't support the GetIdle and SetIdle
  30             commands.
  31          
  32          3. This version of the demo code passes the Chapter 9 EnumerateTest the majority 
  33             of the time but on occasion fails.
  34          
  35          
  36          
  37          
  38                                           Important !!!
  39                                           =============
  40                     If you have a previous beta version, please replace all parts
  41                             of your SW with this new version, there are many small but 
  42                                          important changes that are not
  43                                    obvious for the first look.
  44          
  45          
  46          
  47                                               Notes:
  48                                               ======
  49                              supports USB SUSPEND and RESUME features
  50                              supports USB DisconnectOndemand feature
  51          
  52                                                           
  53                                                  -  Version >= Beta 1.0 - DDC int only
  54          
  55          - this version of USB demo was designed for uPSD3234A. Check your type of uPSD.
C51 COMPILER V7.10   MAIN                                                                  04/30/2004 12:57:59 PAGE 2   

  56          
  57                   - be sure you have jumpers PB0-PB3 present on your DK3200 kit
  58                             to avoid some false detect of button press.
  59                This version supports DisconnectOnDemand feature and tests PB port.
  60          
  61                - We recommend to design your USB-isr to be as shortest as possible,
  62                  make your USB ISR part as short as possible if you add something
  63          
  64          - set the USB priority to the max.level (bit 0 of IPA, see uPSD323X datasheet).
  65          
  66                         - This version uses relative register addressing,
  67                       use #pragma NOAREGS directive in your applications ...
  68          
  69                 - Use data directive or place your variables to data area directly
  70          (data variables are executed faster than xdata, but their amount is more limited.)
  71          
  72                 - use 36MHz xtal (or 24MHz if not posssible) oscillator freq.only
  73          
  74                  - be careful of using <string.h> and other routines in USB ISRs
  75          
  76                                  Tested on DK3200 board. Rev.0.1.
  77          
  78          
  79          
  80          
  81          
  82          
  83                                     ..........................
  84                                    .                          .
  85                                    .      ******************  .
  86                                    .     **PPPPPPPPPPPPPPPP   .
  87                                    .     *PPPP*******PP****   .
  88                                    .    **PPP********PP***    .
  89                                    .    ***PPP******PP****    .
  90                                    .   *****PPP****PP****     .
  91                                    .   *****PPP****PP****     .
  92                                    .  PPPPPPPP****PP****  (R) .
  93                                    .                          .
  94                                     ..........................
  95          
  96          
  97                                            =-=-=-=-=-=
  98                                     =-=-=-=-=-=-=-=-=-=-=-=-=
  99                          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 100          
 101                                 Copyright 2004 ST Microelectronics
 102          
 103                       This code/file is provided as is and has no warranty,
 104               implied or otherwise.  You are free to use/modify any of the provided
 105              code at your own risk in your applications with the expressed limitation
 106                  of liability (see below) so long as your product using the code
 107                           contains at least one uPSD products (device).
 108          
 109                                      LIMITATION OF LIABILITY:
 110                                      ========================
 111                        NEITHER STMicroelectronics NOR ITS VENDORS OR AGENTS
 112                SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
 113                 INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
 114                 CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
 115                   OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 116          
 117                          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
C51 COMPILER V7.10   MAIN                                                                  04/30/2004 12:57:59 PAGE 3   

 118                                     =-=-=-=-=-=-=-=-=-=-=-=-=
 119                                            =-=-=-=-=-=
 120          
 121                             For current information on uPSD products,
 122                          please consult our pages on the World Wide Web:
 123          
 124                                           www.st.com/psm
 125          
 126                                      - - - - - - - - - - - -
 127          
 128                               STMicroelectronics GROUP OF COMPANIES
 129              Australia - Brazil - China - Czech Republic - Finland - France - Germany
 130             Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco - Singapore
 131                       Spain - Sweden - Switzerland - United Kingdom - U.S.A.
 132          
 133                                         http://www.st.com
 134          
 135          
 136           `========================================================================` */
 137          
 138          
 139          #pragma NOAREGS                      //this source must use relative registers !!!
 140          
 141          #include <string.h>
 142          #include "upsd3200.h"
 143          #include "upsd_usb.h"
 144          #include "lcd_3200.h"
 145          #include "app_intr.h"
 146          
 147          
 148                                 /*========= Prototypes =========*/
 149          
 150          extern uchar flash_write_with_poll(volatile uchar xdata *addr, uchar dat);
 151          extern uchar flash_boot_write_with_poll(volatile uchar xdata *addr, uchar dat);
 152          extern uchar flash_erase_sector(volatile uchar xdata* addr);
 153          extern uchar flash_boot_erase_sector(volatile uchar xdata* addr);
 154          extern void flash_reset();
 155          extern void flash_boot_reset();
 156          
 157          extern void initXREG();
 158          
 159          
 160          //extern
 161          extern PSD_REGS UPSD_xreg;                   // UPSD registers (upsd_cfg.c)
 162          extern data uchar LCD_buffer[];              // LCD mirror buffer (lcd_32xx.c)
 163          
 164          
 165          
 166          
 167          
 168          
 169                                /*=========== Globals ===========*/
 170          
 171          // uncomment the following line to enable DisconnectOndemand feature
 172          //#define DisconnectOnDemand
 173          
 174          /*
 175            Enable this DisconnectOnDemand define in case of usage of Disconnect-on-demand
 176            feature ONLY. Be sure that all hardware modifications are present !!!
 177          */
 178          
 179          unsigned char DDCCONintc = 0;
C51 COMPILER V7.10   MAIN                                                                  04/30/2004 12:57:59 PAGE 4   

 180          
 181          
 182          
 183          data int counter;                       // Incremented in do_timer0 (timer_func.c)
 184          
 185          MCU_CMD status;                              // Status from last command executed
 186          data uchar   returnStatus;   // Set TRUE if we should return status record to host
 187          MCU_CMD currentCmd;                          // Current command we're working on
 188          MCU_CMD rcvReport;                           // Incoming report
 189          data uchar   rcvIndex;                 // Current byte position in incoming report
 190          MCU_CMD txReport;                            // Outgoing report
 191          data uchar   txIndex;
 192                         // Current byte position in outgoing report, but be a byte only !!!
 193          
 194          
 195          xdata char AuxTXBuf[8];                     //Aux. buffer for TXing of LCD content
 196          data uchar LCDBufTXIndex;              //current position of LCD buffer for USB TX
 197          
 198          
 199          data unsigned int  g_debugUSB_INT_CNT = 0;
 200          data unsigned char g_debugTimer2_INT_CNT = 0;
 201          
 202          
 203          
 204          
 205          
 206          
 207          
 208          
 209          void initXREG(void)
 210          /******************************************************************************
 211           Function   : void initXREG()
 212           Parameters : (void)
 213           Description: Init of uPSD's xregs
 214           ******************************************************************************/
 215           {
 216   1      
 217   1      /************ VM ************/
 218   1        UPSD_xreg.VM |= 0x80;
 219   1                                                   // bit 7 - PIO (1=enable)
 220   1                                                   // bit 4 - RD access FLASH (1=enable)
 221   1                                                  // bit 3 - RD access EEPROM (1=enable)
 222   1                                                 // bit 2 - PSEN access FLASH (1=enable)
 223   1                                                // bit 1 - PSEN access EEPROM (1=enable)
 224   1                                                  // bit 0 - PSEN access SRAM (1=enable)
 225   1      
 226   1      
 227   1      /****** power management ******/
 228   1        UPSD_xreg.PMMR0=0x38;                      // power-on default = 0x00
 229   1                                                 // bit 5 - CLKIN input to MCell (1=off)
 230   1                                             // bit 4 - CLKIN input to PLD array (1=off)
 231   1                                       // bit 3 - PLD turbo mode (ZPSD only) (1=disable)
 232   1                                                   // bit 1 - APD unit (1=enable)
 233   1      
 234   1        UPSD_xreg.PMMR2=0x70;                      // power-on default = 0x00
 235   1                                               // bit 6 - DBE input to PLD array (1=off)
 236   1                                               // bit 5 - ALE input to PLD array (1=off)
 237   1                                             // bit 4 - CNTL2 input to PLD array (1=off)
 238   1                                             // bit 3 - CNTL1 input to PLD array (1=off)
 239   1                                             // bit 2 - CNTL0 input to PLD array (1=off)
 240   1       }
 241          
C51 COMPILER V7.10   MAIN                                                                  04/30/2004 12:57:59 PAGE 5   

 242          
 243          
 244          
 245          
 246          
 247          
 248          
 249          
 250          
 251          
 252          
 253          
 254          #ifdef DisconnectOnDemand
              
              static void ReConnectUSB()
              /******************************************************************************
               Function   : static void ReConnectUSB()
               Parameters : none
               Description: Use insted of UsbInitialize when DisconnectOnDemand feature
                            is implemented.
                            Be sure that the DisconnectOnDemand feature is present on DK3200.
               ******************************************************************************/
               {
                data int w;
              
                UIEN = 0;                                  // Disable all USB interrupts
                UADR = 0;                                  // Disable USB hardware
              
                LCDBufTXIndex = 0;                         // LCD disp position for USB
              
                UPSD_xreg.DATAOUT_C &= 0xEF;               // PC4=0
                UPSD_xreg.DRIVE_C |= 0x10;                 // set as OpenDrain
                UPSD_xreg.DIRECTION_C |= 0x10;             // set as output
              
                printfLCD("\rUSB Disconnected");
              

⌨️ 快捷键说明

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