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

📄 hpi.lst

📁 采用811芯片实现单片机读写U盘的源代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
 727   3                              file_point.offset_sec_clue-=deviceinfo.SecPerClus;
 728   3                              file_point.current_clue=GetNextClusterNum(file_point.current_clue);
 729   3                              if(!file_point.current_clue) return DEVICEC_OP_ERR;
 730   3                              if((file_point.current_clue>0x0fffffef)&&writeLength){
 731   4                                      if(!CreateClusterLink(file_point.current_clue)) return DEVICEC_OP_ERR;
 732   4                              }       
 733   3                      }
 734   2              }//end while
 735   1      //      file_point.offset_point+=write_len;
C51 COMPILER V7.00  HPI                                                                    09/22/2005 17:15:31 PAGE 13  

 736   1              
 737   1              //更新文件目录信息
 738   1              if(file_point.offset_point>file_point.file_size){
 739   2                      cur_file_item.dir_file_size=file_point.offset_point;
 740   2                      file_point.file_size=file_point.offset_point;
 741   2                      compress_date(file_point.date,&cur_file_item.dir_wrtdate,&cur_file_item.dir_wrttime);
 742   2                      error=find_file(file_point.name, (uchar *)&cur_file_item,1);
 743   2                      if(error) return error;
 744   2              }               
 745   1              
 746   1              file_point.file_open_flag=1;
 747   1              
 748   1              #ifdef ZLH_DEBUG
 749   1              disp_data(2,"B2");
 750   1              disp_data(47,&file_point);
 751   1              #endif
 752   1              
 753   1              return 0;
 754   1      }
 755          
 756          unsigned char RemoveFile(unsigned char *pBuffer)
 757          {
 758   1      
 759   1      
 760   1              uchar error,exist_flag=0,end_flag=0;
 761   1              ulong temp,start_clue,start_sec;
 762   1              uint clue_len,k;
 763   1              FILE_DIR_ITEM  file_temp;
 764   1      
 765   1              
 766   1              if(!bXXGFlags.bits.SLAVE_IS_ATTACHED)
 767   1              {
 768   2              return NOT_DEVICE;              
 769   2              }
 770   1      
 771   1              error=find_file(pBuffer, (uchar *)&file_temp, 0);
 772   1              if(error) return error;
 773   1      
 774   1              file_temp.dir_name[0]=0xe5;
 775   1      
 776   1              temp=((ulong)file_temp.dir_fstclushi)<<16+file_temp.dir_fstcluslo;
 777   1              temp=SwapINT32(temp);
 778   1      
 779   1              if(file_temp.dir_attr==0x10){
 780   2              //删除目录需要判断目录内文件是否都已删除
 781   2                      start_clue=temp;
 782   2                      clue_len=deviceinfo.BytePerSec<<(BitNum(deviceinfo.SecPerClus));
 783   2                      while(1){
 784   3                              start_sec=FirstSectorofCluster(start_clue);
 785   3                              //还未考虑溢出DBUF的情况
 786   3                              if(!RBC_Read(start_sec, deviceinfo.SecPerClus, DBUF)) return DEVICEC_OP_ERR;    
 787   3                              for(k=0;k<clue_len;k+=32){
 788   4                                      if(!DBUF[k]){
 789   5                                              end_flag=1;
 790   5                                              break;
 791   5                                      }       
 792   4                                      if(DBUF[k]!=0xe5){
 793   5                                              exist_flag=1;
 794   5                                              break;
 795   5                                      }
 796   4                              }       
 797   3                              if(end_flag) break;
C51 COMPILER V7.00  HPI                                                                    09/22/2005 17:15:31 PAGE 14  

 798   3                              start_clue=GetNextClusterNum(start_clue);
 799   3                              if(start_clue>0x0fffffef){
 800   4                                      end_flag=1;
 801   4                                      break;
 802   4                              }
 803   3                      }
 804   2                      if(exist_flag) return DIR_NOT_EMPTY;
 805   2              }
 806   1      
 807   1              //删除FAT链
 808   1              if(!DeleteClusterLink(temp)) return DEVICEC_OP_ERR;
 809   1              
 810   1              //删除目录项
 811   1              error=find_file(pBuffer, (uchar *)&file_temp, 1);
 812   1              if(error) return error;
 813   1              
 814   1              return 0;
 815   1      }
 816          
 817          //unsigned char GetCapacity(uchar *para)
 818          //{
 819          //      unsigned int sectorNum,freesectorcnt,i;
 820          //      
 821          ////#define RspBlockGetCapacity UartRspBlock.RspBlock.Rsp_GetCapacity
 822          //
 823          //      PREAD_CAPACITY_RSP pBuf;
 824          //      
 825          //      if(!bXXGFlags.bits.SLAVE_IS_ATTACHED)
 826          //      {
 827          //              return NOT_DEVICE;              
 828          //      }
 829          //      ///////////////////////////////////////////////////////////
 830          //      if(!RBC_ReadCapacity())
 831          //      {
 832          //              return DEVICEC_OP_ERR;  
 833          //      }
 834          //      
 835          //      pBuf=(PREAD_CAPACITY_RSP)DBUF;
 836          //      RspBlockGetCapacity.disksize=SwapINT32((pBuf->LastLBA+1)*pBuf->BlockSize);
 837          //      ////////////////////////////////////////////////////////////////////////
 838          //      sectorNum=DeviceInfo.FatStartSector;
 839          //      freesectorcnt=0;
 840          //      while(sectorNum<DeviceInfo.BPB_FATSz16+DeviceInfo.FatStartSector)
 841          //      {
 842          //              
 843          //              if(RBC_Read(sectorNum,1,DBUF))
 844          //              {
 845          //                for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+2)
 846          //                      {
 847          //                       //clusterNum++;        
 848          //                       
 849          //                       if((DBUF[i]==0xff)&&(DBUF[i+1]==0xff))
 850          //                              {       
 851          //                              freesectorcnt++;
 852          //                              }
 853          //                      // clusterNum++;
 854          //                      }       
 855          //              }
 856          //              else
 857          //                      {
 858          //                      return DEVICEC_OP_ERR;  
 859          //                      }
C51 COMPILER V7.00  HPI                                                                    09/22/2005 17:15:31 PAGE 15  

 860          //              sectorNum++;
 861          //      }
 862          //      
 863          //      ////////////////////////////////////////////////////////////////////////
 864          //      RspBlockGetCapacity.freedisksize=DeviceInfo.BPB_BytesPerSec*DeviceInfo.BPB_SecPerClus;
 865          //      RspBlockGetCapacity.freedisksize=freesectorcnt*RspBlockGetCapacity.freedisksize;
 866          //      RspBlockGetCapacity.freedisksize=SwapINT32(RspBlockGetCapacity.disksize)-RspBlockGetCapacity.freedisksi
             -ze;
 867          //      RspBlockGetCapacity.freedisksize=SwapINT32(RspBlockGetCapacity.freedisksize);
 868          //              
 869          //      return 0;
 870          ////#undef RspBlockGetCapacity
 871          //}
 872          //
 873          //unsigned char GetFreeCapacity(void)
 874          //{
 875          //#define RspBlockGetCapacity UartRspBlock.RspBlock.Rsp_GetFreeCapacity
 876          //      if(!bXXGFlags.bits.SLAVE_IS_ATTACHED)
 877          //      {
 878          //      UartRspBlock.errcode=ERC_NODEVICE;
 879          //      return FALSE;           
 880          //      }
 881          //      //////////////////////////////////////////////
 882          //      
 883          //      
 884          //      return TRUE;
 885          //#undef RspBlockGetFreeCapacity
 886          //}
 887          
 888          unsigned char SetFilePointer(unsigned long pointer)
 889          {
 890   1              
 891   1              if(!bXXGFlags.bits.SLAVE_IS_ATTACHED)
 892   1              {
 893   2                      return NOT_DEVICE;              
 894   2              }
 895   1              if(!file_point.file_open_flag)
 896   1              {
 897   2                      return FILE_NOT_OPEN;           
 898   2              }
 899   1              
 900   1              #ifdef ZLH_DEBUG
 901   1              disp_data(2,"B4");
 902   1              disp_data(4,&pointer);
 903   1              disp_data(4,&file_point.file_size);
 904   1              #endif
 905   1              
 906   1              
 907   1              if(!GoToPointer(pointer))
 908   1              {
 909   2                      file_point.file_open_flag=0;
 910   2                      return DEVICEC_OP_ERR;  
 911   2              }
 912   1              #ifdef ZLH_DEBUG
 913   1              disp_data(2,"B2");
 914   1              disp_data(FILE_INFO_LEN,&file_point);
 915   1              #endif
 916   1              return 0;
 917   1      
 918   1      }
 919          
 920          /*********************************************************************************
C51 COMPILER V7.00  HPI                                                                    09/22/2005 17:15:31 PAGE 16  

 921          压缩日期时间
 922          入口参数:*para  年月日时分秒(HEX)(大端模式)
 923          出口参数: date   uint   日期(小端模式)
 924                                     time   uint   时间(小端模式)
 925          *********************************************************************************/
 926          void compress_date(uchar *para,uint *date,uint *time_com)
 927          {
 928   1              uint year;
 929   1              uchar month,day,hour,min,sec;
 930   1              
 931   1              year=*((uint *)(para));
 932   1              month=*(para+2);
 933   1              day=*(para+3);
 934   1              hour=*(para+4);
 935   1              min=*(para+5);
 936   1              sec=*(para+6);
 937   1              
 938   1              *date=((year-1980)<<9)+(month<<5)+day;
 939   1              *date=SwapINT16(*date);
 940   1              *time_com=(hour<<11)+(min<<5)+(sec>>1);
 941   1              *time_com=SwapINT16(*time_com);
 942   1              return ;
 943   1      }       
 944          
 945          //unsigned char GetFirmwareVersion(void)
 946          //{
 947          //   #define RspBlockGetVersion UartRspBlock.RspBlock.Rsp_GetVersion
 948          //   ////////////////////////////////////////////////////////////
 949          //   RspBlockGetVersion.version=0x0102;
 950          //   return TRUE;
 951          //   #undef RspBlockGetVersion
 952          //}
 953          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   6989    ----
   CONSTANT SIZE    =     56    ----
   XDATA SIZE       =   ----     293
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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