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

📄 mainloop.lst

📁 philiphs D12 firmware驱动程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   MAINLOOP                                                              08/06/2006 09:11:07 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MAINLOOP
OBJECT MODULE PLACED IN MAINLOOP.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE MAINLOOP.C BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*
   2             //*************************************************************************
   3             //
   4             //                  P H I L I P S   P R O P R I E T A R Y
   5             //
   6             //           COPYRIGHT (c)   1997 BY PHILIPS SINGAPORE.
   7             //                     --  ALL RIGHTS RESERVED  --
   8             //
   9             // File Name:        MainLoop.C
  10             // Author:           Wenkai Du
  11             // Created:          19 Dec 97
  12             // Modified:
  13             // Revision:         3.0
  14             //
  15             //*************************************************************************
  16             //
  17             // 98/11/25          Added I/O access support on Main endpoints. (WK)
  18             //*************************************************************************
  19             */
  20          
  21          #include <stdio.h>
  22          #include <string.h>
  23          
  24          #include <reg51.h>                /* special function register declarations   */
  25          
  26          #include "epphal.h"
  27          #include "d12ci.h"
  28          #include "mainloop.h"
  29          #include "usb100.h"
  30          #include "chap_9.h"
  31          #include "protodma.h"
  32          /*
  33          //*************************************************************************
  34          // USB protocol function pointer arrays
  35          //*************************************************************************
  36          */
  37          code void (*StandardDeviceRequest[])(void) =
  38          {
  39                  get_status,
  40                  clear_feature,
  41                  reserved,
  42                  set_feature,
  43                  reserved,
  44                  set_address,
  45                  get_descriptor,
  46                  reserved,
  47                  get_configuration,
  48                  set_configuration,
  49                  get_interface,
  50                  set_interface,
  51                  reserved,
  52                  reserved,
  53                  reserved,
  54                  reserved
  55          };
C51 COMPILER V7.06   MAINLOOP                                                              08/06/2006 09:11:07 PAGE 2   

  56          
  57          code void (*VendorDeviceRequest[])(void) =
  58          {
  59                  reserved,
  60                  reserved,
  61                  reserved,
  62                  reserved,
  63                  reserved,
  64                  reserved,
  65                  reserved,
  66                  reserved,
  67                  reserved,
  68                  reserved,
  69                  reserved,
  70                  reserved,
  71                  read_write_register,
  72                  reserved,
  73                  reserved,
  74                  reserved
  75          };
  76          
  77          /*
  78          //*************************************************************************
  79          //  Public static data
  80          //*************************************************************************
  81          */
  82          
  83          extern EPPFLAGS bEPPflags;
  84          extern unsigned long ClockTicks;
  85          extern unsigned char idata GenEpBuf[];
  86          extern IO_REQUEST idata ioRequest;
  87          
  88          extern unsigned char ioSize, ioCount;
  89          extern unsigned char xdata MainEpBuf[];
  90          extern unsigned char idata EpBuf[];
  91          
  92          CONTROL_XFER ControlData;
  93          BOOL bNoRAM;
  94          
  95          code char * _NAME_USB_REQUEST_DIRECTION[] =
  96          {
  97          "Host_to_device",
  98          "Device_to_host"
  99          };
 100          
 101          code char * _NAME_USB_REQUEST_RECIPIENT[] =
 102          {
 103          "Device",
 104          "Interface",
 105          "Endpoint(0)",
 106          "Other"
 107          };
 108          
 109          code char * _NAME_USB_REQUEST_TYPE[] =
 110          {
 111          "Standard",
 112          "Class",
 113          "Vendor",
 114          "Reserved"
 115          };
 116          
 117          code char * _NAME_USB_STANDARD_REQUEST[] =
