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

📄 periph.lst

📁 ezUSB fireware 的固件
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V5.50,  PERIPH                                                                26/07/00  13:53:27  PAGE 1   


DOS C51 COMPILER V5.50, COMPILATION OF MODULE PERIPH
OBJECT MODULE PLACED IN PERIPH.OBJ
COMPILER INVOKED BY: C:\C51\BIN\C51.EXE PERIPH.C DB OE MODDP2

stmt level    source

   1          #pragma NOIV					// Do not generate interrupt vectors
   2          //-----------------------------------------------------------------------------
   3          //	File:		periph.c
   4          //	Contents:	Hooks required to implement USB peripheral function.
   5          //
   6          //	Copyright (c) 1997 AnchorChips, Inc. All rights reserved
   7          //      Adapted for use with HIDs by Jan Axelson (jan@lvr.com)
   8          //-----------------------------------------------------------------------------
   9          #include <ezusb.h>
  10          #include <ezregs.h>
  11          
  12          extern BOOL	GotSUD;			// Received setup data flag
  13          extern BOOL	Sleep;
  14          extern BOOL	Rwuen;
  15          extern BOOL	Selfpwr;
  16          
  17          BYTE	Configuration;		// Current configuration
  18          BYTE	AlternateSetting;	// Alternate settings
  19          BYTE  suspCount;
  20          
  21          // HID code start
  22          BYTE InReportBytes;
  23          void *dscr_ptr;
  24          // HID code end
  25          
  26          //-----------------------------------------------------------------------------
  27          // Task Dispatcher hooks
  28          //	The following hooks are called by the task dispatcher.
  29          //-----------------------------------------------------------------------------
  30          
  31          void TD_Init(void) 				// Called once at startup
  32          {
  33   1      	// Enable endpoints 0-7 IN and OUT
  34   1      	//IN07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
  35   1      	//OUT07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
  36   1      
  37   1      //HID code start
  38   1      //Comment out the above two lines and enable only the endpoints used by the HID interface.
  39   1      	IN07VAL |= bmEP1 ;
  40   1      	OUT07VAL |= bmEP2;
  41   1      //HID code end
  42   1      
  43   1         // Enable interrupts for the OUT endpoints
  44   1      //   OUT07IEN |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
  45   1      
  46   1      //HID code start
  47   1      //Comment out the above line and enable interrupts for the endpoints used by the HID interface.
  48   1      // Enable interrrupts for Endpoint 2 OUT
  49   1         OUT07IEN |= bmEP2;
  50   1      // Enable interrupts for Endpoint 1 IN
  51   1         IN07IEN |= bmEP1;
  52   1      
  53   1      //HID code end
  54   1      
  55   1         suspCount = 1;
  56   1      
  57   1         OEA = 0xFF;
  58   1      
  59   1         Rwuen = TRUE;				// Enable remote-wakeup
C51 COMPILER V5.50,  PERIPH                                                                26/07/00  13:53:27  PAGE 2   

  60   1      }
  61          
  62          void TD_Poll(void) 				// Called repeatedly while the device is idle
  63          {
  64   1      }
  65          
  66          BOOL TD_Suspend(void) 			// Called before the device goes into suspend mode
  67          {
  68   1      	return(TRUE);
  69   1      }
  70          
  71          BOOL TD_Resume(void) 			// Called after the device resumes
  72          {
  73   1      	return(TRUE);
  74   1      }
  75          
  76          //-----------------------------------------------------------------------------
  77          // Device Request hooks
  78          //	The following hooks are called by the end point 0 device request parser.
  79          //-----------------------------------------------------------------------------
  80          
  81          BOOL DR_GetDescriptor(void)
  82          {
  83   1      	return(TRUE);
  84   1      }
  85          
  86          BOOL DR_SetConfiguration(void)	// Called when a Set Configuration command is received
  87          {
  88   1      	Configuration = SETUPDAT[2];
  89   1      	return(TRUE);				// Handled by user code
  90   1      }
  91          
  92          BOOL DR_GetConfiguration(void)	// Called when a Get Configuration command is received
  93          {
  94   1      	IN0BUF[0] = Configuration;
  95   1      	EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
  96   1      	return(TRUE);				// Handled by user code
  97   1      }
  98          
  99          BOOL DR_SetInterface(void) 		// Called when a Set Interface command is received
 100          {
 101   1      	AlternateSetting = SETUPDAT[2];
 102   1      	return(TRUE);				// Handled by user code
 103   1      }
 104          
 105          BOOL DR_GetInterface(void) 		// Called when a Set Interface command is received
 106          {
 107   1      	IN0BUF[0] = AlternateSetting;
 108   1      	EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
 109   1      	return(TRUE);				// Handled by user code
 110   1      }
 111          
 112          BOOL DR_GetStatus(void)
 113          {
 114   1      	return(TRUE);
 115   1      }
 116          
 117          BOOL DR_ClearFeature(void)
 118          {
 119   1      	return(TRUE);
 120   1      }
 121          
 122          BOOL DR_SetFeature(void)
 123          {
 124   1      	return(TRUE);
 125   1      }
