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

📄 hpi32.lst

📁 JLDLED.rar
💻 LST
📖 第 1 页 / 共 4 页
字号:
 222   1              ThisFile.FatSectorPointer=0;    
 223   1              ThisFile.pointer=0;
 224   1              
 225   1              Response.len=32;
 226   1              return TRUE;    
 227   1      }
 228          
 229          
 230          unsigned char ReadFile32(unsigned long readLength,unsigned char *pBuffer)
 231          {
 232   1      
 233   1              unsigned int len,i;
 234   1              unsigned int tlen;      
 235   1              unsigned long blen;
 236   1      
 237   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 238   1                      return FALSE;           
 239   1              if(!ThisFile.bFileOpen)
 240   1                      return FALSE;
 241   1      
C51 COMPILER V7.00  HPI32                                                                  01/15/2008 09:38:32 PAGE 5   

 242   1              blen=readLength;
 243   1              tlen=0;
 244   1              if(readLength>MAX_READ_LENGTH)
 245   1                      return FALSE;   
 246   1              
 247   1              if(readLength+ThisFile.pointer>ThisFile.LengthInByte)
 248   1                      return FALSE;   
 249   1                      
 250   1              ////////////////////////////////////////////            
 251   1                      while(readLength>0)
 252   1                      {
 253   2                         if(ThisFile.SectorofCluster>=DeviceInfo.BPB_SecPerClus)
 254   2                              {
 255   3                                      ThisFile.SectorofCluster=0;
 256   3                                       ThisFile.ClusterPointer=GetNextClusterNum32(ThisFile.ClusterPointer);
 257   3                                       if(ThisFile.ClusterPointer>DeviceInfo.TotCluster)
 258   3                                                 return FALSE;                                                
 259   3                                       ThisFile.SectorPointer=FirstSectorofCluster32(ThisFile.ClusterPointer);        
 260   3                              }
 261   2      
 262   2                         if(readLength+ThisFile.OffsetofSector>DeviceInfo.BPB_BytesPerSec)
 263   2                              len=DeviceInfo.BPB_BytesPerSec;
 264   2                         else
 265   2                              len=readLength+ThisFile.OffsetofSector;
 266   2                         
 267   2                         //////////////////////////////////////////////////////
 268   2                         if(ThisFile.OffsetofSector>0)
 269   2                              {
 270   3                              if(SdReadSector(ThisFile.SectorPointer,1,DBUF))
 271   3                                      {
 272   4                                      
 273   4                                      len=len-ThisFile.OffsetofSector;
 274   4                                      for(i=0;i<len;i++)
 275   4                                              
 276   4                                              *(pBuffer+i)=DBUF[ThisFile.OffsetofSector+i];
 277   4                                      ThisFile.OffsetofSector=ThisFile.OffsetofSector+len;
 278   4                                      }
 279   3                              else
 280   3                                      return FALSE;                           
 281   3                              }
 282   2                         else
 283   2                              {
 284   3                                      if(!SdReadSector(ThisFile.SectorPointer,1,pBuffer+tlen))
 285   3                                                      return FALSE;   
 286   3                                      ThisFile.OffsetofSector=len;
 287   3                              }
 288   2                         ////////////////////////////////////////////////////////////
 289   2                         readLength-=len;
 290   2                         tlen+=len;
 291   2                        
 292   2                         /////////////////////////////////////////////////////////
 293   2                         if(ThisFile.OffsetofSector>=DeviceInfo.BPB_BytesPerSec)
 294   2                         {    
 295   3                              ThisFile.OffsetofSector-=DeviceInfo.BPB_BytesPerSec;
 296   3                              ThisFile.SectorofCluster+=1;
 297   3                              
 298   3                               ThisFile.SectorPointer+=1;
 299   3                          }
 300   2                         //////////////////////////////////////////////////////////////////
 301   2                      }//end while
 302   1                      
 303   1              ThisFile.bFileOpen=1;
C51 COMPILER V7.00  HPI32                                                                  01/15/2008 09:38:32 PAGE 6   

 304   1              ThisFile.pointer+=tlen;
 305   1              //////////////////////////////////////////////
 306   1              Response.len=blen;
 307   1      
 308   1              return TRUE;
 309   1      }
 310          
 311          unsigned char SetFilePointer32(unsigned long pointer)
 312          {
 313   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 314   1                      return FALSE;           
 315   1              if(!ThisFile.bFileOpen)
 316   1                      return FALSE;           
 317   1              ///////////////////////////////////////////////////////////
 318   1              ThisFile.pointer=pointer;
 319   1              if(ThisFile.pointer>ThisFile.LengthInByte)
 320   1                      return FALSE;   
 321   1      
 322   1              if(!GoToPointer32(ThisFile.pointer))
 323   1              {
 324   2              ThisFile.bFileOpen=0;
 325   2              return FALSE;   
 326   2              }
 327   1              //////////////////////////////////////////////
 328   1              return TRUE;
 329   1      }
 330          
 331          unsigned char CreateFile32(unsigned long len,unsigned char *pBuffer,unsigned char *pName)
 332          {
 333   1              unsigned int sector,i,j,DirCount;
 334   1              unsigned long cnum;
 335   1              unsigned char xdata bstop,InByte,bwrite;
 336   1              unsigned long ClusterPointer;
 337   1              
 338   1              if(!bFlags.bits.SLAVE_IS_ATTACHED)
 339   1                      return FALSE;
 340   1              if((len%32)!=0)
 341   1                      return FALSE;
 342   1              if((len+32)>DeviceInfo.BPB_BytesPerSec)
 343   1                      return FALSE;
 344   1      
 345   1              ThisFile.bFileOpen=0;   
 346   1      
 347   1              cnum=GetFreeCusterNum32();
 348   1              if(cnum<0x02)
 349   1                      return FALSE;   
 350   1      
 351   1              pBuffer[21]=(unsigned char)(cnum>>24);
 352   1              pBuffer[20]=(unsigned char)(cnum>>16);
 353   1              pBuffer[27]=(unsigned char)(cnum>>8);
 354   1              pBuffer[26]=(unsigned char)(cnum);
 355   1      
 356   1              pBuffer[28]=0;pBuffer[29]=0;pBuffer[30]=0;pBuffer[31]=0;
 357   1              bstop=0;
 358   1      
 359   1              NowCluster32=DirStartCluster32;         
 360   1                      do
 361   1                      {
 362   2                              NowSector=FirstSectorofCluster32(NowCluster32);
 363   2                              ClusterPointer=NowCluster32;
 364   2                              for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
 365   2                      {   
C51 COMPILER V7.00  HPI32                                                                  01/15/2008 09:38:32 PAGE 7   

 366   3                                      if(!SdReadSector(NowSector+sector,1,DBUF))
 367   3                                              return FALSE;
 368   3                                      DirCount=0;bwrite=0;
 369   3      
 370   3                                      for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
 371   3                                      {
 372   4                                      if(len==0)
 373   4                                              {
 374   5                                              if((DBUF[i]==0x00)||(DBUF[i]==0xE5))
 375   5                                              {
 376   6                                              for(j=0;j<32;j++)
 377   6                                                      DBUF[i+j]=*(pBuffer+j);
 378   6                                              if(!SdWriteSector(NowSector+sector,1,DBUF))
 379   6                                                      return FALSE;                                   
 380   6                                              bstop=1;
 381   6                                              break;
 382   6                                              }               
 383   5                                              }
 384   4                                      else
 385   4                                      {
 386   5                                      if(DirCount==0)
 387   5                                              InByte=i;
 388   5                                      if(DBUF[i]==0xE5)                               
 389   5                                              DirCount++;                             
 390   5                                      else if(DBUF[i]==0x00)
 391   5                                              {       
 392   6                                              DirCount++;     
 393   6                                              DBUF[i]=0xE5;   
 394   6                                              bwrite=1;                               
 395   6                                              }
 396   5                                      else
 397   5                                              DirCount=0;
 398   5      
 399   5                                      if((DirCount*32)>=(len+32))
 400   5                                              {
 401   6                                              for(j=0;j<len;j++)
 402   6                                                      DBUF[InByte+j]=*(pName+j);
 403   6                                              for(j=0;j<32;j++)
 404   6                                                      DBUF[InByte+len+j]=*(pBuffer+j);
 405   6                                              if(!SdWriteSector(NowSector+sector,1,DBUF))
 406   6                                                      return FALSE;                                   
 407   6                                              bstop=1;
 408   6                                              break;
 409   6                                              }
 410   5                                       }
 411   4                                      }
 412   3                                      if(bstop==1)break;
 413   3                                      
 414   3                                      if((len!=0)&&(bwrite==1))
 415   3                                      {
 416   4                                      if(!SdWriteSector(NowSector+sector,1,DBUF))
 417   4                                              return FALSE;
 418   4                              }
 419   3                      }
 420   2                              if(bstop==1)break;
 421   2              
 422   2                              NowCluster32=GetNextClusterNum32(NowCluster32);
 423   2                              if(NowCluster32>DeviceInfo.TotCluster)
 424   2                      {
 425   3                              NowCluster32=CreateClusterLink32(ClusterPointer);
 426   3                              if(NowCluster32==0x00)
 427   3                                       return FALSE;
C51 COMPILER V7.00  HPI32                                                                  01/15/2008 09:38:32 PAGE 8   

 428   3                              NowSector=FirstSectorofCluster32(NowCluster32);
 429   3                              for(i=0;i<DeviceInfo.BPB_BytesPerSec;i++) DBUF[i]=0x00;
 430   3                              for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
 431   3                                      {
 432   4                                      if(!SdWriteSector(NowSector+sector,1,DBUF))
 433   4                                              return FALSE;
 434   4                                      }
 435   3                              }
 436   2                      }while(NowCluster32<=DeviceInfo.TotCluster);    
 437   1      ////////////////////////////////////////////////////////////////
 438   1              
 439   1              ThisFile.StartCluster=cnum;
 440   1              ThisFile.LengthInByte=0;
 441   1              ThisFile.ClusterPointer=ThisFile.StartCluster;
 442   1              ThisFile.SectorPointer=FirstSectorofCluster32(ThisFile.StartCluster);
 443   1              ThisFile.OffsetofSector=0;
 444   1              ThisFile.SectorofCluster=0;
 445   1              ThisFile.bFileOpen=1;
 446   1              ThisFile.pointer=0;
 447   1              ThisFile.FatSectorPointer=0;
 448   1              
 449   1              return TRUE;

⌨️ 快捷键说明

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