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

📄 main.lst

📁 基于MCU的U盘源码
💻 LST
字号:
C51 COMPILER V7.09   MAIN                                                                  05/11/2005 17:30:28 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN MAIN.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE MAIN.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <string.h> 
   2          //#include "..\inc\option.h"
   3          //#include "..\inc\def.h"
   4          //#include "..\inc\44b.h"
   5          //#include "..\inc\44blib.h"
   6          //#include "..\inc\flash.h"
   7          //#include "..\inc\download.h"
   8          /
*** ERROR C141 IN LINE 8 OF MAIN.C: syntax error near '/'
   9          
  10          //#include "..\inc\cache.h"
  11          //#include "..\inc\lcd240.h"
  12          //#include "..\inc\KeyBoard16.h"
  13          //#include "..\inc\ata.h"
  14          #include <stdio.h>
  15          //following is CPU test functions include
  16          //#include "..\inc\cputest\adc.h"
  17          
  18          //#include "..\inc\cputest\idle.h"
  19          //#include "..\inc\cputest\iic.h"
  20          //#include "..\inc\cputest\iis.h"
  21          //#include "..\inc\cputest\nwait.h"
  22          //#include "..\inc\cputest\power.h"
  23          //#include "..\inc\cputest\rtc.h"
  24          //#include "..\inc\cputest\sio.h"
  25          //#include "..\inc\cputest\stop.h"
  26          //#include "..\inc\cputest\timer.h"
  27          //#include "..\inc\cputest\uart.h"
  28          
  29          
  30          
  31          #include "main.h"
*** ERROR C129 IN LINE 101 OF MAIN.H: missing ';' before 'struct'
  32          #include "d12ci.h"
  33          #include "isr.h"
  34          #include "chap9.h"
  35          #include "usb100.h"
  36          
  37          #include "..\fat16\fat16.h"
*** WARNING C318 IN LINE 37 OF MAIN.C: can't open file '..\fat16\fat16.h'
  38          #include "..\bulk\bulk_only.h"
*** WARNING C318 IN LINE 38 OF MAIN.C: can't open file '..\bulk\bulk_only.h'
  39          //*******************************
  40          
  41          extern unsigned char *downPt;
  42          extern unsigned int fileSize;
  43          
  44          EPPFLAGS bEPPflags;
  45          CONTROL_XFER ControlData;
  46          
  47          //migrated for 51ok
  48          extern unsigned long ClockTicks;
  49          
  50          extern unsigned char  GenEpBuf[];
  51          extern IO_REQUEST  ioRequest;
