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

📄 f32x_usb_utilities.lst

📁 C8051F320 SOURCE CODE 内容有: * USB Bulk Driver Example * USB Bulk Firmware Example * Host Ap
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   F32X_USB_UTILITIES                                                    07/16/2008 15:35:22 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE F32X_USB_UTILITIES
OBJECT MODULE PLACED IN F32x_USB_Utilities.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe F32x_USB_Utilities.c DB OE

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // F32x_USB_Utilities.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2005 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          //
   9          // Source file for USB firmware. Includes the following support routines:
  10          //
  11          // - HaltEndpoint()
  12          // - EnableEndpoint()
  13          // - GetEpStatus()
  14          // - SetConfiguration()
  15          // - SetInterface()
  16          // - FIFOWrite()
  17          // - FIFORead()
  18          //
  19          //
  20          // How To Test:    See Readme.txt
  21          //
  22          //
  23          // FID:            32X000020
  24          // Target:         C8051F32x
  25          // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  26          //                 Silicon Laboratories IDE version 2.6
  27          // Command Line:   See Readme.txt
  28          // Project Name:   F32x_USB_Bulk
  29          //
  30          //
  31          // Release 1.3
  32          //    -All changes by GP
  33          //    -21 NOV 2005
  34          //    -Changed revision number to match project revision
  35          //     No content changes to this file
  36          //    -Modified file to fit new formatting guidelines
  37          //    -Changed file name from usb_utils.c
  38          //
  39          //
  40          // Release 1.2
  41          //    -Initial Revision (JS)
  42          //    -XX AUG 2003
  43          //
  44          
  45          //-----------------------------------------------------------------------------
  46          // Includes
  47          //-----------------------------------------------------------------------------
  48          
  49          #include "c8051F320.h"
  50          #include "F32x_USB_Registers.h"
  51          #include "F32x_USB_Structs.h"
  52          #include "F32x_USB_Main.h"
  53          #include "F32x_USB_Descriptors.h"
  54          #include "F32x_USB_Config.h"
  55          #include "F32x_USB_Request.h"
C51 COMPILER V7.06   F32X_USB_UTILITIES                                                    07/16/2008 15:35:22 PAGE 2   

  56          
  57          //-----------------------------------------------------------------------------
  58          // Extern Global Variables
  59          //-----------------------------------------------------------------------------
  60          
  61          extern DEVICE_STATUS    gDeviceStatus;
  62          extern code DESCRIPTORS gDescriptorMap;
  63          extern DEVICE_STATUS    gDeviceStatus;
  64          extern EP_STATUS        gEp0Status;
  65          extern EP_STATUS        gEp2OutStatus;
  66          extern EP_STATUS        gEp1InStatus;
  67          
  68          //-----------------------------------------------------------------------------
  69          // HaltEndpoint
  70          //-----------------------------------------------------------------------------
  71          //
  72          // Return Value : None
  73          // Parameters   : 
  74          // 1) UINT uEp
  75          //
  76          //-----------------------------------------------------------------------------
  77          BYTE HaltEndpoint (UINT uEp)
  78          {
  79   1         BYTE bReturnState, bIndex;
  80   1      
  81   1         // Save current INDEX value and target selected endpoint
  82   1         UREAD_BYTE (INDEX, bIndex);
  83   1         UWRITE_BYTE (INDEX, (BYTE)uEp & 0x00EF);
  84   1      
  85   1         // Halt selected endpoint and update its status flag
  86   1         switch (uEp)
  87   1         {
  88   2            case EP1_IN:
  89   2               UWRITE_BYTE (EINCSRL, rbInSDSTL);
  90   2               gEp1InStatus.bEpState = EP_HALTED;
  91   2               bReturnState = EP_IDLE;          // Return success flag
  92   2               break;
  93   2            case EP2_OUT:
  94   2               UWRITE_BYTE (EOUTCSRL, rbOutSDSTL);
  95   2               gEp2OutStatus.bEpState = EP_HALTED;
  96   2               bReturnState = EP_IDLE;          // Return success flag
  97   2               break;
  98   2            default:
  99   2               bReturnState = EP_ERROR;         // Return error flag
 100   2                                                // if endpoint not found
 101   2               break;
 102   2         }
 103   1      
 104   1         UWRITE_BYTE (INDEX, bIndex);           // Restore saved INDEX
 105   1         return bReturnState;
 106   1      }
 107          
 108          //-----------------------------------------------------------------------------
 109          // EnableEndpoint
 110          //-----------------------------------------------------------------------------
 111          //
 112          // Return Value : None
 113          // Parameters   : 
 114          // 1) UINT uEp
 115          //
 116          //-----------------------------------------------------------------------------
 117          BYTE EnableEndpoint (UINT uEp)
