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

📄 ufi.lst

📁 单片机读写优盘
💻 LST
📖 第 1 页 / 共 2 页
字号:
 133   1              BlockCommand.CbwBlock.dCBW_DataXferLen=0x08000000;
 134   1              BlockCommand.CbwBlock.bCBW_Flag=0x80;
 135   1              BlockCommand.CbwBlock.bCBW_LUN=0;       
 136   1              //BlockCommand.CbwBlock.CBW_CDBLen=sizeof(READ_CAPACITY);
 137   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(READ_CAPACITY);
 138   1              //-----------------------------------------------------------------
 139   1              //包含在CBWCB中的READCAPACITY命令
 140   1              //------------------------------------------------------------------    
 141   1              BlockCommand.CbwBlock.CBWCommand.Ufi_ReadCapacity.OperationCode=UFI_CMD_READCAPACITY;
 142   1              DelayMs(45);
 143   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock),0))
 144   1                      return FALSE;
 145   1              DelayMs(45);
 146   1              if(!BulkIn((BYTE *)bBUF,8))
 147   1                      return FALSE;
 148   1              DelayMs(45);
 149   1              if(!BulkIn((BYTE *)&BlockCommand.CswBlock,13))
 150   1                      return FALSE;   
 151   1              return TRUE;
 152   1      }
 153          //**********************************************************************
 154          //读取U盘中的数据
 155          //**********************************************************************
 156          BYTE Read(DWORD dlba,BYTE blen,BYTE *pbBuffer)
 157          {       BYTE i;
 158   1              ////////////////////////////////////////////////////////////////////////
 159   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
 160   1              BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;
 161   1              BlockCommand.CbwBlock.dCBW_DataXferLen=DWordSwap(blen*512);
 162   1              BlockCommand.CbwBlock.bCBW_Flag=0x80;
 163   1              BlockCommand.CbwBlock.bCBW_LUN=0;
 164   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(READ);
 165   1              //-----------------------------------------------------------------
 166   1              //包含在CBWCB中的READ命令
 167   1              //------------------------------------------------------------------
 168   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Read.OperationCode=UFI_CMD_READ;
 169   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Read.Reserved1=0;
 170   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Read.LBA=dlba;
 171   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Read.ReadLength=blen;
 172   1              DelayMs(100);
 173   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock),0))
 174   1                      return FALSE;
 175   1              i=100;
 176   1              while(i--)
C51 COMPILER V7.06   UFI                                                                   07/30/2008 08:56:13 PAGE 4   

 177   1              {
 178   2                      DelayMs(1);
 179   2                      if(BulkIn(pbBuffer,blen*512))
 180   2                              break;
 181   2              }       
 182   1              if(i==0)
 183   1                      return FALSE;
 184   1              DelayMs(2);
 185   1              if(!BulkIn((BYTE *)&BlockCommand.CswBlock,13))
 186   1                      return FALSE;
 187   1              return TRUE;
 188   1      }
 189          //**********************************************************************
 190          //写数据到U盘
 191          //**********************************************************************
 192          BYTE Write(DWORD dlba,BYTE blen,BYTE *pbBuffer,BYTE bWaitTime)
 193          {
 194   1              BYTE i;
 195   1              ////////////////////////////////////////////////////////////////////////
 196   1              BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
 197   1              BlockCommand.CbwBlock.dCBW_Tag=0xb4d977c1;
 198   1              BlockCommand.CbwBlock.dCBW_DataXferLen=DWordSwap(blen*512);
 199   1              BlockCommand.CbwBlock.bCBW_Flag=0x0;
 200   1              BlockCommand.CbwBlock.bCBW_LUN=0;
 201   1              BlockCommand.CbwBlock.bCBW_CDBLen=sizeof(WRITE);
 202   1              //-----------------------------------------------------------------
 203   1              //包含在CBWCB中的WRITE命令
 204   1              //------------------------------------------------------------------
 205   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Write.OperationCode=UFI_CMD_WRITE;
 206   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Write.Reserved1=0;
 207   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Write.LBA=dlba;
 208   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Write.WriteLength=blen;
 209   1              BlockCommand.CbwBlock.CBWCommand.Ufi_Write.Reserved2=0; 
 210   1              if(!BulkOut((BYTE *)&BlockCommand.CbwBlock,sizeof(BlockCommand.CbwBlock),0))    
 211   1                      return FALSE;
 212   1              //DelayMs(bwaittime);   
 213   1              DelayMs(200);
 214   1              if(!BulkOut(pbBuffer,512*blen,dlba))
 215   1                      return FALSE;                           
 216   1              i=10;
 217   1              while(i--)
 218   1              {
 219   2                      if(BulkIn((BYTE *)&BlockCommand.CswBlock,13))
 220   2                              break;
 221   2              }
 222   1              if(i==0)
 223   1                      return FALSE;
 224   1              return TRUE;    
 225   1      }
*** WARNING C280 IN LINE 192 OF UFI.C: 'bWaitTime': unreferenced local variable
 226          BYTE PollDisk(void)
 227          {
 228   1              //也许需要延长一定的时间,在每个测试参数后面
 229   1      //      BYTE Cache[512];
 230   1      //      BYTE i;
 231   1              DelayMs(100);
 232   1              if(!Inquiry())
 233   1                      return FALSE;
 234   1              if(!TestUnit())
 235   1                      return FALSE;
 236   1              if(!RequestSense())
 237   1                      return FALSE;
C51 COMPILER V7.06   UFI                                                                   07/30/2008 08:56:13 PAGE 5   

 238   1              if(!TestUnit())
 239   1                      return FALSE;
 240   1              if(!ReadCapacity())
 241   1                      return FALSE;   
 242   1              if(!RequestSense())
 243   1                      return FALSE;
 244   1              if(!TestUnit())
 245   1                      return FALSE;
 246   1              if(!ReadCapacity())
 247   1                      return FALSE;   
 248   1              if(!TestUnit())
 249   1              return FALSE;
 250   1          if(!RequestSense())
 251   1                      return FALSE;
 252   1      
 253   1              return TRUE;
 254   1      }
 255          //************************************************************************
 256          //author:dragon
 257          //web:8dragon.com
 258          //2004.2.5完成于桃龙源
 259          //*************************************************************************


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1145    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----      34
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =     31    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  4 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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