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

📄 ufi.lst

📁 单片机读写优盘
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   UFI                                                                   07/30/2008 08:56:13 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE UFI
OBJECT MODULE PLACED IN ufi.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ufi.c LARGE BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //************************************************************************
   2          //author:dragon
   3          //web:8dragon.com
   4          //2004.2.5完成于桃龙源
   5          //*************************************************************************
   6          #include "AT89X52.h"
   7          #include "host_811.h"
   8          #include "ufi.h"
   9          BLOCK  idata BlockCommand;
  10          extern idata USBDEV uDev;
  11          extern BYTE bBUF[256];
  12          //*********************************************************************
  13          //*底层的批量传输函数
  14          //*********************************************************************
  15          BYTE BulkOut(BYTE *pbBuffer,UINT len,UINT lba)
  16          {
  17   1              WORD j;
  18   1              ////////////////////////////////////////////////////////////////////////
  19   1              while(len>0)
  20   1              {
  21   2                      if (len >64)
  22   2                              j = 64;
  23   2                      else                            
  24   2                              j= len;
  25   2                      if(!usbXfer(0x01,uDev.bEpOut,PID_OUT,64,j,pbBuffer)) 
  26   2                              return FALSE;
  27   2                      len-=j;
  28   2                      pbBuffer=pbBuffer+j;
  29   2              }
  30   1              return TRUE;
  31   1      }
*** WARNING C280 IN LINE 15 OF UFI.C: 'lba': unreferenced local variable
  32          BYTE BulkIn(BYTE *pbBuffer,UINT len)
  33          {
  34   1              BYTE i;
  35   1              ////////////////////////////////////////////////////////////////////////
  36   1              if(len)
  37   1              {
  38   2                      i=100;
  39   2                      while(!usbXfer(0x01,uDev.bEpin,PID_IN,64,len,pbBuffer))
  40   2                      {
  41   3                               i--;
  42   3                       }
  43   2                      if(i<=0)
  44   2                        return FALSE;
  45   2              }
  46   1              return TRUE;
  47   1      }
  48          //**********************************************************************
  49          //获取U盘的硬件信息
  50          //**********************************************************************
  51          BYTE Inquiry(void)
  52          {
  53   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
  54   1              BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;
C51 COMPILER V7.06   UFI                                                                   07/30/2008 08:56:13 PAGE 2   

  55   1              BlockCommand.CbwBlock.dCBW_DataXferLen=0x24000000;
  56   1              BlockCommand.CbwBlock.bCBW_Flag=0x80;
  57   1              BlockCommand.CbwBlock.bCBW_LUN=0;
  58   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(INQUIRY);
  59   1              //-----------------------------------------------------------------
  60   1              //包含在CBWCB中的Inquiry命令
  61   1              //------------------------------------------------------------------
  62   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Inquiry.OperationCode=UFI_CMD_INQUIRY;
  63   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Inquiry.Reserved0=0;
  64   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Inquiry.PageCode=0;
  65   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Inquiry.AllocationLen=0x24;
  66   1              DelayMs(20);
  67   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock)))
*** WARNING C209 IN LINE 67 OF UFI.C: '_BulkOut': too few actual parameters
  68   1                      return FALSE;   
  69   1              DelayMs(20);
  70   1              if(!BulkIn(bBUF,38))
  71   1                      return FALSE;
  72   1              if(!BulkIn((BYTE *)&BlockCommand.CswBlock,13))
  73   1                      return FALSE;
  74   1              return TRUE;    
  75   1      }
  76          //**********************************************************************
  77          //测试U盘是否可用www.8dragon.com
  78          //**********************************************************************
  79          BYTE TestUnit(void)
  80          {
  81   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
  82   1              BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;
  83   1              BlockCommand.CbwBlock.dCBW_DataXferLen=0x00000000;
  84   1              BlockCommand.CbwBlock.bCBW_Flag=0x00;
  85   1              BlockCommand.CbwBlock.bCBW_LUN=0;
  86   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(TEST_UNIT);
  87   1              //-----------------------------------------------------------------
  88   1              //包含在CBWCB中的TestUnit命令
  89   1              //------------------------------------------------------------------
  90   1              BlockCommand.CbwBlock.CBWCommand.Ufi_TestUnit.OperationCode=UFI_CMD_TESTUNITREADY;
  91   1              DelayMs(70);
  92   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock)))
*** WARNING C209 IN LINE 92 OF UFI.C: '_BulkOut': too few actual parameters
  93   1                      return FALSE;
  94   1              DelayMs(150);
  95   1              if(!BulkIn((BYTE *)&BlockCommand.CswBlock,13))
  96   1                      return FALSE;
  97   1              return TRUE;
  98   1      }
  99          //**********************************************************************
 100          //让U盘传回必要数据
 101          //**********************************************************************
 102          BYTE RequestSense(void)
 103          {
 104   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
 105   1              BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;
 106   1              BlockCommand.CbwBlock.dCBW_DataXferLen=0x0e000000;
 107   1              BlockCommand.CbwBlock.bCBW_Flag=0x80;
 108   1              BlockCommand.CbwBlock.bCBW_LUN=0;
 109   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(REQUEST_SENSE);
 110   1              //-----------------------------------------------------------------
 111   1              //包含在CBWCB中的RSEQUESTSENS命令
 112   1              //------------------------------------------------------------------    
 113   1              BlockCommand.CbwBlock.CBWCommand.Ufi_RequestSense.OperationCode=UFI_CMD_REQUESTSENSE;
 114   1              BlockCommand.CbwBlock.CBWCommand.Ufi_RequestSense.AllocationLen=0x0e;
C51 COMPILER V7.06   UFI                                                                   07/30/2008 08:56:13 PAGE 3   

 115   1              DelayMs(45);
 116   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock),0))
 117   1                      return FALSE;
 118   1              DelayMs(45);
 119   1              if(!BulkIn((BYTE *)bBUF,18))
 120   1                      return FALSE;
 121   1              DelayMs(45);
 122   1              if(!BulkIn((BYTE *)&BlockCommand.CswBlock,13))
 123   1                      return FALSE;
 124   1              return TRUE;    
 125   1      }
 126          //**********************************************************************
 127          //读取已格U盘的容量
 128          //**********************************************************************
 129          BYTE ReadCapacity(void)
 130          {
 131   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
 132   1              BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;

⌨️ 快捷键说明

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