C51 COMPILER V5.50,  PERIPH                                                                26/07/00  13:53:27  PAGE 3   

 126          
 127          #define EZUSB_UNARM_EP(ep_id)  			EPIO[ep_id].cntrl = bmEPBUSY
 128          
 129          BOOL DR_VendorCmnd(void)
 130          {
 131   1         return(TRUE);
 132   1      }
 133          
 134          //-----------------------------------------------------------------------------
 135          // USB Interrupt Handlers
 136          //	The following functions are called by the USB interrupt jump table.
 137          //-----------------------------------------------------------------------------
 138          
 139          
 140          // Setup Data Available Interrupt Handler
 141          void ISR_Sudav(void) interrupt 0
 142          {
 143   1      	GotSUD = TRUE;				// Set flag
 144   1      
 145   1      
 146   1      	EZUSB_IRQ_CLEAR();
 147   1      	USBIRQ = bmSUDAV;			// Clear SUDAV IRQ
 148   1      }
 149          
 150          // Setup Token Interrupt Handler
 151          void ISR_Sutok(void) interrupt 0
 152          {
 153   1      	EZUSB_IRQ_CLEAR();
 154   1      	USBIRQ = bmSUTOK;			// Clear SUTOK IRQ
 155   1      }
 156          
 157          void ISR_Sof(void) interrupt 0
 158          {
 159   1      	EZUSB_IRQ_CLEAR();
 160   1      	USBIRQ = bmSOF;				// Clear SOF IRQ
 161   1      }
 162          
 163          void ISR_Ures(void) interrupt 0
 164          {
 165   1         // Arm all of the OUT endpoints so they can accept data
 166   1         //   EPIO[OUT1BUF_ID].bytes = 0;
 167   1      
 168   1      // HID code start
 169   1         // Arm the HID endpoints by loading the byte count registers.
 170   1         // Get the number of bytes the In report will send.
 171   1         // This information is in Report Count in the report descriptor,
 172   1         // and in Report_Count_In_Value in the REPORTDSCR structure.
 173   1         // (Assumes that ReportSize (specified in the report descriptor) = 8).
 174   1         // To do: calculate the number of bytes to send for reports with any ReportSize.
 175   1         REPORTDSCR *rdp;
 176   1         dscr_ptr = (REPORTDSCR xdata *) pReportDscr;
 177   1         rdp = dscr_ptr;
 178   1         InReportBytes = rdp -> Report_Count_In_Value;
 179   1         EPIO[IN1BUF_ID].bytes = InReportBytes;
 180   1         // The value for Out reports can be anything.
 181   1         EPIO[OUT2BUF_ID].bytes = 64;
 182   1      // HID code end
 183   1      
 184   1      //   EPIO[OUT3BUF_ID].bytes = 0;
 185   1      //   EPIO[OUT4BUF_ID].bytes = 0;
 186   1      //   EPIO[OUT5BUF_ID].bytes = 0;
 187   1      //   EPIO[OUT6BUF_ID].bytes = 0;
 188   1      //   EPIO[OUT7BUF_ID].bytes = 0;
 189   1      
 190   1      	EZUSB_IRQ_CLEAR();
 191   1      	USBIRQ = bmURES;			// Clear URES IRQ
C51 COMPILER V5.50,  PERIPH                                                                26/07/00  13:53:27  PAGE 4   

 192   1      }
 193          
 194          void ISR_IBN(void) interrupt 0
 195          {
 196   1         // ISR for the IN Bulk NAK (IBN) interrupt.
 197   1      }
 198          
 199          void ISR_Susp(void) interrupt 0
 200          {
 201   1         Sleep = TRUE;
 202   1      
 203   1         EZUSB_IRQ_CLEAR();
 204   1         USBIRQ = bmSUSP;
 205   1      }
 206          
 207          void ISR_Ep0in(void) interrupt 0
 208          {
 209   1      }
 210          
 211          void ISR_Ep0out(void) interrupt 0
 212          {
 213   1      }
 214          
 215          void ISR_Ep1in(void) interrupt 0
 216          {
 217   1      // HID code start
 218   1         // The HID interface uses Endpoint 1 IN.
 219   1         // When an IN transfer completes, rearm Endpoint 1.
 220   1      	IN1BC = InReportBytes;
 221   1         // clear the IRQ
 222   1      	EZUSB_IRQ_CLEAR();
 223   1      	IN07IRQ = bmEP1;
 224   1      //HID code end
 225   1      }
 226          
 227          void ISR_Ep1out(void) interrupt 0
 228          {
 229   1         int i;
 230   1      
 231   1         //
 232   1         // workaround to cover the case where the host thinks the
 233   1         // previous IN completed but EZ-USB didn't receive a valid
 234   1         // handshake (i.e. the ACK was scrambled).  If we have
 235   1         // received new OUT data (which we have, because we're in this
 236   1         // ISR) but the corresponding IN endpoint is still busy, then
 237   1         // we know we missed the handshake.  The solution is to flip
 238   1         // the data toggle and proceed with the new data.
 239   1         //
 240   1         if (EPIO[IN1BUF_ID].cntrl & bmEPBUSY)
 241   1         {
 242   2            TOGCTL = 0x08 | IN1BUF_ID;
 243   2            WRITEDELAY();
 244   2            if (TOGCTL & 0x80)
 245   2               TOGCTL |= 0x20;
 246   2            else
 247   2               TOGCTL |= 0x40;
 248   2         }
 249   1      

⌨️ 快捷键说明

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