📄 hpi.lst
字号:
208 6 {
209 7 base=((DBUF[i]&0x1F)-1)*26;
210 7 if(base<=224)
211 7 {
212 8 Ncount=0;
213 8 for(k=1;k<11;k++)
214 8 {
215 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
216 9 Ncount++;
217 9 }
218 8 for(k=14;k<26;k++)
219 8 {
220 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
221 9 Ncount++;
222 9 }
223 8 for(k=28;k<32;k++)
224 8 {
225 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
226 9 Ncount++;
227 9 }
228 8 }
229 7 }
230 6 else
231 6 {
232 7 for(k=0;k<32;k++)
233 7 ShowFileName[Lcount].item[k]=DBUF[i+k];
234 7 Lcount++;
235 7 }
236 6 /////////////////////////////////
237 6 }
238 5 }
239 4 if(bstop==1)break;
240 4 }
241 3
C51 COMPILER V7.06 HPI 08/10/2005 23:25:28 PAGE 5
242 3 if(bstop==1)break;
243 3
244 3 NowCluster=GetNextClusterNum(NowCluster);
245 3
246 3 }while(NowCluster<=0xffef);
247 2
248 2 Response.len=item*32;
249 2 return TRUE;
250 2 }
251 1 }
252
253 unsigned char OpenFile(unsigned char *pBuffer)
254 {
255 1 unsigned int i;
256 1 unsigned char j,bstop,sector;
257 1
258 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
259 1 return FALSE;
260 1 ThisFile.bFileOpen=0;
261 1
262 1 if(DirStartCluster==0) //Root Dir
263 1 {
264 2 for(sector=0;sector<DeviceInfo.BPB_RootEntCnt;sector++)
265 2 {
266 3 if(!RBC_Read(DeviceInfo.RootStartSector+sector,1,DBUF))
267 3 return FALSE;
268 3 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
269 3 {
270 4 if(DBUF[i]==0x00)
271 4 return FALSE;
272 4 j=0;
273 4 while(DBUF[i+j]==*(pBuffer+j))
274 4 {
275 5 j=j+1;
276 5 if(j>10)
277 5 break;
278 5 }
279 4
280 4 if(j>10&&(DBUF[i+11]&0x10)!=0x10)
281 4 {
282 5 for(j=0;j<32;j++)
283 5 UARTBUF[j]=DBUF[i+j];
284 5 bstop=1;
285 5 break;}
286 4
287 4 }
288 3 if(bstop==1)break;
289 3 }
290 2
291 2 if(sector>=DeviceInfo.BPB_RootEntCnt)
292 2 return FALSE;
293 2 }
294 1 ///////////////////////////////////////////////////////////////////////////////////////
295 1 else
296 1 {
297 2 NowCluster=DirStartCluster;
298 2 do
299 2 {
300 3 NowSector=FirstSectorofCluster(NowCluster);
301 3 for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
302 3 {
303 4 if(!RBC_Read(NowSector+sector,1,DBUF))
C51 COMPILER V7.06 HPI 08/10/2005 23:25:28 PAGE 6
304 4 return FALSE;
305 4 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
306 4 {
307 5 if(DBUF[i]==0x00)
308 5 return FALSE;
309 5 j=0;
310 5 while(DBUF[i+j]==*(pBuffer+j))
311 5 {
312 6 j=j+1;
313 6 if(j>10)
314 6 break;
315 6 }
316 5 if(j>10&&(DBUF[i+11]&0x10)!=0x10)
317 5 {
318 6 for(j=0;j<32;j++)
319 6 UARTBUF[j]=DBUF[i+j];
320 6 bstop=1;
321 6 break;
322 6 }
323 5 }
324 4 if(bstop==1)break;
325 4 }
326 3 if(bstop==1)break;
327 3 NowCluster=GetNextClusterNum(NowCluster);
328 3 }while(NowCluster<=0xffef);
329 2
330 2 if(NowCluster>0xffef)
331 2 return FALSE;
332 2 }
333 1
334 1 ThisFile.bFileOpen=1;
335 1 ThisFile.StartCluster=LSwapINT16(UARTBUF[26],UARTBUF[27]);
336 1 ThisFile.LengthInByte=LSwapINT32(UARTBUF[28],UARTBUF[29],UARTBUF[30],UARTBUF[31]);
337 1 ThisFile.ClusterPointer=ThisFile.StartCluster;
338 1 ThisFile.SectorPointer=FirstSectorofCluster(ThisFile.StartCluster);
339 1 ThisFile.OffsetofSector=0;
340 1 ThisFile.SectorofCluster=0;
341 1 ThisFile.FatSectorPointer=0;
342 1 ThisFile.pointer=0;
343 1
344 1 Response.len=32;
345 1 return TRUE;
346 1 }
347
348 unsigned char ReadFile(unsigned long readLength,unsigned char *pBuffer)
349 {
350 1
351 1 unsigned int len,i;
352 1 unsigned int tlen;
353 1 unsigned long blen;
354 1
355 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
356 1 return FALSE;
357 1 if(!ThisFile.bFileOpen)
358 1 return FALSE;
359 1
360 1 blen=readLength;
361 1
362 1 tlen=0;
363 1 if(readLength>MAX_READ_LENGTH)
364 1 return FALSE;
365 1
C51 COMPILER V7.06 HPI 08/10/2005 23:25:28 PAGE 7
366 1 if(readLength+ThisFile.pointer>ThisFile.LengthInByte)
367 1 return FALSE;
368 1
369 1 ////////////////////////////////////////////
370 1 while(readLength>0)
371 1 {
372 2 if(readLength+ThisFile.OffsetofSector>DeviceInfo.BPB_BytesPerSec)
373 2 len=DeviceInfo.BPB_BytesPerSec;
374 2 else
375 2 len=readLength+ThisFile.OffsetofSector;
376 2
377 2 //////////////////////////////////////////////////////
378 2 if(ThisFile.OffsetofSector>0)
379 2 {
380 3 if(RBC_Read(ThisFile.SectorPointer,1,DBUF))
381 3 {
382 4
383 4 len=len-ThisFile.OffsetofSector;
384 4 for(i=0;i<len;i++)
385 4
386 4 *(pBuffer+i)=DBUF[ThisFile.OffsetofSector+i];
387 4 ThisFile.OffsetofSector=ThisFile.OffsetofSector+len;
388 4 }
389 3 else
390 3 return FALSE;
391 3 }
392 2 else
393 2 {
394 3 if(!RBC_Read(ThisFile.SectorPointer,1,pBuffer+tlen))
395 3 return FALSE;
396 3 ThisFile.OffsetofSector=len;
397 3 }
398 2 ////////////////////////////////////////////////////////////
399 2 readLength-=len;
400 2 tlen+=len;
401 2
402 2 /////////////////////////////////////////////////////////
403 2 if((ThisFile.OffsetofSector>DeviceInfo.BPB_BytesPerSec-1)&&(tlen+ThisFile.pointer<ThisFile.LengthInBy
-te))
404 2 {
405 3 ThisFile.OffsetofSector-=DeviceInfo.BPB_BytesPerSec;
406 3 ThisFile.SectorofCluster+=1;
407 3 if(ThisFile.SectorofCluster>DeviceInfo.BPB_SecPerClus-1)
408 3 {
409 4 ThisFile.SectorofCluster=0;
410 4 ThisFile.ClusterPointer=GetNextClusterNum(ThisFile.ClusterPointer);
411 4 if(ThisFile.ClusterPointer>0xffef)
412 4 return FALSE;
413 4 ThisFile.SectorPointer=FirstSectorofCluster(ThisFile.ClusterPointer);
414 4 }
415 3 else
416 3 ThisFile.SectorPointer=ThisFile.SectorPointer+1;
417 3 }
418 2 //////////////////////////////////////////////////////////////////
419 2 }//end while
420 1
421 1 ThisFile.bFileOpen=1;
422 1 ThisFile.pointer+=tlen;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -