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

📄 mainloop.lst

📁 PDIUSBD12 USB1.1 C51源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V4.01,  MAINLOOP                                                              07/07/01  13:16:07  PAGE 1   


DOS C51 COMPILER V4.01, COMPILATION OF MODULE MAINLOOP
OBJECT MODULE PLACED IN MAINLOOP.OBJ
COMPILER INVOKED BY: C:\KEIL\C51V4\BIN\C51.EXE MAINLOOP.C DEBUG SMALL CODE SYMBOLS OBJECTEXTEND NOAMAKE

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             // Created:		19 Dec 97
  11             // Modified:		ww
  12             // Revision:		3.0
  13             //
  14             //*************************************************************************
  15             //
  16             // 98/11/25		Added I/O access support on Main endpoints. (WK)
  17             //*************************************************************************
  18             */
  19          
  20          #include <stdio.h>
  21          #include <string.h>
  22          
  23          #include <reg51.h>                /* special function register declarations   */
  24          
  25          #include "epphal.h"
  26          #include "d12ci.h"
  27          #include "mainloop.h"
  28          #include "usb100.h"
  29          #include "chap_9.h"
  30          #include "protodma.h"
  31          #define  Wakeup_Flag_From_Suspend 0xC3
  32          
  33          
  34          /*
  35          //*************************************************************************
  36          // USB protocol function pointer arrays
  37          //*************************************************************************
  38          */
  39          code void (*StandardDeviceRequest[])(void) =
  40          {
  41          	get_status,
  42          	clear_feature,
  43          	reserved,
  44          	set_feature,
  45          	reserved,
  46          	set_address,
  47          	get_descriptor,
  48          	reserved,
  49          	get_configuration,
  50          	set_configuration,
  51          	get_interface,
  52          	set_interface,
  53          	reserved,
  54          	reserved,
  55          	reserved,
  56          	reserved
  57          };
  58          
  59          code void (*VendorDeviceRequest[])(void) =
C51 COMPILER V4.01,  MAINLOOP                                                              07/07/01  13:16:07  PAGE 2   

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

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

 192          {
 193   1      	P0 = 0xFF;
 194   1      	P1 = 0xFF;
 195   1      	P2 = 0xFF;
 196   1      	P3 = 0xFF;
 197   1      	MCU_D12CS = 0x0;
 198   1      	D12SUSPD = 0;
 199   1      }
 200          
 201          /*Serial Port */
 202          /*Mode            = 1  /8-bit UART
 203            Serial Port Interrupt    = Disabled         */
 204          /*Receive         = Enabled   */
 205          /*Auto Addressing    = Disabled   */
 206          void init_serial(void)
 207          {
 208   1      	SCON = 0X52;
 209   1      	PCON = 0X80 | PCON;
 210   1      	TMOD = 0X20;
 211   1      	TCON = 0x69;    /* TCON */
 212   1      	TH1 = 0xF3;
 213   1      }
 214          
 215          void on_exit(void)
 216          {
 217   1      }
 218          
 219          void main(void)
 220          {
 221   1      	unsigned char key, i;
 222   1              MCU_D12CS=0x00;
 223   1      
 224   1      	init_port();
 225   1      	init_serial();
 226   1      	init_timer0();
 227   1      	init_special_interrupts();
 228   1      
 229   1      	MCU_D12CS = 0x1;
 230   1      
 231   1              for(i = 0; i < 16; i ++)
 232   1      		MainEpBuf[i] = i;
 233   1      
 234   1      	for(i = 0; i < 16; i ++) {
 235   2      		if(MainEpBuf[i] != i)
 236   2      			break;
 237   2      		}
 238   1      
 239   1      
 240   1      	if(i < 16)
 241   1      		bNoRAM = TRUE;
 242   1      	else
 243   1      		bNoRAM = FALSE;
 244   1      
 245   1              MCU_D12CS = 0x0; //Enable Chip select
 246   1      
 247   1      
 248   1      	if(MCU_SWM0 == 0 && MCU_SWM1 == 0) {
 249   2      		MCU_D12RST = 0;
 250   2      		MCU_D12RST = 0;
 251   2      		MCU_D12RST = 0;
 252   2                      MCU_D12RST = 1; // reset D12
 253   2      
 254   2                      D12_SetDMA(0x0); // Disable Main IN/Out Interrupt....
 255   2      	}
 256   1      
 257   1      
C51 COMPILER V4.01,  MAINLOOP                                                              07/07/01  13:16:07  PAGE 5   

 258   1              MCU_D12CS=0;
 259   1              i = D12_GetDMA();            
 260   1              i &= Wakeup_Flag_From_Suspend;
 261   1      
 262   1              if(i == Wakeup_Flag_From_Suspend ) {   // read back data following command 0xFB
 263   2      
 264   2                      D12_SendResume(); // wake up Host 
 265   2                 }
 266   1      
 267   1      
 268   1      	else {
 269   2      		bEPPflags.value = 0;
 270   2      
 271   2      		/* Power on reset, lightup LEDs for 1 sec,
 272   2      		   disconnect and reconnect Soft-Connect */
 273   2      		printf("\nPDIUSBD12 SMART evaluation board firmware V3.0.\n");
 274   2      
 275   2      		reconnect_USB();
 276   2      	}
 277   1      	/* Main program loop */
 278   1      
 279   1      	while( TRUE ){
 280   2      
 281   2      		if (bEPPflags.bits.timer){
 282   3      			DISABLE;
 283   3      			bEPPflags.bits.timer = 0;
 284   3      			ENABLE;
 285   3      
 286   3      			if(bEPPflags.bits.configuration)
 287   3      				check_key_LED();
 288   3      		}
 289   2      
 290   2      		if(RI) {
 291   3      			key = _getkey();
 292   3      			switch(key) {
 293   4      				case 'i':
 294   4      					if(bEPPflags.bits.control_state == USB_IDLE)
 295   4      						printf("Control state = USB_IDLE.");
 296   4      					else if(bEPPflags.bits.control_state == USB_RECEIVE)
 297   4      						printf("Control state = USB_RECEIVE.");
 298   4      					else if(bEPPflags.bits.control_state == USB_TRANSMIT)
 299   4      						printf("Control state = USB_TRANSMIT.");

⌨️ 快捷键说明

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