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

📄 xxgmain.lst

📁 一个51写的usb程序 测试过的
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.20c  XXGMAIN                                                               01/16/2003 10:36:17 PAGE 1   


C51 COMPILER V6.20c, COMPILATION OF MODULE XXGMAIN
OBJECT MODULE PLACED IN Xxgmain.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Xxgmain.c ROM(COMPACT) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <stdio.h>
   2          #include <string.h>
   3          
   4          #include <At89x52.h>
   5          
   6          #include "xxghal.h"
   7          #include "xxgmain.h"
   8          #include "xxgd12ci.h"
   9          #include "xxgchap9.h"
  10          #include "xxgprotodma.h"
  11          //=====================================
  12          
  13          /*
  14          //*************************************************************************
  15          // USB protocol function pointer arrays
  16          //*************************************************************************
  17          */
  18          code void (*StandardDeviceRequest[])(void) =
  19          {
  20          	get_status,
  21          	clear_feature,
  22          	reserved,
  23          	set_feature,
  24          	reserved,
  25          	set_address,
  26          	get_descriptor,
  27          	reserved,
  28          	get_configuration,
  29          	set_configuration,
  30          	get_interface,
  31          	set_interface,
  32          	reserved,
  33          	reserved,
  34          	reserved,
  35          	reserved
  36          };
  37          
  38          code void (*VendorDeviceRequest[])(void) =
  39          {
  40          	reserved,
  41          	reserved,
  42          	reserved,
  43          	reserved,
  44          	reserved,
  45          	reserved,
  46          	reserved,
  47          	reserved,
  48          	reserved,
  49          	reserved,
  50          	reserved,
  51          	reserved,
  52          	read_write_register,
  53          	reserved,
  54          	reserved,
  55          	reserved
C51 COMPILER V6.20c  XXGMAIN                                                               01/16/2003 10:36:17 PAGE 2   

  56          };
  57          
  58          
  59          
  60          /*
  61          //*************************************************************************
  62          //  Public static data
  63          //*************************************************************************
  64          */
  65          extern EPPFLAGS bEPPflags;
  66          extern unsigned long ClockTicks;
  67          
  68          extern unsigned char idata GenEpBuf[];
  69          extern IO_REQUEST idata ioRequest;
  70          
  71          extern unsigned char ioSize, ioCount;
  72          extern unsigned char xdata MainEpBuf[];
  73          extern unsigned char idata EpBuf[];
  74          //------------
  75          extern void fn_usb_isr(void);
  76          //-----------
  77          
  78          CONTROL_XFER ControlData;
  79          unsigned char bNoRAM;
  80          
  81          
  82          //==================================================
  83          /*
  84            PCON:		SMOD | - | - | - | GF1|GF0|PD |IDL|
  85            TCON:		TF1  | - |TF0| - |IE1 |IT1|IE0|IT0|
  86              
  87          */
  88          /* Configure Timer 0
  89             - Mode                  = 1
  90             - Interrupt                   = ENABLED
  91             - Clock Source                = INTERNAL
  92             - Enable Gating Control    = DISABLED
  93          */
  94          
  95          
  96          void init_timer0(void)
  97          {
  98   1      	TMOD &= 0XF0;                /* clear Timer 0   */
  99   1      	TMOD  |= 0X1;
 100   1      	TL0 = 0X0;                   /* value set by user    */
 101   1      	TH0 = 0X0;                   /* value set by user  */
 102   1      	ET0 = 1;     		     /* IE.1*/
 103   1      	TR0 = 1;                     /* TCON.4 start timer  */
 104   1      	PT0 = 1;
 105   1      
 106   1      	//EA = 1;
 107   1      }
 108          
 109          
 110          void init_port()
 111          {
 112   1      	P0 = 0xFF;
 113   1      	P1 = 0xFF;
 114   1      	P2 = 0xFF;
 115   1      	P3 = 0xFF;
 116   1      	MCU_D12CS = 0x0;	//D12 Select
 117   1      	D12SUSPD = 0;		//D12 not in Suspend
C51 COMPILER V6.20c  XXGMAIN                                                               01/16/2003 10:36:17 PAGE 3   

 118   1      }
 119          
 120          /*Serial Port */
 121          /*Mode            = 1  /8-bit UART
 122            Serial Port Interrupt    = Disabled         */
 123          /*Receive         = Enabled   */
 124          /*Auto Addressing    = Disabled   */
 125          void init_serial(void)
 126          {
 127   1      	SCON = 0X52;		/* SCON: SM0|SM1|SM2|REN|TB8|RB8|TI|RI		*/
 128   1      	PCON = 0X80 | PCON;	/* PCON: SMOD | - | - | - | GF1|GF0|PD |IDL|    */
 129   1      	TMOD = 0X20;		/* TMOD: GATE|C/T|M1|M0|GATE|C/T|M1|M0 */
 130   1      	TCON = 0x69;    	/* TCON: TF1|TR1|TF0|TR0|IE1|IT1|IE0|IT0 */
 131   1      	TH1 = 0xF3;		/*TH1=0xF3: */
 132   1      }
 133          //----------------------------
 134          /*
 135          void help_devreq(unsigned char typ, unsigned char req)
 136          {
 137          	typ >>= 5;
 138          
 139          	if(typ == USB_STANDARD_REQUEST) {
 140          	}
 141          	else {
 142          		if(bEPPflags.bits.verbose)
 143          			printf("Request Type = %s, bRequest = 0x%bx.\n", _NAME_USB_REQUEST_TYPE[typ],
 144          				req);
 145          	}
 146          }
 147          */
 148          
 149          //=================================================================
 150          void disconnect_USB(void)
 151          {
 152   1      	// Initialize D12 configuration
 153   1      	D12_SetMode(D12_NOLAZYCLOCK|D12_CLOCKRUNNING, D12_SETTOONE | D12_CLOCK_12M);
 154   1      }
 155          
 156          void connect_USB(void)
 157          {
 158   1      	// reset event flags
 159   1      
 160   1      	DISABLE;
 161   1      	bEPPflags.value = 0;
 162   1      	ENABLE;
 163   1      
 164   1      	//	ENABLE_INTERRUPTS;
 165   1      
 166   1      	D12_SetEndpointStatus(4, 0);
 167   1      	D12_SetEndpointStatus(5, 0);
 168   1      	// V2.1 enable normal+sof interrupt
 169   1      	D12_SetDMA(D12_ENDP4INTENABLE | D12_ENDP5INTENABLE);
 170   1      
 171   1      	// Initialize D12 configuration
 172   1      
 173   1      	//D12_SetMode(D12_NOLAZYCLOCK ,D12_SETTOONE | D12_CLOCK_12M );
 174   1      	D12_SetMode(D12_NOLAZYCLOCK |D12_CLOCKRUNNING|D12_SOFTCONNECT,D12_SETTOONE | D12_CLOCK_12M );
 175   1      
 176   1      }
 177          
 178          
 179          void reconnect_USB(void)
C51 COMPILER V6.20c  XXGMAIN                                                               01/16/2003 10:36:17 PAGE 4   

 180          {
 181   1      	unsigned long clk_cnt;
 182   1      
 183   1      	MCU_LED0 = 0;
 184   1      	MCU_LED1 = 0;
 185   1      
 186   1      	// Pull-down D12's SUSPEND pin
 187   1      	// Disable 74HCT123 pulse generation before disconnect
 188   1      	// Release D12's SUSPEND pin after receiving bus reset from host
 189   1      	D12SUSPD = 0;
 190   1      	disconnect_USB();
 191   1      	ENABLE;
 192   1      	//printf("Wait for 1 second ...\n");
 193   1      	clk_cnt = ClockTicks;
 194   1      	while(ClockTicks < clk_cnt + 20);
 195   1      	DISABLE;
 196   1      	
 197   1      	connect_USB();
 198   1      	MCU_LED0 = 1;
 199   1      	MCU_LED1 = 1;
 200   1      
 201   1      }
 202          //------------------------------
 203          void stall_ep0(void)
 204          {
 205   1      	D12_SetEndpointStatus(0, 1);
 206   1      	D12_SetEndpointStatus(1, 1);
 207   1      }
 208          
 209          //---------------
 210          
 211          //----------------------------------
 212          void check_key_LED(void)
 213          {
 214   1      	static unsigned char c, last_key = 0xf;
 215   1      
 216   1      	c = MCU_SWM0 & MCU_SWM1;
 217   1      	c &= 0x0f;
 218   1      	if (c != last_key) {
 219   2      		D12_WriteEndpoint(3, 1, &c);
 220   2      	}
 221   1      
 222   1      	last_key = c;
 223   1      
 224   1      	if(bEPPflags.bits.ep1_rxdone) {
 225   2      		DISABLE;
 226   2      		bEPPflags.bits.ep1_rxdone = 0;
 227   2      		ENABLE;
 228   2      		MCU_LED0 = !(GenEpBuf[3] & 0x1);
 229   2      		MCU_LED1 = !(GenEpBuf[3] & 0x2);
 230   2      	}
 231   1      }
 232          //--------------------------
 233          void init_unconfig(void)
 234          {
 235   1      	//unsigned char i;
 236   1      
 237   1      	D12_SetEndpointEnable(0);	/* Disable all endpoints but EPP0. */
 238   1      }
 239          
 240          void init_config(void)

⌨️ 快捷键说明

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