📄 tpbulk.lst
字号:
C51 COMPILER V7.06 TPBULK 08/10/2005 23:25:28 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TPBULK
OBJECT MODULE PLACED IN TPBULK.OBJ
COMPILER INVOKED BY: D:\Keil51\C51\BIN\C51.EXE TPBULK.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "common.h"
2 #include "SL811.H"
3 #include "TPBULK.H"
4 #include "HAL.H"
5 #include "HPI.H"
6 #include "HPI32.H"
7
8 //////////////////////////////////
9 extern unsigned char xdata DBUF[BUFFER_LENGTH];
10 extern SYS_INFO_BLOCK xdata DeviceInfo;
11 extern FILE_INFO xdata ThisFile;
12 extern unsigned int xdata DirStartCluster;
13 extern unsigned long xdata DirStartCluster32;
14 extern FLAGS bdata bFlags;
15
16 unsigned char idata out[0x20];
17 ///////////////////////////////////////////////////////////////////////////
18 unsigned char EnumMassDev(void)
19 {
20 1 unsigned char i;
21 1 if(!SPC_Inquiry())
22 1 return FALSE;
23 1 if(!SPC_TestUnit())
24 1 return FALSE;
25 1 if(!SPC_LockMedia())
26 1 return FALSE;
27 1 if(!SPC_RequestSense())
28 1 return FALSE;
29 1 if(!SPC_TestUnit())
30 1 return FALSE;
31 1 if(!RBC_ReadCapacity())
32 1 return FALSE;
33 1
34 1 ////////////////////////////////////////////////////
35 1 DeviceInfo.BPB_BytesPerSec=512; //暂假设为512
36 1
37 1 if(!SPC_RequestSense())
38 1 return FALSE;
39 1 if(!SPC_TestUnit())
40 1 return FALSE;
41 1 if(!RBC_ReadCapacity())
42 1 return FALSE;
43 1 ////////////////////////////////////////////////////
44 1 for(i=0;i<0x1f;i++)
45 1 out[i]=0;
46 1 if(!ListDirve())
47 1 return FALSE;
48 1 ThisFile.bFileOpen=0;
49 1 ///////////////////////////////////////////////////////
50 1 return TRUE;
51 1 }
52
53 unsigned char ListDirve(void)
54 {
55 1 unsigned char i,stop,j,extend;
C51 COMPILER V7.06 TPBULK 08/10/2005 23:25:28 PAGE 2
56 1 unsigned long sector0,sector1,sector2,sectorp;
57 1 bFlags.bits.SLAVE_IS_ATTACHED=0;
58 1 DeviceInfo.DriveNum=0;
59 1 extend=0;
60 1
61 1 if(!RBC_Read(0x0,1,DBUF))
62 1 return FALSE;
63 1 //////////////////////Main Partain////////////////////////////////////////////
64 1 for(i=0;i<4;i++)
65 1 {
66 2 j=i*16;
67 2 if(DBUF[450+i*16]==0x0b||DBUF[450+i*16]==0x0c)//FAT32
68 2 {
69 3 DeviceInfo.par_FAT[DeviceInfo.DriveNum]=1;
70 3 DeviceInfo.StartSector[DeviceInfo.DriveNum]=LSwapINT32(DBUF[454+j],DBUF[455+j],DBUF[456+j],DBUF[457+j]);
71 3 DeviceInfo.DriveNum=DeviceInfo.DriveNum+1;
72 3 }
73 2 else if(DBUF[450+i*16]==0x04||DBUF[450+i*16]==0x06||DBUF[450+i*16]==0x0e)//FAT16
74 2 {
75 3 DeviceInfo.par_FAT[DeviceInfo.DriveNum]=0;
76 3 DeviceInfo.StartSector[DeviceInfo.DriveNum]=LSwapINT32(DBUF[454+j],DBUF[455+j],DBUF[456+j],DBUF[457+j]);
77 3 DeviceInfo.DriveNum=DeviceInfo.DriveNum+1;
78 3 }
79 2 else if(DBUF[450+i*16]==0x05||DBUF[450+i*16]==0x0f)//extend
80 2 {
81 3 extend=i;
82 3 DeviceInfo.StartSector[extend]=LSwapINT32(DBUF[454+j],DBUF[455+j],DBUF[456+j],DBUF[457+j]);
83 3 DeviceInfo.DriveNum=DeviceInfo.DriveNum+1;
84 3 }
85 2 }
86 1 //////////////////////////////扩展分区//////////////////////////////////////
87 1
88 1 if(extend)
89 1 {
90 2 stop=0;i=1;
91 2 sector0=DeviceInfo.StartSector[extend];
92 2 sectorp=sector0;
93 2
94 2 do{
95 3 if(!RBC_Read(sector0,1,DBUF))
96 3 return FALSE;
97 3 sector1=LSwapINT32(DBUF[454],DBUF[455],DBUF[456],DBUF[457]);
98 3 sector2=LSwapINT32(DBUF[470],DBUF[471],DBUF[472],DBUF[473]);
99 3
100 3 if(sector2==0||DeviceInfo.DriveNum>=MAX_par)
101 3 stop=1;
102 3
103 3 if(DBUF[450]==0x0b||DBUF[450]==0x0c)//FAT32
104 3 {
105 4 if(i==1)
106 4 {
107 5 DeviceInfo.par_FAT[extend]=1;
108 5 DeviceInfo.StartSector[extend]=sector0+sector1;
109 5 i=i+1;
110 5 }
111 4 else
112 4 {
113 5 DeviceInfo.StartSector[DeviceInfo.DriveNum]=sector0+sector1;
114 5 DeviceInfo.par_FAT[DeviceInfo.DriveNum]=1;
115 5 DeviceInfo.DriveNum=DeviceInfo.DriveNum+1;
116 5 }
117 4 }
C51 COMPILER V7.06 TPBULK 08/10/2005 23:25:28 PAGE 3
118 3 else if(DBUF[450]==0x04||DBUF[450]==0x06||DBUF[450]==0x0e)//FAT16
119 3 {
120 4 if(i==1)
121 4 {
122 5 DeviceInfo.par_FAT[extend]=0;
123 5 DeviceInfo.StartSector[extend]=sector0+sector1;
124 5 i=i+1;
125 5 }
126 4 else
127 4 {
128 5 DeviceInfo.StartSector[DeviceInfo.DriveNum]=sector0+sector1;
129 5 DeviceInfo.par_FAT[DeviceInfo.DriveNum]=0;
130 5 DeviceInfo.DriveNum=DeviceInfo.DriveNum+1;
131 5 }
132 4 }
133 3
134 3 sector0=sectorp+sector2;
135 3 }while(!stop);
136 2 }
137 1 ///////////////////////////////////////////////////////
138 1 return TRUE;
139 1 }
140
141
142 unsigned char SPC_Inquiry(void)
143 {
144 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
145 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
146 1 out[8]=0x24;out[9]=0x00;out[10]=0x00;out[11]=0x00;
147 1 out[12]=0x80;out[13]=0x00;out[14]=06;
148 1 out[15]=SPC_CMD_INQUIRY;out[16]=0x00;out[17]=0x00;
149 1 out[18]=0x00;out[19]=0x24;out[20]=0x00;
150 1 ////////////////////////////////
151 1 if(!epBulkSend(out,0x1f))
152 1 return FALSE;
153 1 DelayMs(150);
154 1 if(!epBulkRcv(DBUF,38))
155 1 return FALSE;
156 1 if(!epBulkRcv(out,13))
157 1 return FALSE;
158 1 ////////////////////////////////
159 1 return TRUE;
160 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -