📄 ide_drv.lst
字号:
C51 COMPILER V7.50 IDE_DRV 02/16/2009 09:59:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE IDE_DRV
OBJECT MODULE PLACED IN ide_drv.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE lib_mcu\ide\ide_drv.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\ide_drv.lst)
-OBJECT(ide_drv.obj)
line level source
1
2 #include "config.h" /* system configuration */
3 #include "ide_drv.h"
4 #include "..\usb\usb_drv.h" /* usb driver definition */
5 #include "lib_mcu\lcd\lcd_drv.h" /* c51 driver definition */
6 #include "lib_mcu\clock\clock.h"
7 //#include "lib_mcu\serial\serial.h"
8
9 #define Usb_clear_RXOUTB0() {if(UEPSTAX & 0x42) UEPSTAX &= 0xbd;}
10
11
12 extern xdata Byte gl_media_buffer[512];
13 extern bit bMediaReadOpenFlag;
14 extern INT16U u16MediaBytePointer;
15 extern INT32U u32MediaSector;
16
17 extern data Uint32 dCBWDataTransferLength;
18 extern data Uint16 hdd_data_length;
19
20
21
22 /////////////////////////////////////////////////////////////////////
23 bit WriteCommand(INT8U u8Command)
24 {
25 1 INT8U u8Try = 0;
26 1
27 1 do
28 1 {
29 2 ACC = FILE7;
30 2 u8Try ++;
31 2 if(u8Try > 250)
32 2 {
33 3 return FALSE;
34 3 }
35 2 }
36 1 while(BSY);
37 1
38 1 FILE7 = u8Command;
39 1 return TRUE;
40 1 }
41
42
43 /////////////////////////////////////////////////////////////////////
44 bit hdd_install(void)
45 {
46 1 AUXR = 0x5c; //设置EXT16=1,使能16-BIT传送模式
47 1 INTQ = 1;
48 1 ARST = 0;
49 1 clock_vDelay(0xff);
50 1 ARST = 1;
51 1
52 1 do
53 1 {
54 2 FILE6 = 0xa0;
C51 COMPILER V7.50 IDE_DRV 02/16/2009 09:59:52 PAGE 2
55 2 ACC = FILE7;
56 2 }
57 1 while(!DRDY | BSY);
58 1 FILE6 = 0x20;
59 1 FILE2 = 64;
60 1 FILE7 = 0x91;
61 1
62 1 do{ACC = FILE7;} while(BSY);
63 1 FILE7 = 0x10;
64 1
65 1 do{ACC = FILE7;} while(BSY);
66 1
67 1 return OK;
68 1 }
69
70
71 /////////////////////////////////////////////////////////////////////
72 void HardDiskSleep(void)
73 {
74 1 do{ACC = FILE7;} while(BSY); //wait for NO busy
75 1 WriteCommand(0xe0); //write command code
76 1 // do{ACC = FILE7;} while(BSY |! DRQ); //wait for noBUSY and data request
77 1 }
78
79
80 /////////////////////////////////////////////////////////////////////
81 bit hdd_read_open(Uint32 hdd_sector)
82 {
83 1 INT16U i = 0;
84 1 INT8U head, cylinderh, cylinderl, sector;
85 1
86 1 u32MediaSector = hdd_sector;
87 1
88 1 head = ((Byte*)&u32MediaSector)[0];
89 1 cylinderh = ((Byte*)&u32MediaSector)[1];
90 1 cylinderl = ((Byte*)&u32MediaSector)[2];
91 1 sector = ((Byte*)&u32MediaSector)[3];
92 1
93 1 do{ACC = FILE7;} while(BSY); //wait for NO busy
94 1
95 1 FILE6 = (0xe0 | (head & 0x0f));
96 1 FILE5 = cylinderh; //high 2-bit cylinder
97 1 FILE4 = cylinderl; //low 8-bit cylinder
98 1 FILE3 = sector; //start sector
99 1 FILE2 = 0x01; //sector counter
100 1 WriteCommand(0x20); //write command code
101 1
102 1 do{ACC = FILE7;} while(BSY |! DRQ); //wait for noBUSY and data request
103 1
104 1 ACC = FILE7;
105 1 if (ERR)
106 1 return KO;
107 1
108 1 for (i=0; i<512; )
109 1 {
110 2 gl_media_buffer[i++] = FILE0;
111 2 gl_media_buffer[i++] = DAT16H;
112 2 gl_media_buffer[i++] = FILE0;
113 2 gl_media_buffer[i++] = DAT16H;
114 2 gl_media_buffer[i++] = FILE0;
115 2 gl_media_buffer[i++] = DAT16H;
116 2 gl_media_buffer[i++] = FILE0;
C51 COMPILER V7.50 IDE_DRV 02/16/2009 09:59:52 PAGE 3
117 2 gl_media_buffer[i++] = DAT16H;
118 2 gl_media_buffer[i++] = FILE0;
119 2 gl_media_buffer[i++] = DAT16H;
120 2 gl_media_buffer[i++] = FILE0;
121 2 gl_media_buffer[i++] = DAT16H;
122 2 gl_media_buffer[i++] = FILE0;
123 2 gl_media_buffer[i++] = DAT16H;
124 2 gl_media_buffer[i++] = FILE0;
125 2 gl_media_buffer[i++] = DAT16H;
126 2 }
127 1
128 1 u16MediaBytePointer = 0;
129 1 bMediaReadOpenFlag = 1;
130 1
131 1 return OK;
132 1 }
133
134 /////////////////////////////////////////////////////////////////////
135 Byte hdd_read_byte(void)
136 {
137 1 INT8U u8Data;
138 1
139 1 if(u16MediaBytePointer >= 512) //a new sector
140 1 {
141 2 u32MediaSector += 1;
142 2 hdd_read_open(u32MediaSector);
143 2 }
144 1
145 1 u8Data = gl_media_buffer[u16MediaBytePointer ++];
146 1 return(u8Data);
147 1 }
148
149
150 /////////////////////////////////////////////////////////////////////
151 bit hdd_read_close(void)
152 {
153 1 u16MediaBytePointer = 0;
154 1 bMediaReadOpenFlag = 0;
155 1 return OK;
156 1 }
157
158
159 /////////////////////////////////////////////////////////////////////
160 bit hdd_read_one_sector(Uint32 hdd_sector)
161 {
162 1 Byte i;
163 1
164 1 if(hdd_read_open(hdd_sector) == OK)
165 1 {
166 2 for (i = 0; i < 8; i++)
167 2 {
168 3 Usb_select_ep(EP_IN);
169 3 /* read 64 bytes from card */
170 3 Usb_write_byte(hdd_read_byte());
171 3 Usb_write_byte(hdd_read_byte());
172 3 Usb_write_byte(hdd_read_byte());
173 3 Usb_write_byte(hdd_read_byte());
174 3 Usb_write_byte(hdd_read_byte());
175 3 Usb_write_byte(hdd_read_byte());
176 3 Usb_write_byte(hdd_read_byte());
177 3 Usb_write_byte(hdd_read_byte());
178 3 Usb_write_byte(hdd_read_byte());
C51 COMPILER V7.50 IDE_DRV 02/16/2009 09:59:52 PAGE 4
179 3 Usb_write_byte(hdd_read_byte());
180 3 Usb_write_byte(hdd_read_byte());
181 3 Usb_write_byte(hdd_read_byte());
182 3 Usb_write_byte(hdd_read_byte());
183 3 Usb_write_byte(hdd_read_byte());
184 3 Usb_write_byte(hdd_read_byte());
185 3 Usb_write_byte(hdd_read_byte());
186 3 Usb_write_byte(hdd_read_byte());
187 3 Usb_write_byte(hdd_read_byte());
188 3 Usb_write_byte(hdd_read_byte());
189 3 Usb_write_byte(hdd_read_byte());
190 3 Usb_write_byte(hdd_read_byte());
191 3 Usb_write_byte(hdd_read_byte());
192 3 Usb_write_byte(hdd_read_byte());
193 3 Usb_write_byte(hdd_read_byte());
194 3 Usb_write_byte(hdd_read_byte());
195 3 Usb_write_byte(hdd_read_byte());
196 3 Usb_write_byte(hdd_read_byte());
197 3 Usb_write_byte(hdd_read_byte());
198 3 Usb_write_byte(hdd_read_byte());
199 3 Usb_write_byte(hdd_read_byte());
200 3 Usb_write_byte(hdd_read_byte());
201 3 Usb_write_byte(hdd_read_byte());
202 3 Usb_write_byte(hdd_read_byte());
203 3 Usb_write_byte(hdd_read_byte());
204 3 Usb_write_byte(hdd_read_byte());
205 3 Usb_write_byte(hdd_read_byte());
206 3 Usb_write_byte(hdd_read_byte());
207 3 Usb_write_byte(hdd_read_byte());
208 3 Usb_write_byte(hdd_read_byte());
209 3 Usb_write_byte(hdd_read_byte());
210 3 Usb_write_byte(hdd_read_byte());
211 3 Usb_write_byte(hdd_read_byte());
212 3 Usb_write_byte(hdd_read_byte());
213 3 Usb_write_byte(hdd_read_byte());
214 3 Usb_write_byte(hdd_read_byte());
215 3 Usb_write_byte(hdd_read_byte());
216 3 Usb_write_byte(hdd_read_byte());
217 3 Usb_write_byte(hdd_read_byte());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -