📄 tpbulk.lst
字号:
134 {
135 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
136 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
137 1 out[8]=0x00;out[9]=0x00;out[10]=0x00;out[11]=0x00;
138 1 out[12]=0x00;out[13]=0x00;out[14]=6;
139 1 /////////////////////////////////////
140 1 out[15]=SPC_CMD_TESTUNITREADY;
141 1 out[16]=0;out[17]=0;out[18]=0;out[19]=0;out[20]=0;
142 1 //////////////////////////////////////
143 1 if(!epBulkSend(out,0x1f))
144 1 return FALSE;
145 1 DelayMs(5);
146 1 if(!epBulkRcv(out,13))
147 1 return FALSE;
148 1 return TRUE;
149 1 }
150
151 unsigned char SPC_LockMedia(void)
152 {
153 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
154 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
155 1 out[8]=0x00;out[9]=0x00;out[10]=0x00;out[11]=0x00;
156 1 out[12]=0x00;out[13]=0x00;out[14]=5;
157 1 ///////////////////////////////////////////
158 1 out[15]=SPC_CMD_PRVENTALLOWMEDIUMREMOVAL;
159 1 out[16]=0;out[17]=0;out[18]=0;out[19]=1;
160 1 ///////////////////////////////////////////
161 1 if(!epBulkSend(out,0x1f))
162 1 return FALSE;
163 1 DelayMs(5);
164 1
165 1 if(!epBulkRcv(out,13))
166 1 return FALSE;
167 1
168 1 /////////////////////////////
169 1 return TRUE;
170 1 }
171
172 unsigned char RBC_ReadCapacity(void)
173 {
174 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
175 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
176 1 out[8]=0x08;out[9]=0x00;out[10]=0x00;out[11]=0x00;
C51 COMPILER V7.07 TPBULK 07/13/2007 21:38:24 PAGE 4
177 1 out[12]=0x80;out[13]=0x00;out[14]=10;
178 1 /////////////////////////////////////
179 1 out[15]=RBC_CMD_READCAPACITY;
180 1 out[16]=0;out[17]=0;out[18]=0;out[19]=0;
181 1 out[20]=0;out[21]=0;out[22]=0;out[23]=0;
182 1 out[24]=0;
183 1 /////////////////////////////////////
184 1 if(!epBulkSend(out,0x1f))
185 1 return FALSE;
186 1 DelayMs(10);
187 1 if(!epBulkRcv(DBUF,8))
188 1 return FALSE;
189 1 if(!epBulkRcv(out,13))
190 1 return FALSE;
191 1 /////////////////////////////
192 1 return TRUE;
193 1 }
194 //U盘读数据命令 24Bytes
195 //0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
196 //0000:55 53 42 43 60 A6 24 DE |<=4字节长度==>| 80 00 10 读命令=28
197 //0010: 00 |<=4字节扇区号=>|00 扇区长度 00
198 unsigned char RBC_Read(unsigned long lba,unsigned char len,unsigned char *pBuffer)
199 {
200 1 unsigned long lout;
201 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
202 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
203 1 lout=len*DeviceInfo.BPB_BytesPerSec; //根据扇区数计算字节长度
204 1 out[8]=(unsigned char)(lout&0xff); //字节长度最低位
205 1 out[9]=(unsigned char)((lout>>8)&0xff); //字节长度
206 1 out[10]=(unsigned char)((lout>>16)&0xff); //字节长度
207 1 out[11]=(unsigned char)((lout>>24)&0xff); //字节长度最高位
208 1 out[12]=0x80;out[13]=0x00;out[14]=10;
209 1 /////////////////////////////////////
210 1 out[15]=RBC_CMD_READ10;out[16]=0x00;
211 1 out[17]=(unsigned char)((lba>>24)&0xff); //扇区号
212 1 out[18]=(unsigned char)((lba>>16)&0xff);
213 1 out[19]=(unsigned char)((lba>>8)&0xff);
214 1 out[20]=(unsigned char)(lba&0xff); //扇区号
215 1 out[21]=0x00;
216 1 out[22]=(unsigned char)((len>>8)&0xff);
217 1 out[23]=(unsigned char)(len&0xff); //扇区长度
218 1 out[24]=0x00;
219 1 //////////////////////////////////////
220 1 if(!epBulkSend(out,0x1f))
221 1 return FALSE;
222 1 DelayMs(5);
223 1 if(!epBulkRcv(pBuffer,len*DeviceInfo.BPB_BytesPerSec))
224 1 return FALSE;
225 1 if(!epBulkRcv(out,13))
226 1 return FALSE;
227 1 /////////////////////////////
228 1 return TRUE;
229 1 }
230
231 unsigned char RBC_Write(unsigned long lba,unsigned char len,unsigned char *pBuffer)
232 {
233 1 unsigned long lout;
234 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
235 1 out[4]=0xb4;out[5]=0xd9;out[6]=0x77;out[7]=0xc1;
236 1 lout=len*DeviceInfo.BPB_BytesPerSec;
237 1 out[8]=(unsigned char)(lout&0xff);
238 1 out[9]=(unsigned char)((lout>>8)&0xff);
C51 COMPILER V7.07 TPBULK 07/13/2007 21:38:24 PAGE 5
239 1 out[10]=(unsigned char)((lout>>16)&0xff);
240 1 out[11]=(unsigned char)((lout>>24)&0xff);
241 1 out[12]=0x00;out[13]=0x00;out[14]=10;
242 1 /////////////////////////////////////
243 1 out[15]=RBC_CMD_WRITE10;
244 1 out[16]=0x00;
245 1 out[17]=(unsigned char)((lba>>24)&0xff);
246 1 out[18]=(unsigned char)((lba>>16)&0xff);
247 1 out[19]=(unsigned char)((lba>>8)&0xff);
248 1 out[20]=(unsigned char)(lba&0xff);
249 1 out[21]=0x00;
250 1 out[22]=(unsigned char)((len>>8)&0xff);
251 1 out[23]=(unsigned char)(len&0xff);
252 1 out[24]=0x00;
253 1 //////////////////////////////////////
254 1 if(!epBulkSend(out,0x1f))
255 1 return FALSE;
256 1 DelayMs(15);
257 1 if(!epBulkSend(pBuffer,DeviceInfo.BPB_BytesPerSec))
258 1 return FALSE;
259 1 DelayMs(10);
260 1 if(!epBulkRcv(out,13))
261 1 return FALSE;
262 1 return TRUE;
263 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2091 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 26
IDATA SIZE = 32 ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -