📄 hpi.lst
字号:
C51 COMPILER V7.00 HPI 02/15/2008 12:14:58 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE HPI
OBJECT MODULE PLACED IN HPI.OBJ
COMPILER INVOKED BY: e:\Keil\C51\BIN\C51.EXE HPI.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "common.h"
2 #include "DEVICE.H"
3 #include "HPI.H"
4 #include "HAL.H"
5 #include "Fat.h"
6 #include "Fat32.h"
7 #include "HPI32.H"
8
9 extern FLAGS bdata bFlags;
10 extern unsigned char xdata DBUF[];//BUFFER_LENGTH];
11 //////////////////////////////////////////
12 unsigned char xdata UARTBUF[UARTBUF_LENGTH];
13 SYS_INFO_BLOCK xdata DeviceInfo;
14 FILE_INFO xdata ThisFile;
15
16 Command_Def xdata Command;
17 Response_Def xdata Response;
18
19 unsigned int xdata DirStartCluster,NowCluster;
20 unsigned long xdata NowSector;
21 ShowFileName_Def xdata ShowFileName[MaxLFNum]; //long file struct
22 /////////////////////////////////////////////
23
24 void UartSendRsp(void)
25 {
26 1 unsigned int i;
27 1 unsigned char *pBuf=(unsigned char *)&Response;
28 1 MCU_LED4=0;
29 1 for(i=0;i<5;i++)
30 1 ComSendByte(*(pBuf+i));
31 1
32 1 if(Response.len!=0)
33 1 {
34 2 for(i=0;i<Response.len;i++)
35 2 ComSendByte(UARTBUF[i]);
36 2 }
37 1 MCU_LED4=1;
38 1 }
39
40 unsigned char UartHandler(void)
41 {
42 1 Response.Result=0;Response.len=0;
43 1 switch(Command.CLass)
44 1 {
45 2 case 0x00: //List
46 2 Response.Result=List();
47 2 break;
48 2 case 0x01: //Open File
49 2 Response.Result=OpenFile(Command.Parameter);
50 2 break;
51 2 case 0x02: //Read File
52 2 Response.Result=ReadFile(Command.len,UARTBUF);
53 2 break;
54 2 case 0x03: //Set Pointer
55 2 Response.Result=SetFilePointer(Command.len);
C51 COMPILER V7.00 HPI 02/15/2008 12:14:58 PAGE 2
56 2 break;
57 2 case 0x04: //Great File
58 2 Response.Result=OpenFile(Command.Parameter);
59 2 if(Response.Result)
60 2 {
61 3 Response.Result=SetFilePointer(ThisFile.LengthInByte);
62 3 }
63 2 else
64 2 Response.Result=CreateFile(Command.len,Command.Parameter,UARTBUF);
65 2 break;
66 2 case 0x05: //Write File
67 2 Response.Result=WriteFile(Command.len,UARTBUF);
68 2 break;
69 2 case 0x06: //Remove File
70 2 ThisFile.bFileOpen=0;
71 2 Response.Result=RemoveFile(Command.Parameter);
72 2 break;
73 2 case 0x07: //Get Space
74 2 Response.Result=GetCapacity();
75 2 break;
76 2 case 0x08: //DetectDisk
77 2 if(bFlags.bits.SLAVE_IS_ATTACHED)
78 2 Response.Result=1;
79 2 break;
80 2 case 0x09: //Great Dir
81 2 Response.Result=DownDir(Command.Parameter);
82 2 if(!Response.Result)
83 2 Response.Result=CreateDir(Command.len,Command.Parameter,UARTBUF);
84 2 break;
85 2 case 0x0a: //Down Dir
86 2 Response.Result=DownDir(Command.Parameter);
87 2 break;
88 2 case 0x0b: //Up Dir
89 2 Response.Result=UpDir();
90 2 break;
91 2 case 0x0c: //Up RootDir
92 2 Response.Result=UpRootDir();
93 2 break;
94 2 }
95 1
96 1 UartSendRsp();
97 1 ///////////////////////////////
98 1 return TRUE;
99 1 }
100
101 unsigned char List(void)
102 {
103 1 unsigned int item,i;
104 1 unsigned char k,bstop,sector;
105 1 unsigned char Lcount,Ncount,base;
106 1
107 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
108 1 return FALSE;
109 1 item=0;
110 1 bstop=0;
111 1 ////////////////////////////////////
112 1 Lcount=0;
113 1 for(i=0;i<MaxLFNum;i++)
114 1 {
115 2 ShowFileName[i].LongName[0]=0x00;
116 2 ShowFileName[i].LongName[1]=0x00;
117 2 }
C51 COMPILER V7.00 HPI 02/15/2008 12:14:58 PAGE 3
118 1 /////////////////////////////////////
119 1
120 1 if(DirStartCluster==0) //Root Dir
121 1 {
122 2 for(sector=0;sector<DeviceInfo.BPB_RootEntCnt;sector++)
123 2 {
124 3 if(!SdReadSector(DeviceInfo.RootStartSector+sector,1,DBUF))
125 3 return FALSE;
126 3 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
127 3 {
128 4 if(DBUF[i]==0x00)
129 4 {bstop=1;
130 5 break;}
131 4 else if(DBUF[i]==0xE5)
132 4 continue;
133 4 else
134 4 {
135 5 for(k=0;k<32;k++)
136 5 UARTBUF[item*32+k]=DBUF[i+k];
137 5 item=item+1;
138 5 if(item>=(UARTBUF_LENGTH/32)) {bstop=1;break;} //串口缓冲 只能有512项目录,强行结束
139 5 /////////////////////////////////
140 5 if(Lcount<MaxLFNum)
141 5 {
142 6 if(DBUF[i+11]==0x0F)
143 6 {
144 7 base=((DBUF[i]&0x1F)-1)*26;
145 7 if(base<=224)
146 7 {
147 8 Ncount=0;
148 8 for(k=1;k<11;k++)
149 8 {
150 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
151 9 Ncount++;
152 9 }
153 8 for(k=14;k<26;k++)
154 8 {
155 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
156 9 Ncount++;
157 9 }
158 8 for(k=28;k<32;k++)
159 8 {
160 9 ShowFileName[Lcount].LongName[base+Ncount]=DBUF[i+k];
161 9 Ncount++;
162 9 }
163 8 }
164 7 }
165 6 else
166 6 {
167 7 for(k=0;k<32;k++)
168 7 ShowFileName[Lcount].item[k]=DBUF[i+k];
169 7 Lcount++;
170 7 }
171 6 }//if(Lcount<MaxLFNum)
172 5 /////////////////////////////////
173 5 }
174 4 }
175 3
176 3 if(bstop==1)break;
177 3 }
178 2 Response.len=item*32;
179 2 return TRUE;
C51 COMPILER V7.00 HPI 02/15/2008 12:14:58 PAGE 4
180 2 }
181 1 //////////////////////////////////////////////////////////////////
182 1 else //Son Dir
183 1 {
184 2 NowCluster=DirStartCluster;
185 2 do
186 2 {
187 3 NowSector=FirstSectorofCluster(NowCluster);
188 3 for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
189 3 {
190 4 if(!SdReadSector(NowSector+sector,1,DBUF))
191 4 return FALSE;
192 4 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
193 4 {
194 5 if(DBUF[i]==0x00)
195 5 {bstop=1;break;}
196 5 else if(DBUF[i]==0xE5)
197 5 continue;
198 5 else
199 5 {
200 6 for(k=0;k<32;k++)
201 6 UARTBUF[item*32+k]=DBUF[i+k];
202 6 item=item+1;
203 6 if(item>=(UARTBUF_LENGTH/32)) {bstop=1;break;} //串口缓冲 只能有512项目录,强行结束
204 6 /////////////////////////////////
205 6 if(Lcount<MaxLFNum)
206 6 {
207 7 if(DBUF[i+11]==0x0F)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -