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