C51 COMPILER V7.06   F32X_USB_UTILITIES                                                    07/16/2008 15:35:22 PAGE 3   

 118          {
 119   1         BYTE bReturnState, bIndex;
 120   1      
 121   1         // Save current INDEX value and target selected endpoint
 122   1         UREAD_BYTE (INDEX, bIndex);
 123   1         UWRITE_BYTE (INDEX, (BYTE)uEp & 0x00EF);
 124   1      
 125   1         // Flag selected endpoint has HALTED
 126   1         switch (uEp)
 127   1         {
 128   2            case EP1_IN:
 129   2               // Disable STALL condition and clear the data toggle
 130   2               UWRITE_BYTE (EINCSRL, rbInCLRDT);
 131   2               gEp1InStatus.bEpState = EP_IDLE; // Return success
 132   2               bReturnState = EP_IDLE;
 133   2               break;
 134   2            case EP2_OUT:
 135   2               // Disable STALL condition and clear the data toggle
 136   2               UWRITE_BYTE (EOUTCSRL, rbOutCLRDT);
 137   2               gEp2OutStatus.bEpState = EP_IDLE;// Return success
 138   2               bReturnState = EP_IDLE;
 139   2               break;
 140   2            default:
 141   2               bReturnState = EP_ERROR;         // Return error
 142   2                                                // if no endpoint found
 143   2               break;
 144   2         }
 145   1      
 146   1         UWRITE_BYTE (INDEX, bIndex);           // Restore INDEX
 147   1      
 148   1         return bReturnState;
 149   1      }
 150          
 151          //-----------------------------------------------------------------------------
 152          // GetEpStatus
 153          //-----------------------------------------------------------------------------
 154          //
 155          // Return Value : None
 156          // Parameters   : 
 157          // 1) UINT uEp
 158          //
 159          //-----------------------------------------------------------------------------
 160          BYTE GetEpStatus (UINT uEp)
 161          {
 162   1         BYTE bReturnState;
 163   1      
 164   1         // Get selected endpoint status
 165   1         switch (uEp)
 166   1         {
 167   2            case EP1_IN:
 168   2               bReturnState = gEp1InStatus.bEpState;
 169   2               break;
 170   2            case EP2_OUT:
 171   2               bReturnState = gEp2OutStatus.bEpState;
 172   2               break;
 173   2            default:
 174   2               bReturnState = EP_ERROR;
 175   2               break;
 176   2         }
 177   1      
 178   1         return bReturnState;
 179   1      }
C51 COMPILER V7.06   F32X_USB_UTILITIES                                                    07/16/2008 15:35:22 PAGE 4   

 180          
 181          //-----------------------------------------------------------------------------
 182          // SetConfiguration
 183          //-----------------------------------------------------------------------------
 184          //
 185          // Return Value : None
 186          // Parameters   : 
 187          // 1) BYTE SelectConfig
 188          //
 189          //-----------------------------------------------------------------------------
 190          BYTE SetConfiguration(BYTE SelectConfig)

⌨️ 快捷键说明

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