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