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