📄 ideio.lst
字号:
C51 COMPILER V7.50 IDEIO 06/03/2006 10:32:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE IDEIO
OBJECT MODULE PLACED IN ideio.obj
COMPILER INVOKED BY: C:\Program Files\keil\C51\BIN\C51.EXE lib_mcu\ide\ideio.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\i
-deio.lst) OBJECT(ideio.obj)
line level source
1 /*C**************************************************************************
2 * NAME: ideio.c
3 *----------------------------------------------------------------------------
4 * Copyright (c) 2003 Atmel.
5 *----------------------------------------------------------------------------
6 * RELEASE: snd1c-refd-nf-4_0_3
7 * REVISION: 1.21
8 *----------------------------------------------------------------------------
9 * PURPOSE:
10 *
11 *****************************************************************************/
12
13
14 /*_____ I N C L U D E S ____________________________________________________*/
15 #include "config.h" /* system configuration */
16 #include "ideio.h"
17 #include "..\usb\usb_drv.h" /* usb driver definition */
18 #include "lib_mcu\lcd\lcd_drv.h" /* c51 driver definition */
19 #include "lib_mcu\serial\serial.h"
20
21 #define Usb_clear_RXOUTB0() {if(UEPSTAX & 0x42) UEPSTAX &= 0xbd;}
22
23 extern bdata bit gl_hdd_buffer_flag;
24 extern xdata Byte gl_hdd_buffer[512];
25 extern xdata uint gl_hdd_buffer_ptr; //hdd_buffer[]的序列号
26 extern data Uint32 dCBWDataTransferLength;
27 extern data Uint16 hdd_data_length;
28
29 data Uint32 hdd_current_sector;
30
31 /*bit ata_install(void);
32 bit hdd_uninstall(void);
33 bit hdd_read_open(Uint32);
34 bit hdd_read_close(void);
35 Byte hdd_read_byte(void);
36 bit hdd_write_open(Uint32);
37 bit hdd_write_close(void);
38 bit hdd_write_byte(Byte);
39 bit hdd_read_long_big_endian(void);
40 bit hdd_read_one_sector(void);
41 bit hdd_write_one_sector(void);
42 s_format *hdd_format(void);
43 extern Uint32 (hdd_mem_size);*/
44
45
46 /**********************************************************
47 *函数名称:void DriveID(void) *
48 *用途:读硬盘ID *
49 ***********************************************************/
50 /*void DriveID(void)
51 {uint i=512;
52 do{ACC=FILE7;}while(BSY);
53 FILE7=0xec;
54 do{ACC=FILE7;}while(BSY|!DRQ);
C51 COMPILER V7.50 IDEIO 06/03/2006 10:32:52 PAGE 2
55 while(i){ReadData();i-=2;}
56 }*/
57
58 extern void usb_mass_storage_csw (void);
59
60
61 /*********************************************************
62 *函数名称:WriteCommand(command) *
63 *函数用途:写命令 *
64 **********************************************************/
65 WriteCommand(command)
66 {do{ACC = FILE7;}while(BSY);
67 1 FILE7 = command;
68 1 }
69
70 /**********************************************************
71 *函数名称:bit ata_install(void) *
72 *用途:初始化硬盘 *
73 ***********************************************************/
74 bit ata_install(void)
75 {
76 1 ARST = 0;
77 1 ARST = 1;
78 1
79 1 AUXR = 0x5c; //设置EXT16=1,使能16-BIT传送模式
80 1
81 1 do{FILE6 = 0xa0; ACC = FILE7;} while(!DRDY | BSY);
82 1 FILE6 = 0x20;
83 1 FILE2 = 64;
84 1 FILE7 = 0x91;
85 1 do{ACC = FILE7;} while(BSY);
86 1 FILE7 = 0x10;
87 1 do{ACC = FILE7;} while(BSY);
88 1
89 1 return OK;
90 1 }
91
92 /**********************************************************
93 *函数名称:HardDiskSleep(void) *
94 *用途:硬盘休眠 *
95 ***********************************************************/
96 void HardDiskSleep(void)
97 {
98 1 do{ACC = FILE7;} while(BSY); //wait for NO busy
99 1 WriteCommand(0xe0); //write command code
100 1 do{ACC = FILE7;} while(BSY |! DRQ); //wait for noBUSY and data request
101 1 }
102 /**********************************************************
103 *函数名称:bit hdd_read_open(Uint32 hdd_sector) *
104 *用途:读硬盘OPEN动作 *
105 ***********************************************************/
106 bit hdd_read_open(Uint32 hdd_sector)
107 {
108 1 uint i = 0;
109 1 uchar head,cylinderh,cylinderl,sector;
110 1 hdd_current_sector = hdd_sector;
111 1 head = ((Byte*)&hdd_current_sector)[0];
112 1 cylinderh = ((Byte*)&hdd_current_sector)[1];
113 1 cylinderl = ((Byte*)&hdd_current_sector)[2];
114 1 sector = ((Byte*)&hdd_current_sector)[3];
115 1 do{ACC = FILE7;} while(BSY); //wait for NO busy
116 1 FILE6 = (0xe0 | (head & 0x0f));
C51 COMPILER V7.50 IDEIO 06/03/2006 10:32:52 PAGE 3
117 1 FILE5 = cylinderh; //high 2-bit cylinder
118 1 FILE4 = cylinderl; //low 8-bit cylinder
119 1 FILE3 = sector; //start sector
120 1 FILE2 = 0x01; //sector counter
121 1 WriteCommand(0x20); //write command code
122 1
123 1 do{ACC = FILE7;} while(BSY |! DRQ); //wait for noBUSY and data request
124 1
125 1 ACC = FILE7;
126 1 if (ERR)
127 1 return KO;
128 1
129 1 for (i = 0; i<512;)
130 1 {
131 2 gl_hdd_buffer[i++]=FILE0;
132 2 gl_hdd_buffer[i++]=DAT16H;
133 2 }
134 1
135 1 gl_hdd_buffer_ptr = 0;
136 1 gl_hdd_buffer_flag = 1;
137 1 return OK;
138 1
139 1 }
140
141
142 /**********************************************************
143 *函数名称:Byte hdd_read_byte(void) *
144 *用途:读硬盘缓存中的一个字节 *
145 ***********************************************************/
146 Byte hdd_read_byte(void)
147 {
148 1 gl_hdd_buffer_ptr++;
149 1
150 1 if (gl_hdd_buffer_ptr > 512)
151 1 {
152 2 gl_hdd_buffer_ptr = 0;
153 2 hdd_current_sector +=1;
154 2 hdd_read_open(hdd_current_sector);
155 2 gl_hdd_buffer_ptr++;
156 2 }
157 1
158 1 return (gl_hdd_buffer[gl_hdd_buffer_ptr - 1]);
159 1 }
160
161
162 /**********************************************************
163 *函数名称:bit hdd_read_close(void) *
164 *用途:读硬盘CLOSE动作 *
165 ***********************************************************/
166 bit hdd_read_close(void)
167 {
168 1 gl_hdd_buffer_flag = 0;
169 1 gl_hdd_buffer_ptr = 0;
170 1 return OK;
171 1 }
172
173
174 /**********************************************************
175 *函数名称:bit hdd_read_one_sector(Uint32 hdd_sector) *
176 *用途:将硬盘中一个扇区的数据送入USB接口 *
177 ***********************************************************/
178 bit hdd_read_one_sector(Uint32 hdd_sector)
C51 COMPILER V7.50 IDEIO 06/03/2006 10:32:52 PAGE 4
179 {Byte i;
180 1
181 1 if (hdd_read_open(hdd_sector) == OK)
182 1 {
183 2 for (i = 0; i < 8; i++)
184 2 {
185 3 Usb_select_ep(EP_IN);
186 3 /* read 64 bytes from card */
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());
218 3 Usb_write_byte(hdd_read_byte());
219 3 Usb_write_byte(hdd_read_byte());
220 3 Usb_write_byte(hdd_read_byte());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -