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

📄 file_sys.lst

📁 基于at89c51单片机的mp3 mp3播放实验资料及代码
💻 LST
字号:
C51 COMPILER V7.50   FILE_SYS                                                              01/15/2006 18:48:59 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE FILE_SYS
OBJECT MODULE PLACED IN FILE_SYS.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE FILE_SYS.C LARGE ROM(COMPACT) BROWSE

line level    source

   1          #include <string.h>
   2          #include "AT89C51SND1_REG.H"
   3          #include "FILE_SYS.H"
   4          #include "MCU_UART.H"
   5          
   6          unsigned char PageBuf[512];
   7          unsigned char FAT_TYPE; 
   8          
   9          unsigned char  SecPerClus;
  10          unsigned int   RsdSecCnt,BytesPerSec,RootEntCnt,FatSize16;
  11          unsigned long  TotalSector,FatStartSec,RootStartSec,FirstDataSec;
  12          
  13          unsigned long  CurrentClus,CurrentSec,DataRemain = 0;
  14          
  15          #define BootSector  0
  16          
  17          void Init_FAT_Info(void)
  18          {
  19   1              ReadPage(BootSector,PageBuf);
  20   1              RsdSecCnt = PageBuf[14] + PageBuf[15] * 256;
  21   1              printuf16x("Reserved Sector Count : 0x%x\n",RsdSecCnt);
  22   1              SecPerClus = PageBuf[13];
  23   1              printuf16x("Sector per Clus : 0x%x\n",SecPerClus);
  24   1              BytesPerSec = PageBuf[12] * 256 + PageBuf[11];
  25   1              printuf16x("Bytes per Sector: 0x%x\n",BytesPerSec);
  26   1              RootEntCnt = PageBuf[18] * 256 + PageBuf[17];
  27   1              printuf16x("Root Entry Count : 0x%x\n",RootEntCnt);
  28   1              TotalSector = PageBuf[20] * 256 + PageBuf[19];
  29   1              printuf16x("Total Sector Count : 0x%x\n",TotalSector);
  30   1      
  31   1              FatSize16 = PageBuf[23] * 256 + PageBuf[22];
  32   1              if(FatSize16==0) 
  33   1                { FAT_TYPE = FAT32; return; } 
  34   1      
  35   1              FatStartSec  = BootSector + RsdSecCnt;
  36   1              RootStartSec = FatStartSec + 2 * FatSize16;
  37   1              FirstDataSec = RootStartSec + (RootEntCnt * 32 + (BytesPerSec - 1)) / BytesPerSec;
  38   1              printuf16x("Fat Start Sector : 0x%x\n",FatStartSec);
  39   1              printuf16x("Root Start Sector : 0x%x\n",RootStartSec);
  40   1              printuf16x("First Data Sector : 0x%x\n",FirstDataSec);
  41   1      
  42   1              FAT_TYPE = FAT16;
  43   1      }
  44          
  45          unsigned char  OpenFile(unsigned char *FileName)
  46          {
  47   1              unsigned char data i, k;
  48   1              unsigned long data page;
  49   1              page = RootStartSec;
  50   1              while (1)
  51   1                      {
  52   2                              ReadPage(page, PageBuf);
  53   2                      for (k=0; k<16; k++)
  54   2                                {     
  55   3                                      if (PageBuf[k * 32] == 0x00) return 0;
C51 COMPILER V7.50   FILE_SYS                                                              01/15/2006 18:48:59 PAGE 2   

  56   3                                      if (PageBuf[k * 32] == 0xE5) continue;
  57   3                                      if (!memcmp(FileName, &PageBuf[k * 32], 11))      //file find
  58   3                                          {   
  59   4                                               CurrentClus = PageBuf[32 * k + 27] * 256 + PageBuf[32 * k + 26];
  60   4                                               CurrentSec  = (CurrentClus - 2) * SecPerClus + FirstDataSec;
  61   4                                               for (i=31; i>=28; i--) 
  62   4                                                      DataRemain = (DataRemain << 8) | PageBuf[k * 32 + i];
  63   4                                               
  64   4                                               printu("File Name :");
  65   4                                               for(i=0;i<11;i++)
  66   4                                                 printuf("%c",PageBuf[k * 32+i]);
  67   4                                               printu("\n");
  68   4                                               
  69   4                                               printuf16x("File Size : 0x%x",DataRemain/0x10000);
  70   4                                               printuf16x("%x\n",DataRemain%0x10000);
  71   4                                               printuf16x("First Clus : 0x%x\n",CurrentClus);
  72   4                                               printuf16x("First Sector : 0x%x\n",CurrentSec);
  73   4      
  74   4                                               return 1;
  75   4                                               }
  76   3                                 }
  77   2              
  78   2                              page++;
  79   2                      }
  80   1      
  81   1      }
  82          
  83          unsigned int ReadFile()
  84          {
  85   1              ReadPage(CurrentSec++, PageBuf);
  86   1              if (DataRemain < 512) 
  87   1                      return (DataRemain);
  88   1              else
  89   1              {       DataRemain -= 512;
  90   2                      return (512);
  91   2              }
  92   1      }
  93          
  94          void Flash_Reset()
  95          { 
  96   1              K9F_FUN = COMMAND;                     
  97   1              K9F5608 = 0xff;       
  98   1              K9F_FUN = INACTIVE;
  99   1      }
 100          
 101          void ReadPage(unsigned int BlockPage,unsigned char *PageBuf)
 102          {
 103   1          unsigned int data i;
 104   1      
 105   1              K9F_FUN = COMMAND;
 106   1              K9F5608 = 0x00;
 107   1              K9F_FUN = ADDRESS;
 108   1          K9F5608 = 0;                                //A0-A7
 109   1          K9F5608 = BlockPage;            //A9-A16
 110   1              K9F5608 = BlockPage >> 8;   //A17-A24 
 111   1              K9F_FUN = D_DATA;
 112   1      
 113   1              i = 512;
 114   1          while(!(K9F_FUN & RB));
 115   1      
 116   1              while(i--) 
 117   1                      *PageBuf++ = K9F5608;
C51 COMPILER V7.50   FILE_SYS                                                              01/15/2006 18:48:59 PAGE 3   

 118   1              K9F_FUN = INACTIVE;
 119   1       }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1170    ----
   CONSTANT SIZE    =    285    ----
   XDATA SIZE       =    550       6
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       8
   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 + -