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

📄 device.lst

📁 c51读写SD卡原代码,c51编写,串口接收
💻 LST
字号:
C51 COMPILER V7.00  DEVICE                                                                 10/27/2006 00:20:29 PAGE 1   


C51 COMPILER V7.00, COMPILATION OF MODULE DEVICE
OBJECT MODULE PLACED IN DEVICE.OBJ
COMPILER INVOKED BY: e:\Keil\C51\BIN\C51.EXE DEVICE.C BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include "common.h"
   2          #include "DEVICE.H"
   3          #include "HAL.H"
   4          #include "HPI.H"
   5          #include "HPI32.H"
   6          
   7          //////////////////////////////////
   8          extern SYS_INFO_BLOCK xdata DeviceInfo;
   9          extern FILE_INFO xdata ThisFile;
  10          extern unsigned int xdata DirStartCluster;
  11          extern unsigned long xdata DirStartCluster32;
  12          
  13          unsigned char xdata DBUF[BUFFER_LENGTH];
  14                  
  15          ///////////////////////////////////////////////////////////////////////////
  16          unsigned char InitFileSystem(void)
  17          {
  18   1              unsigned int ReservedSectorsNum;
  19   1      
  20   1              ////////////////////////////////////////////////////
  21   1              DeviceInfo.BPB_BytesPerSec=512; //暂假设为512
  22   1              
  23   1      
  24   1              ////////////////////////////////////////////////////
  25   1              if(!SdReadSector(0x0,1,DBUF))
  26   1                      return FALSE;
  27   1          if(DBUF[510] != 0x55 || DBUF[511] != 0xaa) return FALSE;
  28   1      
  29   1              //////////////////////////////////
  30   1              if(DBUF[0]==0xeb||DBUF[0]==0xe9)
  31   1                      {
  32   2                      DeviceInfo.StartSector=0;
  33   2                      }
  34   1              else
  35   1                      {
  36   2                       if(DBUF[446] != 0x80 && DBUF[446] != 0)  return FALSE;
  37   2                       DeviceInfo.StartSector=LSwapINT32(DBUF[454],DBUF[455],DBUF[456],DBUF[457]);
  38   2                      }
  39   1              ///////////////////////////////////////////////////////
  40   1              if(!SdReadSector(DeviceInfo.StartSector,1,DBUF))
  41   1                      return FALSE;
  42   1              
  43   1              if(DBUF[510] != 0x55 || DBUF[511] != 0xaa) return FALSE;
  44   1      
  45   1              DeviceInfo.BPB_BytesPerSec=LSwapINT16(DBUF[11],DBUF[12]);
  46   1              DeviceInfo.BPB_SecPerClus=DBUF[13];
  47   1              ReservedSectorsNum=LSwapINT16(DBUF[14],DBUF[15]);
  48   1              DeviceInfo.BPB_NumFATs=DBUF[16];
  49   1      
  50   1              if(DBUF[82]=='F'&&DBUF[83]=='A'&&DBUF[84]=='T'&&DBUF[85]=='3'&&DBUF[86]=='2')
  51   1                      {
  52   2                      DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
  53   2                      DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;
  54   2                      DeviceInfo.BPB_TotSec32=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
  55   2                      DeviceInfo.BPB_FATSz32=LSwapINT32(DBUF[36],DBUF[37],DBUF[38],DBUF[39]);
C51 COMPILER V7.00  DEVICE                                                                 10/27/2006 00:20:29 PAGE 2   

  56   2                      DeviceInfo.RootStartCluster=LSwapINT32(DBUF[44],DBUF[45],DBUF[46],DBUF[47]);
  57   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
  58   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz32;
  59   2                      //DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-DeviceInfo.FirstDataSector+1)/DeviceInfo.BPB_SecPerClus
             -+1;
  60   2                      DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-ReservedSectorsNum-DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_
             -FATSz32-DeviceInfo.BPB_RootEntCnt)/DeviceInfo.BPB_SecPerClus;
  61   2                      DirStartCluster32=DeviceInfo.RootStartCluster;
  62   2                      DeviceInfo.FAT=1;       //FAT16=0,FAT32=1;
  63   2                      }
  64   1              else
  65   1                      {               
  66   2                      DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
  67   2                      DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;    
  68   2                      DeviceInfo.BPB_TotSec16=LSwapINT16(DBUF[19],DBUF[20]);  
  69   2                      if(DeviceInfo.BPB_TotSec16==0)
  70   2                        DeviceInfo.BPB_TotSec16=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
  71   2                      DeviceInfo.BPB_FATSz16=LSwapINT16(DBUF[22],DBUF[23]);                   
  72   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
  73   2                      DeviceInfo.RootStartSector=DeviceInfo.StartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Reserved
             -SectorsNum;        
  74   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Devic
             -eInfo.BPB_RootEntCnt;
  75   2                      DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec16-DeviceInfo.BPB_RootEntCnt-DeviceInfo.BPB_NumFATs*DeviceIn
             -fo.BPB_FATSz16-1)/DeviceInfo.BPB_SecPerClus;
  76   2              if(DeviceInfo.TotCluster<4085) return FALSE;    //FAT12 不被支持
  77   2                      DeviceInfo.FAT=0;
  78   2                      }               
  79   1              ///////////////////////////////////////////////////////
  80   1              ThisFile.bFileOpen=0;   
  81   1              ///////////////////////////////////////////////////////
  82   1              return TRUE;
  83   1      }
  84          
  85          unsigned char SdReadSector(unsigned long sector,unsigned char len,unsigned char *pBuffer)
  86          {
  87   1              while(len--)
  88   1               {
  89   2                if(SdReadBlock(pBuffer,sector<<9)==0) 
  90   2                   return 0;
  91   2            pBuffer+=512;
  92   2               }
  93   1        return 1;
  94   1      }
  95          
  96          unsigned char SdWriteSector(unsigned long sector,unsigned char len,unsigned char *pBuffer)
  97          {
  98   1              while(len--)
  99   1               {
 100   2                if(SdWriteBlock(pBuffer,sector<<9)==0) return 0;
 101   2            pBuffer+=512;
 102   2               }
 103   1       return 1;  
 104   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1479    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   8192    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      18
C51 COMPILER V7.00  DEVICE                                                                 10/27/2006 00:20:29 PAGE 3   

   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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