?? ufi.lst
字號:
C51 COMPILER V8.05a UFI 05/22/2009 15:28:38 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE UFI
OBJECT MODULE PLACED IN UFI.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE UFI.C BROWSE INCDIR(.\INCLUDE;D:\ch9\include\) DEBUG OBJECTEXTEND
line level source
1 /**************************************************************************
2 * H E A D E R F I L E S
3 *************************************************************************/
4 #include <reg51.h>
5 #include <intrins.h>
6 #include <stdio.h>
7 #include "AT89C51SND.h"
8 #include "typedef.h"
9 #include "config.h"
10 #include "constant.h"
11 #include "global.h"
12 #include "gpio.h"
13 #include "macro.h"
14 #include "external.h"
15 #include "usb.h"
16
17 /**************************************************************************
18 * C O N S T A N T S
19 *************************************************************************/
20
21 /**************************************************************************
22 * M A C R O S
23 *************************************************************************/
24
25 /**************************************************************************
26 * D A T A T Y P E S
27 *************************************************************************/
28
29 /**************************************************************************
30 * G L O B A L D A T A
31 *************************************************************************/
32 //answer for UFI inquery command
33 UINT8 code ATAInquiryData[] =
34 {
35 0x00,0x00,0x00,0x01,0x1F,0,0,0, //peripheral device type=0x00,RMB=0,ANSI=0,RESPONSE DATAFORMA
-T=1,Direct-access device
36 'w','e','i','c','h','i','n','g', //8 bytes for Vendor Information
37 'U','S','B',' ','D','E','V','I','C','E',' ',' ',' ',' ',' ',' ', //16 bytes for Product Information
38 ' ',' ',' ',' ', //4 bytes for Product Revision
39
40 };
41
42 /**************************************************************************
43 * Function Name:
44 *
45 * Descriptions:
46 *
47 * Arguments:
48 *
49 * Returns: None
50 **************************************************************************/
51 void dmaCopyIn(UINT16 u16Offset, UINT8 *pu8Buf, UINT8 u8Size)
52 {
53 1 UINT8 i ;
54 1 u16Offset=0;
C51 COMPILER V8.05a UFI 05/22/2009 15:28:38 PAGE 2
55 1 for(i=0; i<u8Size; i++) UEPDATX= *(pu8Buf++) ;
56 1 }
57
58 /**************************************************************************
59 * Function Name:
60 *
61 * Descriptions:
62 *
63 * Arguments:
64 *
65 * Returns: None
66 **************************************************************************/
67 UINT8 ufiInquiry(void)
68 {
69 1 UINT8 TransLength;
70 1
71 1 Usb_sel_ep(1);
72 1 if(gCBWDataLen>36)
73 1 TransLength=36;
74 1 else
75 1 TransLength=gCBWDataLen;
76 1
77 1 dmaCopyIn(0, ATAInquiryData,TransLength);
78 1 Usb_set_TXRDY_bit();
79 1 while (!(Usb_tx_complete_bit()));
80 1 Usb_clear_TXCMPL_bit();
81 1 gCBWDataLen-=TransLength;
82 1 return (0);
83 1
84 1 }
85
86 /**************************************************************************
87 * Function Name:
88 *
89 * Descriptions:
90 *
91 * Arguments:
92 *
93 * Returns: None
94 **************************************************************************/
95 UINT8 ufiRead10(void)
96 {
97 1 UINT8 Status ;
98 1 gbUsbReadError=0;//for Request Sense
99 1
100 1 Status=stReadSectors(gCmdBlock.CB1.LUN,gCmdBlock.CB1.LBA.ULONG, gCmdBlock.CB1.Length2.INTEGER) ;
101 1
102 1 if(Status)
103 1 {
104 2 if(gCBWDataLen!=0)//SEND NULL DATA IN BULK-IN ENDPOINT.
105 2 {
106 3 Usb_set_TXRDY_bit();
107 3 while (!(Usb_tx_complete_bit()));
108 3 Usb_clear_TXCMPL_bit();
109 3 }
110 2 gCBWDataLen=gOrgCBWDataLen;
111 2 gbUsbReadError=1;
112 2 }
113 1
114 1 return(Status);
115 1 }
116 /**************************************************************************
C51 COMPILER V8.05a UFI 05/22/2009 15:28:38 PAGE 3
117 * Function Name:
118 *
119 * Descriptions:
120 *
121 * Arguments:
122 *
123 * Returns: None
124 **************************************************************************/
125 UINT8 ufiWrite10(void)
126 {
127 1 UINT8 Status;
128 1 gbUsbWriteError=0;
129 1
130 1 Status=stWriteSectors(gCmdBlock.CB1.LUN, gCmdBlock.CB1.LBA.ULONG, gCmdBlock.CB1.Length2.INTEGER) ;
131 1 if(Status)
132 1 {
133 2 if(gCBWDataLen!=0)//STALL ENDPOINT2
134 2 {
135 3
136 3 Usb_sel_ep(2);
137 3 Usb_set_STALLRQ();
138 3 }
139 2 gCBWDataLen=gOrgCBWDataLen;
140 2 gbUsbWriteError=1;
141 2 }
142 1 return(Status);
143 1 }
144
145 /**************************************************************************
146 * Function Name:
147 *
148 * Descriptions:
149 *
150 * Arguments:
151 *
152 * Returns: None
153 **************************************************************************/
154 UINT8 ufiRequestSense(void)
155 {
156 1 Usb_sel_ep(1);
157 1 UEPDATX=0x70;
158 1 UEPDATX=0x00;
159 1 UEPDATX=0x05;
160 1 UEPDATX=0x00;
161 1 UEPDATX=0x00;
162 1 UEPDATX=0x00;
163 1 UEPDATX=0x00;
164 1 UEPDATX=0x0a;
165 1 UEPDATX=0x00;
166 1 UEPDATX=0x00;
167 1 UEPDATX=0x00;
168 1 UEPDATX=0x00;
169 1 UEPDATX=0x24;
170 1 UEPDATX=0x00;
171 1 UEPDATX=0x00;
172 1 UEPDATX=0x00;
173 1 UEPDATX=0x00;
174 1 UEPDATX=0x00;
175 1
176 1 Usb_set_TXRDY_bit();
177 1 while (!(Usb_tx_complete_bit()));
178 1 Usb_clear_TXCMPL_bit();
C51 COMPILER V8.05a UFI 05/22/2009 15:28:38 PAGE 4
179 1 gCBWDataLen=0;
180 1 return (0);
181 1 }
182
183 /**************************************************************************
184 * Function Name:
185 *
186 * Descriptions:
187 *
188 * Arguments:
189 *
190 * Returns: None
191 **************************************************************************/
192 UINT8 ufiReadCapacity(void)
193 {
194 1 LongByte BAddr,TotalSectors;
195 1 Usb_sel_ep(1);
196 1 TotalSectors.ULONG =stGetCapacity(gCmdBlock.CB1.LUN) ;
197 1 if(TotalSectors.ULONG==0)
198 1 BAddr.ULONG = 0;
199 1 else
200 1 BAddr.ULONG = TotalSectors.ULONG-1; //Last Logical Block Address
201 1
202 1 UEPDATX= BAddr.BYTE.B3 ; //(J)LBA range
203 1 UEPDATX= BAddr.BYTE.B2 ;
204 1 UEPDATX= BAddr.BYTE.B1 ;
205 1 UEPDATX= BAddr.BYTE.B0 ;
206 1 //Block Length In Bytes
207 1 UEPDATX= 0x00 ; //(J)Block length=512 bytes
208 1 UEPDATX= 0x00 ;
209 1 UEPDATX= 0x02 ;
210 1 UEPDATX= 0x00 ;
211 1 Usb_set_TXRDY_bit();
212 1 while (!(Usb_tx_complete_bit()));
213 1 Usb_clear_TXCMPL_bit();
214 1 gCBWDataLen=0;
215 1
216 1 if(TotalSectors.ULONG==0) return(1);
217 1 else return(0);
218 1
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -