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

📄 hpi32.lst

📁 能用51读写U盘...创建文件格式...能自由创建文件.删除.读写
💻 LST
📖 第 1 页 / 共 4 页
字号:
 722   5                                              }
 723   4                                      else
 724   4                                      {
 725   5                                      if(DirCount==0)
 726   5                                              InByte=i;
 727   5                                      if(DBUF[i]==0xE5)                               
 728   5                                              DirCount++;                             
 729   5                                      else if(DBUF[i]==0x00)
 730   5                                              {       
 731   6                                              DirCount++;     
 732   6                                              DBUF[i]=0xE5;
 733   6                                              bwrite=1;                                       
 734   6                                              }
 735   5                                      else
 736   5                                              DirCount=0;
C51 COMPILER V7.06   HPI32                                                                 08/10/2005 23:25:29 PAGE 13  

 737   5      
 738   5                                      if((DirCount*32)>=(len+32))
 739   5                                              {
 740   6                                              for(j=0;j<len;j++)
 741   6                                                      DBUF[InByte+j]=*(pName+j);
 742   6                                              for(j=0;j<32;j++)
 743   6                                                      DBUF[InByte+len+j]=*(pBuffer+j);
 744   6                                              if(!RBC_Write(NowSector+sector,1,DBUF))
 745   6                                                      return FALSE;                                   
 746   6                                              bstop=1;
 747   6                                              break;
 748   6                                              }
 749   5                                       }                      
 750   4                                      }
 751   3                                      if(bstop==1)break;
 752   3                                      if((len!=0)&&(bwrite==1))
 753   3                                      {
 754   4                                      if(!RBC_Write(NowSector+sector,1,DBUF))
 755   4                                              return FALSE;
 756   4                              }
 757   3                      }
 758   2                              if(bstop==1)break;
 759   2              
 760   2                              NowCluster32=GetNextClusterNum32(NowCluster32);
 761   2                              if(NowCluster32>DeviceInfo.TotCluster)
 762   2                      {
 763   3                              NowCluster32=CreateClusterLink32(ClusterPointer);
 764   3                              if(NowCluster32==0x00)
 765   3                                       return FALSE;
 766   3                              NowSector=FirstSectorofCluster32(NowCluster32);
 767   3                              for(i=0;i<DeviceInfo.BPB_BytesPerSec;i++) DBUF[i]=0x00;
 768   3                              for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
 769   3                                      {
 770   4                                      if(!RBC_Write(NowSector+sector,1,DBUF))
 771   4                                              return FALSE;
 772   4                                      }
 773   3                              }
 774   2                      }while(NowCluster32<=DeviceInfo.TotCluster);
 775   1              
 776   1              if(NowCluster32>DeviceInfo.TotCluster)
 777   1                  return FALSE;
 778   1      ////////////////////////////////////////////////////////////////
 779   1              for(i=64;i<DeviceInfo.BPB_BytesPerSec;i++)      DBUF[i]=0x00;
 780   1              
 781   1              for(i=0;i<43;i++) DBUF[i]=0x20;
 782   1              
 783   1              DBUF[0]=0x2e;
 784   1              for(i=11;i<32;i++) DBUF[i]=pBuffer[i];
 785   1      
 786   1              DBUF[32]=0x2e;DBUF[33]=0x2e;
 787   1              for(i=43;i<64;i++) DBUF[i]=pBuffer[i-32];
 788   1      
 789   1              if(DirStartCluster32==DeviceInfo.RootStartCluster)      //Root Dir
 790   1                      {
 791   2                      DBUF[53]=0;DBUF[52]=0;DBUF[59]=0;DBUF[58]=0;
 792   2                      }
 793   1              else
 794   1                      {
 795   2                      DBUF[53]=(unsigned char)(DirStartCluster32>>24);
 796   2                      DBUF[52]=(unsigned char)(DirStartCluster32>>16);
 797   2                      DBUF[59]=(unsigned char)(DirStartCluster32>>8);
 798   2                      DBUF[58]=(unsigned char)(DirStartCluster32);
C51 COMPILER V7.06   HPI32                                                                 08/10/2005 23:25:29 PAGE 14  

 799   2                      }
 800   1      
 801   1              NowSector=FirstSectorofCluster32(cnum);
 802   1              if(!RBC_Write(NowSector,1,DBUF))
 803   1                      return FALSE;   
 804   1      
 805   1              DirStartCluster32=cnum;
 806   1      //      ThisFile.ClusterPointer=DirStartCluster32;
 807   1              ThisFile.ClusterPointer=0;              
 808   1              return TRUE;    
 809   1      }
 810          
 811          unsigned char DownDir32(unsigned char *pBuffer)
 812          {
 813   1              unsigned int i;
 814   1              unsigned char j,bstop,sector;   
 815   1                      
 816   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 817   1                      return FALSE;   
 818   1              
 819   1              ThisFile.bFileOpen=0;
 820   1              bstop=0;
 821   1      
 822   1              NowCluster32=DirStartCluster32;         
 823   1                      do
 824   1                      {
 825   2                              NowSector=FirstSectorofCluster32(NowCluster32);
 826   2                              for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
 827   2                      {   
 828   3                                      if(!RBC_Read(NowSector+sector,1,DBUF))
 829   3                                              return FALSE;                           
 830   3                                      for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
 831   3                                      {
 832   4                                              if(DBUF[i]==0x00)
 833   4                                                      return FALSE;
 834   4                                              j=0;
 835   4                                              while(DBUF[i+j]==*(pBuffer+j))
 836   4                                              {
 837   5                                                       j=j+1;
 838   5                                                       if(j>10)
 839   5                                                              break;
 840   5                                              }
 841   4                                              if(j>10&&(DBUF[i+11]&0x10))
 842   4                                              {bstop=1;break;}
 843   4                                      }
 844   3                                      if(bstop==1)break;              
 845   3                      }
 846   2                              if(bstop==1)break;      
 847   2                              NowCluster32=GetNextClusterNum32(NowCluster32);                 
 848   2                      }while(NowCluster32<=DeviceInfo.TotCluster);
 849   1                      
 850   1              if(NowCluster32>DeviceInfo.TotCluster)
 851   1                      return FALSE;
 852   1      
 853   1              DirStartCluster32=LSwapINT32(DBUF[i+26],DBUF[i+27],DBUF[i+20],DBUF[i+21]);      
 854   1      //      ThisFile.ClusterPointer=DirStartCluster32;
 855   1              ThisFile.ClusterPointer=0;              
 856   1              return TRUE;
 857   1      }
 858          
 859          unsigned char UpDir32()
 860          {
C51 COMPILER V7.06   HPI32                                                                 08/10/2005 23:25:29 PAGE 15  

 861   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 862   1                      return FALSE;   
 863   1              if(DirStartCluster32==DeviceInfo.RootStartCluster)      //Root Dir
 864   1                      return TRUE;    
 865   1              
 866   1              ThisFile.bFileOpen=0;
 867   1      
 868   1              NowSector=FirstSectorofCluster32(DirStartCluster32);
 869   1              if(!RBC_Read(NowSector,1,DBUF))
 870   1                              return FALSE;
 871   1              if(DBUF[32]!=0x2e&&DBUF[33]!=0x2e)      //..
 872   1                              return FALSE;
 873   1      
 874   1              DirStartCluster32=LSwapINT32(DBUF[58],DBUF[59],DBUF[52],DBUF[53]);
 875   1              if(DirStartCluster32==0)        //Root Dir
 876   1                      DirStartCluster32=DeviceInfo.RootStartCluster;  
 877   1      //      ThisFile.ClusterPointer=DirStartCluster32;
 878   1              ThisFile.ClusterPointer=0;              
 879   1              return TRUE;
 880   1      }
 881          
 882          unsigned char UpRootDir32()
 883          {
 884   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 885   1                      return FALSE;
 886   1      
 887   1              ThisFile.bFileOpen=0;
 888   1              DirStartCluster32=DeviceInfo.RootStartCluster;  //Root Dir
 889   1                              
 890   1              return TRUE;
 891   1      }
 892          
 893          unsigned char GetDriveNum()
 894          {
 895   1              Response.len=1;
 896   1              UARTBUF[0]=DeviceInfo.DriveNum;
 897   1              return TRUE;
 898   1      }
 899          
 900          unsigned char SelectDrive(unsigned char Drive_Num)//Drive_Num=0,1,2,....
 901          {
 902   1              unsigned int ReservedSectorsNum;
 903   1              
 904   1              if(Drive_Num>=DeviceInfo.DriveNum)
 905   1                      return FALSE;
 906   1      
 907   1              bFlags.bits.SLAVE_IS_ATTACHED=0;
 908   1              if(!RBC_Read(DeviceInfo.StartSector[Drive_Num],1,DBUF))
 909   1                      return FALSE;
 910   1      
 911   1              DeviceInfo.BPB_BytesPerSec=LSwapINT16(DBUF[11],DBUF[12]);
 912   1              DeviceInfo.BPB_SecPerClus=DBUF[13];
 913   1              ReservedSectorsNum=LSwapINT16(DBUF[14],DBUF[15]);
 914   1              DeviceInfo.BPB_NumFATs=DBUF[16];
 915   1      
 916   1              //if(DBUF[82]=='F'&&DBUF[83]=='A'&&DBUF[84]=='T'&&DBUF[85]=='3'&&DBUF[86]=='2')
 917   1              if(DeviceInfo.par_FAT[Drive_Num]==1)    //FAT32
 918   1                      {
 919   2                      DeviceInfo.BPB_TotSec32=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
 920   2                      DeviceInfo.BPB_FATSz32=LSwapINT32(DBUF[36],DBUF[37],DBUF[38],DBUF[39]);
 921   2                      DeviceInfo.RootStartCluster=LSwapINT32(DBUF[44],DBUF[45],DBUF[46],DBUF[47]);
 922   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector[Drive_Num]+ReservedSectorsNum;
C51 COMPILER V7.06   HPI32                                                                 08/10/2005 23:25:29 PAGE 16  

 923   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz32;
 924   2                      DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-DeviceInfo.FirstDataSector+1)/DeviceInfo.BPB_SecPerClus+1
             -;
 925   2                      DirStartCluster32=DeviceInfo.RootStartCluster;
 926   2                      DeviceInfo.FAT=1;       //FAT16=0,FAT32=1;
 927   2                      }
 928   1              else    //FAT16
 929   1                      {               
 930   2                      DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
 931   2                      DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;    
 932   2                      DeviceInfo.BPB_TotSec16=LSwapINT16(DBUF[19],DBUF[20]);  
 933   2                      DeviceInfo.BPB_FATSz16=LSwapINT16(DBUF[22],DBUF[23]);                   
 934   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector[Drive_Num]+ReservedSectorsNum;
 935   2                      DeviceInfo.RootStartSector=DeviceInfo.StartSector[Drive_Num]+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz
             -16+ReservedSectorsNum;        
 936   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Devic
             -eInfo.BPB_RootEntCnt;
 937   2                      DeviceInfo.FAT=0;
 938   2                      }
 939   1      
 940   1              ///////////////////////////////////////////////////////
 941   1              bFlags.bits.SLAVE_IS_ATTACHED=1;
 942   1              ThisFile.bFileOpen=0;   
 943   1              ///////////////////////////////////////////////////////
 944   1              return TRUE;
 945   1      }
 946          


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