📄 tpbulk.lst
字号:
C51 COMPILER V7.07 TPBULK 07/13/2007 21:38:24 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE TPBULK
OBJECT MODULE PLACED IN D:\HEX\TPBULK.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE TPBULK.C BROWSE DEBUG OBJECTEXTEND OBJECT(D:\HEX\TPBULK.obj)
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
15 unsigned char idata out[0x20];
16 ///////////////////////////////////////////////////////////////////////////
17 unsigned char EnumMassDev(void)
18 {
19 1 unsigned int ReservedSectorsNum;
20 1
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 if(!RBC_Read(0x0,1,DBUF))
45 1 return FALSE;
46 1 //////////////////////////////////
47 1 if(DBUF[0]==0xeb||DBUF[0]==0xe9)
48 1 {
49 2 DeviceInfo.StartSector=0;
50 2 }
51 1 else
52 1 {
53 2 DeviceInfo.StartSector=LSwapINT32(DBUF[454],DBUF[455],DBUF[456],DBUF[457]);
54 2 }
55 1 ///////////////////////////////////////////////////////
C51 COMPILER V7.07 TPBULK 07/13/2007 21:38:24 PAGE 2
56 1 if(!RBC_Read(DeviceInfo.StartSector,1,DBUF))
57 1 return FALSE;
58 1
59 1 DeviceInfo.BPB_BytesPerSec=LSwapINT16(DBUF[11],DBUF[12]);
60 1 DeviceInfo.BPB_SecPerClus=DBUF[13];
61 1 ReservedSectorsNum=LSwapINT16(DBUF[14],DBUF[15]);
62 1 DeviceInfo.BPB_NumFATs=DBUF[16];
63 1
64 1 if(DBUF[82]=='F'&&DBUF[83]=='A'&&DBUF[84]=='T'&&DBUF[85]=='3'&&DBUF[86]=='2')
65 1 {
66 2 DeviceInfo.BPB_TotSec32=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
67 2 DeviceInfo.BPB_FATSz32=LSwapINT32(DBUF[36],DBUF[37],DBUF[38],DBUF[39]);
68 2 DeviceInfo.RootStartCluster=LSwapINT32(DBUF[44],DBUF[45],DBUF[46],DBUF[47]);
69 2 DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
70 2 DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz32;
71 2 DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-DeviceInfo.FirstDataSector+1)/DeviceInfo.BPB_SecPerClus+1
-;
72 2 DirStartCluster32=DeviceInfo.RootStartCluster;
73 2 DeviceInfo.FAT=1; //FAT16=0,FAT32=1;
74 2 }
75 1 else
76 1 {
77 2 DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
78 2 DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;
79 2 DeviceInfo.BPB_TotSec16=LSwapINT16(DBUF[19],DBUF[20]);
80 2 DeviceInfo.BPB_FATSz16=LSwapINT16(DBUF[22],DBUF[23]);
81 2 DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
82 2 DeviceInfo.RootStartSector=DeviceInfo.StartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Reserved
-SectorsNum;
83 2 DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Devic
-eInfo.BPB_RootEntCnt;
84 2 DeviceInfo.FAT=0;
85 2 }
86 1 ///////////////////////////////////////////////////////
87 1 ThisFile.bFileOpen=0;
88 1 ///////////////////////////////////////////////////////
89 1 return TRUE;
90 1 }
91
92 unsigned char SPC_Inquiry(void)
93 {
94 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
95 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
96 1 out[8]=0x24;out[9]=0x00;out[10]=0x00;out[11]=0x00;
97 1 out[12]=0x80;out[13]=0x00;out[14]=06;
98 1 out[15]=SPC_CMD_INQUIRY;out[16]=0x00;out[17]=0x00;
99 1 out[18]=0x00;out[19]=0x24;out[20]=0x00;
100 1 ////////////////////////////////
101 1 if(!epBulkSend(out,0x1f))
102 1 return FALSE;
103 1 DelayMs(150);
104 1 if(!epBulkRcv(DBUF,38))
105 1 return FALSE;
106 1 if(!epBulkRcv(out,13))
107 1 return FALSE;
108 1 ////////////////////////////////
109 1 return TRUE;
110 1 }
111
112 unsigned char SPC_RequestSense(void)
113 {
114 1 out[0]=0x55;out[1]=0x53;out[2]=0x42;out[3]=0x43;
C51 COMPILER V7.07 TPBULK 07/13/2007 21:38:24 PAGE 3
115 1 out[4]=0x60;out[5]=0xa6;out[6]=0x24;out[7]=0xde;
116 1 out[8]=0x0e;out[9]=0x00;out[10]=0x00;out[11]=0x00;
117 1 out[12]=0x80;out[13]=0x00;out[14]=6;
118 1 out[15]=SPC_CMD_REQUESTSENSE;out[16]=0x00;out[17]=0x00;
119 1 out[18]=0x00;out[19]=0x0e;out[20]=0x00;
120 1 //////////////////////////////////////
121 1 if(!epBulkSend(out,0x1f))
122 1 return FALSE;
123 1 DelayMs(5);
124 1 if(!epBulkRcv(out,18))
125 1 return FALSE;
126 1 //delay_dsp
127 1 if(!epBulkRcv(out,13))
128 1 return FALSE;
129 1 /////////////////////////////
130 1 return TRUE;
131 1 }
132
133 unsigned char SPC_TestUnit(void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -