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