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

📄 file.lst

📁 sl811 c8051F驱动程序 保证绝对可以使用 USB通信协议USB1.1
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE FILE
OBJECT MODULE PLACED IN FILE.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE FILE.C LARGE OMF2 BROWSE DEBUG

line level    source

   1          //************************************************************************
   2          //author:dragon
   3          //web:8dragon.com
   4          //2004.2.5完成于桃龙源
   5          //********************************************************************
   6          #include <c8051F020.h>
   7          #include "host_811.h"
   8          #include "file.h"
   9          #include "math.h"
  10          #include "string.h"
  11          #include "ufi.h"
  12          #include <stdio.h>
  13          struct _BPB             SimpleBpb;
  14          struct _FILE    FileControl;
  15          FAT_PARAMETER FatParameter;
  16          xdata WORD FatCache[2][256]  _at_ 0xb100 ;
  17          xdata      BYTE buf[5120]       _at_ 0xc000;
  18          
  19          
  20          BYTE InitFsys()
  21          {       
  22   1        xdata         BYTE buf[512];
  23   1              UINT m_Offset;
  24   1              DWORD DataSectors,TotalClusters;
  25   1              ///////////////////////////////////////////////////////////////////////
  26   1              DelayMs(100);
  27   1              if(Read(0,1,(BYTE *)buf)==FALSE)        
  28   1                      return FALSE;
  29   1              DelayMs(100);
  30   1              if(buf[0x00]==0xEB ||buf[0x02]==0x90)   
  31   1                      m_Offset=0;
  32   1              else
  33   1                      m_Offset=ConvTwoBytes((buf+0x1c6));     
  34   1              if(Read(0+m_Offset,1,(BYTE *)buf)==FALSE)
  35   1                      return FALSE;
  36   1              SimpleBpb.BytsPerSec =ConvTwoBytes((&buf[11]));
  37   1              SimpleBpb.SecPerClus = buf[13];
  38   1              SimpleBpb.RsvdSecCnt =ConvTwoBytes((&buf[14]));
  39   1              SimpleBpb.NumFATs = buf[16];
  40   1              SimpleBpb.RootEntCnt = ConvTwoBytes((&buf[17]));
  41   1              if((SimpleBpb.TotSec = ConvTwoBytes((&buf[19])))==0)
  42   1                      SimpleBpb.TotSec = ConvFourBytes((&buf[32]));   
  43   1              if((SimpleBpb.FATSz = ConvTwoBytes((&buf[22])))==0)
  44   1                      SimpleBpb.FATSz =ConvFourBytes((&buf[36]));
  45   1              //------------------------------------------------------------------------
  46   1              //Compute the corresponding data for Fat information;
  47   1              //------------------------------------------------------------------------
  48   1              FatParameter.RootDirSectors= ((SimpleBpb.RootEntCnt * 32) + (SimpleBpb.BytsPerSec - 1)) / SimpleBpb.BytsP
             -erSec;
  49   1              DataSectors = SimpleBpb.TotSec - (SimpleBpb.RsvdSecCnt + (SimpleBpb.NumFATs * SimpleBpb.FATSz) + FatParam
             -eter.RootDirSectors);
  50   1              TotalClusters = DataSectors / SimpleBpb.SecPerClus;
  51   1              //判断文件格式是否为fat16;
  52   1              if(TotalClusters < 4085 || TotalClusters >= 65525)
  53   1                      return FALSE;   
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 2   

  54   1              FatParameter.FirstFatSecNum=SimpleBpb.RsvdSecCnt+m_Offset;
  55   1              FatParameter.FirstRootDirSecNum = SimpleBpb.RsvdSecCnt + (SimpleBpb.NumFATs * SimpleBpb.FATSz)+m_Offset;
  56   1              FatParameter.FirstDataSector = SimpleBpb.RsvdSecCnt + (SimpleBpb.NumFATs * SimpleBpb.FATSz) + FatParamete
             -r.RootDirSectors+m_Offset;    
  57   1               printf("hehe12");
  58   1              return TRUE;
  59   1      }
  60          WORD SeekEmptyCluster()
  61          {       
  62   1      //      static WORD  Cluster=2;//加快寻找进度
  63   1              WORD  i,Cache[256],j;
  64   1              //      WORD  i,Cache[256],OffSet;
  65   1                      for(i=0;i<SimpleBpb.FATSz;i++)
  66   1              {
  67   2                      if(!Read(FatParameter.FirstFatSecNum+i,1,(BYTE *)Cache))
  68   2                              return FALSE;
  69   2                      for(j=0;j<256;j++)
  70   2                      {
  71   3                                      if(Cache[j]==0)
  72   3                                              return (i*256+j);                       
  73   3                      }
  74   2              }
  75   1              return 0xffff;
  76   1              //************************************************************************
  77   1      /*      for(i=Cluster;i<SimpleBpb.BytsPerSec * SimpleBpb.FATSz / sizeof(WORD);i++)
  78   1              {       
  79   1                      OffSet=i%(SimpleBpb.BytsPerSec/2);
  80   1                      if(OffSet==0)
  81   1                      {
  82   1                              if(!Read((i*2/SimpleBpb.BytsPerSec)+FatParameter.FirstFatSecNum,1,(BYTE *)Cache))
  83   1                                      return 0xffff;          
  84   1                      }
  85   1                       if(Cache[OffSet]==0)
  86   1                       {
  87   1                              Cluster=i;
  88   1                              return  Cluster;
  89   1                       }
  90   1      
  91   1              }//*end for cycle
  92   1              //************************************************************************
  93   1              for(i=2;i<Cluster;i++) 
  94   1              {
  95   1                      OffSet=i%(SimpleBpb.BytsPerSec/2);
  96   1                      if(!Read(i*2/SimpleBpb.BytsPerSec+FatParameter.FirstFatSecNum,1,(BYTE *)Cache))
  97   1                              return 0xffff;
  98   1                      if(Cache[OffSet]==0x0)
  99   1                      {
 100   1                              Cluster=i;
 101   1                              return  Cluster;
 102   1                      }
 103   1              }//*end for cycl
 104   1              return 0xffff;*/
 105   1      }       
 106          WORD LinkClusterList(WORD Cluster)
 107          {
 108   1              static WORD VariedCluster=2;
 109   1              WORD i,FixedSec,j;
 110   1              BYTE p; 
 111   1              //////////////////////////////////////////////////////////////////////////////////
 112   1              if(VariedCluster==2)
 113   1              {        FatCache[0][256]=0;
 114   2              //      FatCache[1][256]=0;
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 3   

 115   2                      VariedCluster=3;
 116   2              }
 117   1              //VariedCluster=Cluste
 118   1              FixedSec=Cluster*2/SimpleBpb.BytsPerSec;
 119   1              if(FatCache[0][256]!=FixedSec+FatParameter.FirstFatSecNum)
 120   1              {       FatCache[0][256]=0;
 121   2                      //      if(FatCache[1][256])
 122   2                      //      if(!Write(FixedSec+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[0],TRUE))
 123   2                      //              return FALSE;
 124   2                      if(!Read(FixedSec+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[0]))
 125   2                              return FALSE;
 126   2              }
 127   1              for(i=FixedSec;i<SimpleBpb.FATSz;i++)
 128   1              {
 129   2                      if(i!=FixedSec)
 130   2                      {
 131   3                              p=1;
 132   3                              FatCache[0][256]=0;
 133   3                              if(!Read(i+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[1]))
 134   3                                      return FALSE;
 135   3                      }
 136   2                      else{
 137   3                              p=0;            
 138   3                              FatCache[0][256]=FixedSec+FatParameter.FirstFatSecNum;
 139   3                              }
 140   2                      for(j=0;j<256;j++)
 141   2                      {
 142   3                              if(FatCache[p][j]==0)
 143   3                              {//     if(i==FixedSec)
 144   4                              //      {       p=0;    
 145   4                              //              FatCache[0][256]=FixedSec+FatParameter.FirstFatSecNum;
 146   4                              //      }
 147   4                              //else{
 148   4                              //      p=1;
 149   4                              //      FatCache[0][256]=0;
 150   4                              //      }
 151   4                                      FatCache[p][j]=0xffff;
 152   4                                      FatCache[0][Cluster%(SimpleBpb.BytsPerSec/2)]=WordSwap((i*256+j));
 153   4                                      if(i!=FixedSec)
 154   4                                      {       if(!Write(FixedSec+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[0],TRUE))
 155   5                                                      return FALSE;
 156   5                                              if(!Write(i+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[p],TRUE))
 157   5                                                      return FALSE;
 158   5                                      }
 159   4                                      return (i*256+j);
 160   4                              }
 161   3                      }
 162   2              }
 163   1              ///////////////////////////////////////////////////////////////////////////
 164   1              FixedSec=Cluster*2/SimpleBpb.BytsPerSec;
 165   1              if(!Read(FixedSec+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[0]))
 166   1                      return FALSE;
 167   1              for(i=0;i<FixedSec;i++)
 168   1              {
 169   2                      if(!Read(i+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[1]))
 170   2                              return FALSE;
 171   2                      for(j=0;j<256;j++)
 172   2                      {
 173   3                              if(FatCache[1][j]==0)
 174   3                              {       
 175   4                                      FatCache[1][j]=0xffff;
 176   4                                      FatCache[0][Cluster%(SimpleBpb.BytsPerSec/2)]=WordSwap((i*256+j));
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 4   

 177   4                                      if(!Write(FixedSec+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[0],TRUE))
 178   4                                              return FALSE;
 179   4                                      if(!Write(i+FatParameter.FirstFatSecNum,1,(BYTE *)FatCache[p],TRUE))
 180   4                                              return FALSE;
 181   4                                      return (i*256+j);
 182   4                              }
 183   3                      }
 184   2              }
 185   1              return 0Xffff;  
 186   1      
 187   1      }
 188          WORD GetListCluster(WORD Cluster)
 189          {
 190   1              WORD Fatbuf[256];
 191   1              //////////////////////////////////////////////////////////////////////////////////
 192   1              if(!Read(2*Cluster/SimpleBpb.BytsPerSec+FatParameter.FirstFatSecNum,1,(BYTE *)Fatbuf))
 193   1                      return FALSE;
 194   1              return WordSwap(Fatbuf[Cluster%(SimpleBpb.BytsPerSec/2)]);
 195   1      }
 196          WORD SecToCluster(DWORD Sector)
 197          {
 198   1              if(Sector < FatParameter.FirstDataSector)

⌨️ 快捷键说明

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