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