C51 COMPILER V7.06   MAINLOOP                                                              08/06/2006 09:11:07 PAGE 3   

 118          {
 119          "GET_STATUS",
 120          "CLEAR_FEATURE",
 121          "RESERVED",
 122          "SET_FEATURE",
 123          "RESERVED",
 124          "SET_ADDRESS",
 125          "GET_DESCRIPTOR",
 126          "SET_DESCRIPTOR",
 127          "GET_CONFIGURATION",
 128          "SET_CONFIGURATION",
 129          "GET_INTERFACE",
 130          "SET_INTERFACE",
 131          "SYNC_FRAME"
 132          };
 133          
 134          void help_devreq(unsigned char typ, unsigned char req)
 135          {
 136   1              typ >>= 5;
 137   1      
 138   1              if(typ == USB_STANDARD_REQUEST) {
 139   2              }
 140   1              else {
 141   2                      if(bEPPflags.bits.verbose)
 142   2                              printf("Request Type = %s, bRequest = 0x%bx.\n", _NAME_USB_REQUEST_TYPE[typ],
 143   2                                      req);
 144   2              }
 145   1      }
 146          
 147          /* Configure Timer 0
 148             - Mode                  = 1
 149             - Interrupt                   = ENABLED
 150             - Clock Source                = INTERNAL
 151             - Enable Gating Control    = DISABLED
 152          */
 153          
 154          
 155          void init_timer0(void)
 156          {
 157   1              TMOD &= 0XF0;                    /* clear Timer 0   */
 158   1              TMOD  |= 0X1;
 159   1              TL0 = 0X0;                   /* value set by user    */
 160   1              TH0 = 0X0;                  /* value set by user  */
 161   1              ET0 = 1;        /* IE.1*/
 162   1              TR0 = 1;                /* TCON.4 start timer  */
 163   1              PT0 = 1;
 164   1      
 165   1              EA = 1;
 166   1      }
 167          
 168          /* Interrupt Control Unit */
 169          /*   ****  Enabled interrupts in Interrupt Enable Register ****
 170                   ****  GLOBAL INTERRUPT MUST BE ENABLED FOR ANY OTHER
 171                   ****  INTERRUPT TO WORK!
 172          */
 173          /*                  GLOBAL INTERRUPT DISABLED ALL INTERRUPTS
 174                                                  ARE DISABLED          */
 175          /*                    External interrupt 0      */
 176          /*                        Priority Level = 0    */
 177          /*                        Timer 0 interrupt     */
 178          /*                       Priority Level = 0     */
 179          void init_special_interrupts(void)
C51 COMPILER V7.06   MAINLOOP                                                              08/06/2006 09:11:07 PAGE 4   

 180          {
 181   1              IT0 = 0;
 182   1              EX0 = 1;
 183   1              PX0 = 0;
 184   1      }
 185          
 186          void init_port()
 187          {
 188   1              P0 = 0xFF;
 189   1              P1 = 0xFF;
 190   1              P2 = 0xFF;
 191   1              P3 = 0xFF;
 192   1              MCU_D12CS = 0x0;
 193   1              D12SUSPD = 0;
 194   1      }
 195          
 196          /*Serial Port */
 197          /*Mode            = 1  /8-bit UART
 198            Serial Port Interrupt    = Disabled         */
 199          /*Receive         = Enabled   */
 200          /*Auto Addressing    = Disabled   */
 201          void init_serial(void)
 202          {
 203   1              SCON = 0X52;
 204   1              PCON = 0X80 | PCON;
 205   1              TMOD = 0X20;
 206   1              TCON = 0x69;    /* TCON */
 207   1              TH1 = 0xF3;
 208   1      }
 209          
 210          void on_exit(void)
 211          {
 212   1      }
 213          
 214          void main(void)
 215          {
 216   1              unsigned char key, i;
 217   1      
 218   1              init_port();
 219   1              init_serial();
 220   1              init_timer0();
 221   1              init_special_interrupts();
 222   1      
 223   1              MCU_D12CS = 0x1;
 224   1              for(i = 0; i < 16; i ++)
 225   1                      MainEpBuf[i] = i;
 226   1              for(i = 0; i < 16; i ++) {
 227   2                      if(MainEpBuf[i] != i)
 228   2                              break;
 229   2                      }
 230   1              if(i < 16)
 231   1                      bNoRAM = TRUE;
 232   1              else
 233   1                      bNoRAM = FALSE;
 234   1              MCU_D12CS = 0x0;
 235   1      
 236   1              if(MCU_SWM0 == 0 && MCU_SWM1 == 0) {
 237   2                      MCU_D12RST = 0;
 238   2                      MCU_D12RST = 1;
 239   2                      D12_SetDMA(0x0);
 240   2              }
 241   1      
C51 COMPILER V7.06   MAINLOOP                                                              08/06/2006 09:11:07 PAGE 5   

 242   1              if((i = D12_GetDMA()) == 0xC3) {
 243   2                      D12_SendResume();
 244   2              }
 245   1              else {
 246   2                      bEPPflags.value = 0;
 247   2      
 248   2                      /* Power on reset, lightup LEDs for 1 sec,
 249   2                         disconnect and reconnect Soft-Connect */
 250   2                      printf("\nPDIUSBD12 SMART evaluation board firmware V3.0.\n");
 251   2      
 252   2                      reconnect_USB();
 253   2              }
 254   1              /* Main program loop */
 255   1      
 256   1              while( TRUE ){
 257   2      
 258   2                      if (bEPPflags.bits.timer){
 259   3                              DISABLE;
 260   3                              bEPPflags.bits.timer = 0;
 261   3                              ENABLE;
 262   3      
 263   3                              if(bEPPflags.bits.configuration)
 264   3                                      check_key_LED();
 265   3                      }
 266   2      
 267   2                      if(RI) {
 268   3                              key = _getkey();
 269   3                              switch(key) {
 270   4                                      case 'i':
 271   4                                              if(bEPPflags.bits.control_state == USB_IDLE)

⌨️ 快捷键说明

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