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

📄 text1.lst

📁 使用51单片机作为控制器
💻 LST
字号:
C51 COMPILER V7.06   TEXT1                                                                 05/14/2007 22:03:36 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Text1.c LARGE BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <at89x52.h>
   2          #include <stdio.h>
   3          #include <string.h>
   4          #include "LCD_FUN.H"
   5          #include "DS1302_18B20.H"
   6          #include "FileOperMenu.h"
   7          #define LIB_CFG_DISK_IO                 2               // 磁盘读写的数据的复制方式,1为"单DPTR复制",2为"双DPTR复制",3为"单DPTR和P2+R0
             -复制" 
   8          #define LIB_CFG_FILE_IO                 2               // 文件读写的数据的复制方式,0为"外部子程序",1为"单DPTR复制",2为"双DPTR复制",3
             -为"单DPTR和P2+R0复制" 
   9          #define LIB_CFG_INT_EN                  1               // CH375的INT#引脚连接方式,0为"查询方式",1为"中断方式" 
  10          
  11          #define CH375_CMD_PORT_ADDR             0x8FFF  // CH375命令端口的I/O地址 
  12          #define CH375_DAT_PORT_ADDR             0x8EFF  // CH375数据端口的I/O地址 
  13          
  14          // 62256提供的32KB的RAM分为两部分: 0000H-7DFFH为文件读写缓冲区, 7E00H-7FFFH为磁盘数据缓冲区 
  15          #define DISK_BASE_BUF_ADDR              0x7800  // 外部RAM的磁盘数据缓冲区的起始地址,从该单元开始的缓冲区长度为SECTOR_S
             -IZE 
  16          #define FILE_DATA_BUF_ADDR              0x0000  // 外部RAM的文件数据缓冲区的起始地址,缓冲区长度不小于一次读写的数据长度
             - 
  17          // 由于演示板用的62256只有32K字节,其中CH375子程序用512字节,所以外部RAM剩余长度为32256字节 
  18          #define FILE_DATA_BUF_LEN               0x7800  // 外部RAM的文件数据缓冲区,缓冲区长度不小于一次读写的数据长度 
  19          
  20          #define CH375_INT_NO                    0               // CH375中断号, CH375的中断线INT#引脚连接单片机的INT0引脚 
  21          #define CH375_INT_FLAG                  IE0             // IE0,CH375中断标志 
  22          #define CH375_INT_EN                    EX0             // EX0,CH375中断允许 
  23          #include "CH375HF4.H"
  24          void    mDelay100mS( )
  25          {
  26   1              UINT8   i, j, c;
  27   1              for ( i = 200; i != 0; i -- ) for ( j = 200; j != 0; j -- ) c+=3;
  28   1      }
  29          ///////// 将程序空间的字符串复制到内部RAM中,返回字符串长度 ////////
  30          UINT8   mCopyCodeStringToIRAM( UINT8 *iDestination, UINT8 *iSource )
  31          {
  32   1              UINT8   i = 0;
  33   1              while ( *iDestination = *iSource ) 
  34   1              {
  35   2                      iDestination ++;
  36   2                      iSource ++;
  37   2                      i ++;
  38   2              }
  39   1              return( i );
  40   1      }
  41          
  42          
  43          ///////// 检查操作状态,如果错误则显示错误代码并停机 /////////
  44          void    mStopIfError( UINT8 iError )
  45          {
  46   1              if ( iError == ERR_SUCCESS ) return;  // 操作成功
  47   1              LCD_clr();
  48   1              LCD_set_XY(12,2);
  49   1              printf( "Error:%#02X", (UINT16)iError );  // 显示错误   
  50   1      }
  51          #include "meun.h"
