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

📄 main.lst

📁 SdCard_V2.1TinyFatFs.rar是单片机实现SD卡功能的FAT文件系统
💻 LST
字号:
C51 COMPILER V7.02b   MAIN                                                                 03/24/2008 15:52:29 PAGE 1   


C51 COMPILER V7.02b, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Output\Main.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Main.c LARGE OPTIMIZE(9,SIZE) BROWSE ORDER DEBUG OBJECTEXTEND PRINT(.\Outpu
                    -t\Main.lst) OBJECT(.\Output\Main.obj)

stmt level    source

   1          /*
   2          **********************************************************************************************
   3          * Project:      FS7805 SD CARD READER
   4          * File:         main.c
   5          * Contents: 
   6          *           The main function is SD and MMC card reader.
   7          *
   8          * $Date: 12/15/06    Derek    V1.0  
   9          *  
  10          *                  This is the SD/MMC card reader firmware.
  11          *                  When read sector,the 512 pingpong FIFO mechanism
  12          *                  is used to improve performance.But when write sector,
  13          *                  only single FIFO is used.
  14          *
  15          * $Date: 12/27/06    Derek    V1.1
  16          *
  17          *                  The 512 pingpong FIFO mechanism is also used when 
  18          *                  writting sectors.
  19          *
  20          * $Date: 01/09/07    Derek    V1.11
  21          *
  22          *                  Fix read sector error bug . 
  23          *                  Don't set FIFO_FULL bit in SetBulkInFull() function.
  24          *                  Setting it in BulkSetDmaIn() function.
  25          *
  26          * $Date: 01/18/07    Derek    V1.11
  27          *
  28          *                  Ignor the OUT_OF_RANGE error in SdSendCmd() when
  29          *                  multi read the last block.
  30          *
  31          * $Date: 03/29/07    Derek    V1.2
  32          *
  33          *                  Add TDES module for data encrypt and decrypt.
  34          *          if Macro TDES>0(define in storage.h) this firmware will encrypt/decrypt data when write/read SD
             - Card
  35          *
  36          * $Date: 07/03/07    Derek    V1.21
  37          *
  38          *                  Support HC SD 2.0 card.
  39          *          Add CMD8,CMD6,different read/write command parameter:
  40          *                  for standard capacity card,unit in data address.
  41          *                  for high capacity card,unit in block.
  42          *                  SdHcFlag is used to identify HC SD and other card.
  43          *
  44          * $Date: 07/27/07    Derek    V1.21
  45          *                       Fix ILLEGALE_COMMAND bug for some MMC card(PQI MMC,e.g),
  46          *                       see sd.c->SdSendCmd() function.
  47          *
  48          * $Date: 08/16/07    Derek    V1.22
  49          *                       Add support for SCSI_READ_BUF command.
  50          *                       Fix HC SD recognization bug.
  51          *                       Card support CMD8(SEND_IF_COND) may be standard V2.00 card or HC SD card.
  52          *                       Now we confirm the HC SD from CSD register value.And we get the SD_SPEC
  53          *                       version from SCR register(V1.00,V1.10 or V2.00).For V1.10 for higher,
C51 COMPILER V7.02b   MAIN                                                                 03/24/2008 15:52:29 PAGE 2   

  54          *                       send CMD6 command to switch to high speed mode.
  55          *
  56          * $Date: 02/28/08    Lshi    V2.0
  57          *          delete USB related function
  58          *                  add tiny fatfs,read_only function
  59          *
  60          *          only support FAT12&FAT16,support max 2 layer directory
  61          *                  could search file by filename through all the directory 
  62          *
  63          *
  64          *
  65          *
  66          *
  67          * Copyright (c) 2007 Fameg, Inc. All rights reserved
  68          *
  69          * 
  70          ***********************************************************************************************
  71          */
  72          #define ALLOCATE_EXTERN                                // Declare GLOBAL variables and functions
  73          
  74          #include "include\Include.h"
  75          #include "tff.h"
  76          #include "diskio.h"
  77          
  78          static  bit SdGetFlashInfoFlag = FALSE;
  79          xdata UINT16 DelayTimer = 0;
  80          bit BusResetFlag = false;
  81          bit BusResetFlagCnt = false;
  82          
  83          extern INT8U Configuration;
  84          
  85          void Timer0() interrupt 1
  86          {
  87   1        // Restore the counter to 10 ms
  88   1        //TH0 = 0x9E; //0x9E58,CPU 30M定时10ms
  89   1        //TL0 = 0x58;
  90   1        TH0         = 0x3C;                                // 0x3CB0, CPU 60MHz, 10ms
  91   1        TL0         = 0xB0;
  92   1      
  93   1        if (DelayTimer)
  94   1          DelayTimer --;
  95   1      
  96   1        if (CmdTimer)
  97   1          CmdTimer --;
  98   1      
  99   1        if (SdGetFlashInfoTimer)
 100   1        {
 101   2          SdGetFlashInfoTimer --;
 102   2          if (SdGetFlashInfoTimer == 0)
 103   2            SdGetFlashInfoFlag = true;
 104   2        }
 105   1      }
 106          
 107          
 108          
 109          FATFS fatfsentity;
 110          BYTE Buff[512];                 /* Working buffer */
 111          char filename[20];
 112          
 113          
 114          //search a file through its name
 115          static
C51 COMPILER V7.02b   MAIN                                                                 03/24/2008 15:52:29 PAGE 3   

 116          FRESULT scan_files (char* path,char* searchname)
 117          {
 118   1              DIR dirs;
 119   1              FRESULT res;
 120   1              int i;
 121   1               FILINFO finfo;
 122   1      
 123   1              if ((res = f_opendir(&dirs, path)) == FR_OK) {
 124   2                      i = strlen(path);
 125   2                      while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {
 126   3                              if (finfo.fattrib & AM_DIR) {
 127   4                              //      acc_dirs++;
 128   4                                      *(path+i) = '/'; 
 129   4                                      strcpy(path+i+1, &finfo.fname[0]);
 130   4                                      res = scan_files(path);
*** WARNING C209 IN LINE 130 OF MAIN.C: '_scan_files': too few actual parameters
*** WARNING C265 IN LINE 130 OF MAIN.C: '_scan_files': recursive call to non-reentrant function
 131   4                                      //*(path+i) = '\0';
 132   4                                      if (res != FR_OK) break;
 133   4                                      else return res;
 134   4                                      
 135   4                              } else {
 136   4                              
 137   4                                /* if(!strcmp(&finfo.fname[0],"3.txt"))
 138   4                                 {    
 139   4                                              *(path+i) = '/'; 
 140   4                                              strcpy(path+i+1, &finfo.fname[0]);
 141   4                                 
 142   4                                 }    */
 143   4      
 144   4                                              
 145   4                                      if(!strcmp(&finfo.fname[0],searchname))
 146   4                                 {    
 147   5                                              *(path+i) = '/'; 
 148   5                                              strcpy(path+i+1, &finfo.fname[0]);
 149   5                              
 150   5                                          strcpy(filename, path);
 151   5                                      
 152   5                                              res = FR_OK;
 153   5                                              return res;
 154   5                                      
 155   5                                         }
 156   4      
 157   4                              }
 158   3                      }
 159   2              }
 160   1      
 161   1              return res;
 162   1      } 
 163          
 164          
 165          void  main (void)
 166          {
 167   1              BYTE res;
 168   1              FIL file1,file2,file3,file4,file5;              /* File object */
 169   1      //      WORD br;         // File R/W count
 170   1      
 171   1      
 172   1              WORD br1,br2;         // File R/W count
 173   1      //      DWORD p1;
 174   1        //  DIR dirs;
 175   1              McuInit();
C51 COMPILER V7.02b   MAIN                                                                 03/24/2008 15:52:29 PAGE 4   

 176   1              Timer0Init(); 
 177   1          TdInit();
 178   1              StorageInit();
 179   1       
 180   1              if(!f_mountdrv())
 181   1      {
 182   2      
 183   2      
 184   2      
 185   2              res = f_mkdir("22");
 186   2      
 187   2      
 188   2              strcpy(filename, "");
 189   2         if(!scan_files (filename,"1.txt"))
 190   2         {
 191   3         
 192   3         
 193   3                              res = f_open(&file1, filename, FA_OPEN_EXISTING | FA_READ);
 194   3       /*
 195   3      for (;;) {
 196   3              res = f_read(&file1, Buff, 0x200, &br);
 197   3              if (res || br == 0) break;      // error or eof      
 198   3               }                                                                                 */ 
 199   3         }
 200   2      
 201   2      
 202   2      
 203   2              strcpy(filename, "/22/5.txt");
 204   2              res = f_open(&file5, filename, FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
 205   2      
 206   2      
 207   2      
 208   2         if(!scan_files (filename,"2.txt"))
 209   2         {
 210   3         
 211   3         
 212   3                              res = f_open(&file2, filename, FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
 213   3        
 214   3         }
 215   2      
 216   2      
 217   2      
 218   2      for (;;) {
 219   3                                              res = f_read(&file1, Buff, sizeof(Buff), &br1);
 220   3                                              if (res || br1 == 0) break;   /* error or eof */
 221   3                                              res = f_write(&file5, Buff, br1, &br2);
 222   3                                      //      p1 += br2;
 223   3                                              if (res || br2 < br1) break;   /* error or disk full */
 224   3                                      }
 225   2      
 226   2              /*
 227   2         
 228   2               strcpy(filename, "");
 229   2         if(!scan_files (filename,"5.txt"))
 230   2         {
 231   2         
 232   2         
 233   2                              res = f_open(&file1, filename, FA_OPEN_EXISTING | FA_READ);
 234   2      
 235   2      for (;;) {
 236   2              res = f_read(&file1, Buff, 0x200, &br);
 237   2              if (res || br == 0) break;      // error or eof
C51 COMPILER V7.02b   MAIN                                                                 03/24/2008 15:52:29 PAGE 5   

 238   2             
 239   2          } 
 240   2      
 241   2        }
 242   2               strcpy(filename, "");
 243   2         if(!scan_files (filename,"6.txt"))
 244   2         {
 245   2         
 246   2         
 247   2                              res = f_open(&file1, filename, FA_OPEN_EXISTING | FA_READ);
 248   2      
 249   2      for (;;) {
 250   2              res = f_read(&file1, Buff, 0x200, &br);
 251   2              if (res || br == 0) break;      // error or eof
 252   2             
 253   2          } 
 254   2        }
 255   2              
 256   2              res = f_open(&file1, "/1/4.txt", FA_OPEN_EXISTING | FA_READ);
 257   2      
 258   2      for (;;) {
 259   2              res = f_read(&file1, Buff, 0x200, &br);
 260   2              if (res || br == 0) break;      // error or eof
 261   2             
 262   2          }  */
 263   2              /*
 264   2              res = f_open(&file1, "/1/3.txt", FA_OPEN_EXISTING | FA_READ);
 265   2      
 266   2      for (;;) {
 267   2              res = f_read(&file1, Buff, 0x200, &br);
 268   2              if (res || br == 0) break;      // error or eof
 269   2             
 270   2          } */
 271   2      
 272   2      // Close all files       
 273   2          f_close(&file1);
 274   2              f_close(&file2);
 275   2              f_close(&file3);
 276   2              f_close(&file4);
 277   2              f_close(&file5);
 278   2          // Deactivate FatFs module
 279   2          //FatFs = null;
 280   2      }       
 281   1      }
 282            
 283          
 284          /*$PAGE*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    622    ----
   CONSTANT SIZE    =     26    ----
   XDATA SIZE       =   1076     171
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      3    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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