C51 COMPILER V7.09   MAIN                                                                  05/11/2005 17:30:28 PAGE 2   

  52          
  53          extern unsigned char ioSize, ioCount;
  54          extern unsigned char  MainEpBuf[];
  55          extern unsigned char  EpBuf[];
  56          
  57          extern U8 Flash_One_Page[];
  58          
  59          
  60          extern U8 Bulk_In_Buf[];
  61          extern U32 Logical_Block_Address;
  62          extern U32 nCurrentPage,nBeginPage;
  63          extern U8 Flash_One_Page[];
  64          
  65          //////////////////////////////////////////////
  66          static void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;
  67          
  68          U16 EthernetMac[3];
  69          
  70          void (*StandardDeviceRequest[])(void) =
  71          {
  72                  get_status,
  73                  clear_feature,
  74                  reserved,
  75                  set_feature,
  76                  reserved,
  77                  set_address,
  78                  get_descriptor,
  79                  reserved,
  80                  get_configuration,
  81                  set_configuration,
  82                  get_interface,
  83                  set_interface,
  84                  reserved,
  85                  reserved,
  86                  reserved,
  87                  reserved
  88          };
  89          
  90          
  91          void Isr_Init(void)
  92          {
  93                  rINTCON=0x5;             ////3(reserved)        2(V 0=vector 1= non vector)     1(I,0=Enable IRQ,1=Disable IRQ) 0(FIQ Rel
             -ated0=enable 1=diable)
  94                                                          // 1,Non-vectored,0,IRQ enable,1,FIQ disable //
  95                                                          // 1,1,1 0x7,disable interupt.
  96                  rINTMOD=0x0;          //0=IRQ mode Set all of the INT to IRQ mode//
  97                  
  98                  rI_ISPC=BIT_EINT2;
  99                  rINTMSK=BIT_GLOBAL;
 100                  //pISR_FIQ,pISR_IRQ must be initialized//
 101                  pISR_EINT2=(unsigned)usb_isr;
 102                  rINTMSK=~(BIT_EINT0 |BIT_EINT2 | ~BIT_GLOBAL);
 103          
 104              
 105                  //pISR_FIQ,pISR_IRQ must be initialized//
 106          }
 107          
 108          void reconnect_USB(void)
 109          {
 110                  unsigned long clk_cnt;
 111          
 112                  MCU_LED0 = MCU_LED0_ON;
C51 COMPILER V7.09   MAIN                                                                  05/11/2005 17:30:28 PAGE 3   

 113                  MCU_LED1 = MCU_LED1_ON;
 114          
 115                  D12SUSPD = D12SUSPD_ON;
 116                  //Disconnect Usb
 117                  D12_SetMode(D12_NOLAZYCLOCK, D12_SETTOONE | D12_CLOCK_12M);
 118          
 119                  Delay(500);
 120          
 121                  //Connect USB
 122                  DISABLE;
 123                  bEPPflags.value = 0;
 124                  ENABLE;
 125          
 126                  // V2.1 enable normal+sof interrupt
 127                  D12_SetDMA(D12_ENDP4INTENABLE | D12_ENDP5INTENABLE);
 128          
 129                  // Initialize D12 configuration
 130          
 131                  //D12_SetMode(D12_NOLAZYCLOCK ,D12_SETTOONE | D12_CLOCK_12M );
 132                  D12_SetMode(D12_ENDP_NONISO |D12_NOLAZYCLOCK | D12_SOFTCONNECT|D12_CLOCKRUNNING,D12_SETTOONE | D12_CLOCK_
             -12M );
 133                  
 134                  //End of Connect USB
 135                  MCU_LED0 = MCU_LED0_OFF;
 136                  MCU_LED1 = MCU_LED1_OFF;
 137                  
 138          }
 139          
 140          
 141          
 142          void control_handler(void)
 143          {
 144                  unsigned char type, req;
 145                  
 146                  type = ControlData.DeviceRequest.bmRequestType & USB_REQUEST_TYPE_MASK; //0x60
 147                  req = ControlData.DeviceRequest.bRequest & USB_REQUEST_MASK;            //0x0F
 148                  //help_devreq(type, req); // print out device request
 149          
 150                  if (type == USB_STANDARD_REQUEST)
 151                          (*StandardDeviceRequest[req])();
 152                  else{
 153                          stall_ep0();
 154                          }
 155          }
 156          
 157          void single_transmit(unsigned char * buf, unsigned char len)
 158          {
 159          if( len <= EP0_PACKET_SIZE) {
 160          D12_WriteEndpoint(1, len,buf);
 161          }
 162          }
 163          
 164          void code_transmit(unsigned char  * pRomData, unsigned short len)
 165          {
 166                  ControlData.wCount = 0;
 167                  if(ControlData.wLength > len)
 168                  ControlData.wLength = len;
 169                  ControlData.pData = pRomData;
 170                  if( ControlData.wLength >= EP0_PACKET_SIZE) {
 171                          D12_WriteEndpoint(1,EP0_PACKET_SIZE, ControlData.pData);
 172                          ControlData.wCount = ControlData.wCount + EP0_PACKET_SIZE;
 173          //              Uart_Printf("len=%d,wCount=%d\n",len,ControlData.wCount);
C51 COMPILER V7.09   MAIN                                                                  05/11/2005 17:30:28 PAGE 4   

 174                          DISABLE;
 175                          bEPPflags.bits.control_state = USB_TRANSMIT;
 176                          ENABLE;
 177                          }
 178                  else {
 179                          D12_WriteEndpoint(1, ControlData.wLength,pRomData);
 180                          ControlData.wCount = ControlData.wCount + ControlData.wLength;
 181          //              Uart_Printf("else*code_transmit,len=%d,wCount=%d\n",len,ControlData.wCount);
 182                          DISABLE;
 183                          bEPPflags.bits.control_state = USB_IDLE;
 184                          ENABLE;
 185                          }
 186          //      Uart_Printf("bEPPflags.bits.control_state=%d\n",bEPPflags.bits.control_state);
 187          }
 188          
 189          
 190          
 191          void stall_ep0(void)
 192          {
 193          D12_SetEndpointStatus(0, 1);
 194          D12_SetEndpointStatus(1, 1);
 195          
 196          }
 197          
 198          void Main(void)
 199          {
 200                  int i;
 201                  rSYSCFG=CACHECFG;       // Using 8KB Cache//
 202          
 203                  Uart_Init(0,115200);
 204                  Port_Init();
 205                  Isr_Init();
 206                  Delay(0);
 207                  downPt=(unsigned char *)DOWNLOAD_ADDRESS;
 208          
 209          
 210                  Flash_Reset();
 211          
 212                  Uart_Select(0); //Select UART0//
 213          
 214                  rINTMSK=~(BIT_EINT0 |BIT_EINT2| BIT_GLOBAL);
 215          
 216          //      Format_Fat16Media();//将Flash格式化成Fat16
 217          //      for(i=0;i<32*528;i+=528) Flash_One_Page[i+5] = 0x55;
 218          //      Write2Flash(0,4,14,Flash_One_Page);
 219                  Uart_Printf("Hi, This is LiWei!\n");
 220                  reconnect_USB();
 221          
 222          //  D12 usb mainloop program
 223                  while( TRUE ){
 224                          if (bEPPflags.bits.setup_packet){
 225                                  DISABLE;
 226                                  bEPPflags.bits.setup_packet = 0;
 227                                  ENABLE;
 228                                  control_handler();
 229                                  //D12SUSPD = 1;
 230                                  D12SUSPD=D12SUSPD_ON;
 231                          } // if setup_packet
 232                  }
 233          }
 234          

C51 COMPILATION COMPLETE.  2 WARNING(S),  2 ERROR(S)

⌨️ 快捷键说明

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