C51 COMPILER V7.06   TEXT1                                                                 05/14/2007 22:03:36 PAGE 2   

  52          /////////////////////////////定时器0,用于定时刷新屏幕///////////////////////////////////
  53          void InitTimer0(void)
  54          {
  55   1          TMOD=TMOD&0xF0;
  56   1          TMOD=TMOD|0x01;    //模式1(16位定时器),仅受TR0控制
  57   1              TL0 =-65530%256;
  58   1              TH0 =-65530/256;
  59   1          ET0=1;       //允许T0中断
  60   1          TR0=0; 
  61   1      }
  62          void Time0(void) interrupt 1 using 3
  63          {
  64   1              flash=1;
  65   1      }
  66          ////////////////////////////////////////////////////////////////////////////////////////
  67          void USB_Attribute(void)
  68          {
  69   1              UINT16 i;
  70   1              LCD_set_RC(0,0);
  71   1              LCD_putc(91,0);LCD_putc(92,0);LCD_putc(20,0);LCD_putc(93,0);
  72   1              LCD_set_RC(1,2);
  73   1              LCD_putc(94,0);LCD_putc(95,0);LCD_putc(96,0);//显示 -正在查询,请稍后...
  74   1              printf("...");
  75   1              i=CH375DiskQuery();
  76   1              mStopIfError( i );
  77   1              LCD_clr();
  78   1              LCD_set_RC(0,0);
  79   1              LCD_putc(97,0);LCD_putc(98,0);LCD_putc(28,0);//显示 -总容量
  80   1              LCD_set_RC(1,0);
  81   1              LCD_putc(99,0);LCD_putc(101,0);LCD_putc(28,0);//显示 -可用量
  82   1              LCD_set_RC(2,0);
  83   1              LCD_putc(88,0);LCD_putc(89,0);LCD_putc(100,0);LCD_putc(102,0);//显示 -文件系统
  84   1              LCD_set_RC(3,5);
  85   1              LCD_putc(103,0);LCD_putc(104,0);//显示 -退出
  86   1              LCD_set_XY(48,3);
  87   1              switch(mCmdParam.Query.mDiskFat)
  88   1              {
  89   2                      case DISK_FAT12:
  90   2                              printf("FAT12");        
  91   2                              break;
  92   2                      case DISK_FAT16:
  93   2                              printf("FAT16");
  94   2                              break;
  95   2                      case DISK_FAT32:
  96   2                              printf("FAT32");
  97   2                              break;
  98   2                      default:
  99   2                              printf("Unknow");
 100   2                              break;
 101   2              }
 102   1          i=((UINT32)mCmdParam.Query.mTotalSector*10)/2048;
 103   1              LCD_set_XY(36,0);
 104   1          printf(":%3d.%dM",i/10,i%10);
 105   1          LCD_set_XY(36,2);
 106   1          i=((UINT32)mCmdParam.Query.mFreeSector*10)/2048;
 107   1          printf(":%3d.%dM",i/10,i%10);
 108   1      }
 109          uchar code USBTab[][7]={
 110          {55,56,57,58,59,60,0}, //优盘未插入
 111          {42,14,15,61,56,57,0},//检测到优盘
 112          {56,57,62,63,64,65,0}, //优盘连接断开
 113          };
C51 COMPILER V7.06   TEXT1                                                                 05/14/2007 22:03:36 PAGE 3   

 114          UINT8 FileMaxNum;
 115          UINT8 FileNameBuf[MAX_PATH_LEN];//路径长度为40
 116          UINT8 FilePathBuf[MAX_PATH_LEN];
 117          UINT8 FilePastBuf[MAX_PATH_LEN];//用于粘贴
 118          //UINT8 FileSavePath[20];
 119          UINT8 FileWhere;
 120          UINT8 FileSel;
 121          UINT8 FileLay;
 122          UINT8 FilePlace[20];
 123          UINT8 FileSaveSel[20];
 124          UINT8 CanPast=0;                   //可以粘贴标志,1为可以粘贴。
 125          //-------------------FilePathBuf处理函数,将*号前面数据取出-----------------------
 126          void    File_CopyPath( UINT8 *iDestination, UINT8 *iSource )
 127          {
 128   1              while (*iSource!='*') 
 129   1              {
 130   2                      *iDestination = *iSource;
 131   2                      iDestination ++;
 132   2                      iSource ++;
 133   2              }
 134   1              *iDestination='\0';
 135   1      }
 136          //---------------文件处理函数----------------------------------------------------
 137          UINT8 *File_NameInPath(UINT8 *p) //找出所在目录的文件名或者文件夹,所在路径保存在FileSavePath[20]中。
 138          {
 139   1              UINT8 i=0,PathPlac=0;
 140   1          UINT8 *ptr;
 141   1          ptr=p;
 142   1              while (FileNameBuf[i]=*ptr)
 143   1              {       //FileSavePath[i]=*ptr;
 144   2              i++;
 145   2                      if(*ptr=='\\') //找出最后的//所在位置。
 146   2                              PathPlac=i;
 147   2                      ptr++;
 148   2              }
 149   1          //FileSavePath[PathPlac]='\0';
 150   1          return (p+PathPlac);        
 151   1      }
 152          //---------------取出文件后缀名扩展名称----------------------
 153          UINT8 *File_NameType(UINT8 *ptr)
 154          {       
 155   1              UINT8 i;
 156   1              for(i=strlen(ptr);i>0;i--)
 157   1              {
 158   2                      if(*(ptr+i-1)=='.')
 159   2                              return ptr+i;
 160   2              }
 161   1              return 0;
 162   1      }
 163          //---------------FilePathBuf向上一级--------------------------
 164          void File_UpPath(void)
 165          {
 166   1              UINT8 i=0,PathPlac=0;
 167   1              while (FilePathBuf[i])
 168   1             i++;
 169   1          FilePathBuf[i-2]='\0';
 170   1              i=0;
 171   1              while (FilePathBuf[i])
 172   1              {
 173   2                      if(FilePathBuf[i]=='\\')
 174   2                              PathPlac=i;
 175   2              i++;
C51 COMPILER V7.06   TEXT1                                                                 05/14/2007 22:03:36 PAGE 4   

 176   2              }
 177   1          FilePathBuf[PathPlac+1]='*';        
 178   1              FilePathBuf[PathPlac+2]='\0';   
 179   1      }
 180          UINT8* File_SelName(UINT8 *Path,UINT8 SelNum)//SelNum必须少于FileMaxNum,从零开始。
 181          {
 182   1              UINT8 i;
 183   1              i = mCopyCodeStringToIRAM( mCmdParam.Enumer.mPathName, Path);
 184   1          mCmdParam.Enumer.mPathName[ i ] =SelNum;
 185   1          i=CH375FileEnumer();
 186   1              mStopIfError( i );
 187   1          return File_NameInPath(mCmdParam.Enumer.mPathName);
 188   1      }
 189          ////////////////////////删除文件 /////////////////////////////////////////////
 190          void File_Del(UINT8 *p)
 191          {
 192   1              UINT8 i;
 193   1              mCopyCodeStringToIRAM( mCmdParam.Open.mPathName,p); 
 194   1              i = CH375FileErase();
 195   1              mStopIfError(i);
 196   1      }
 197          //////////////////枚举文件///////////////////////
 198          UINT8 File_Enumer(UINT8 *path,bit type)//0为刷新文件数目;1为枚举文件;返回为文件数目-1(含0开始)
 199          //void File_Enumer(void)
 200          {
 201   1              UINT8 i;
 202   1              UINT16 j;
 203   1              if(type)
 204   1                      printf("Enumer files:");
 205   1              for ( j = 0; j < 255; j ++ )  //最多搜索前255个文件
 206   1              { 
 207   2                      i = mCopyCodeStringToIRAM( mCmdParam.Open.mPathName, path);  //搜索文件名,*为通配符,适用于所有文件或者子
             -目录 
 208   2                      mCmdParam.Open.mPathName[ i ] = j;  // 根据字符串长度将结束符替换为搜索的序号,从0到255
 209   2                      i = CH375FileOpen();                            // 打开文件,如果文件名中含有通配符*,则为搜索文件而不打开 
 210   2                      if ( i == ERR_MISS_FILE ) {return(j-1);break;}  // 再也搜索不到匹配的文件,已经没有匹配的文件名 
 211   2                      if ( i == ERR_FOUND_NAME )                      // 搜索到与通配符相匹配的文件名,文件名及其完整路径在命令缓冲区中 
 212   2                      {   
 213   3                         if(type)
 214   3                                      printf( "%03d:%s", (unsigned int)j, mCmdParam.Open.mPathName );// 显示序号和搜索到的匹配文件名或者子目
             -录名 
 215   3                              continue;  //继续搜索下一个匹配的文件名,下次搜索时序号会加1 
 216   3                      }
 217   2                      else // 出错 
 218   2                      {                       
 219   3                              mStopIfError( i );
 220   3                              break;
 221   3                      }
 222   2              }       
 223   1      }
 224          /* 新建目录并打开,如果目录已经存在则直接打开 */
 225          /* 输入参数:   目录名在mCmdParam.Create.mPathName中,与文件名规则相同 */
 226          /* 返回状态码: ERR_SUCCESS = 打开目录成功或者创建目录成功,
 227                         ERR_FOUND_NAME = 已经存在同名文件,
 228                         ERR_MISS_DIR = 路径名无效或者上级目录不存在,
 229                         其它状态码参考CH375HF?.H */
 230          UINT8   CreateDirectory( void )
 231          {
 232   1              UINT8   i, j;
 233   1              UINT32  UpDirCluster;
 234   1              PUINT8X DirXramBuf;
 235   1              UINT8 code *DirConstData;
C51 COMPILER V7.06   TEXT1                                                                 05/14/2007 22:03:36 PAGE 5   

 236   1              j = 0xFF;
 237   1              for ( i = 0; i != sizeof( mCmdParam.Create.mPathName ); i ++ ) {  /* 检查目录路径 */
 238   2                      if ( mCmdParam.Create.mPathName[ i ] == 0 ) break;
 239   2                      if ( mCmdParam.Create.mPathName[ i ] == PATH_SEPAR_CHAR1 || mCmdParam.Create.mPathName[ i ] == PATH_SEPA
             -R_CHAR2 ) j = i;  /* 记录上级目录 */
 240   2              }
 241   1              i = ERR_SUCCESS;
 242   1              if ( j == 0 || j == 2 && mCmdParam.Create.mPathName[1] == ':' ) UpDirCluster = 0;  /* 在根目录下创建子目

⌨️ 快捷键说明

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