📄 f3xx_usb0_standard_requests.lst
字号:
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE F3XX_USB0_STANDARD_REQUESTS
OBJECT MODULE PLACED IN F3xx_USB0_Standard_Requests.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe F3xx_USB0_Standard_Requests.c DB OE LARGE
line level source
1 //-----------------------------------------------------------------------------
2 // F32x_USB0_Standard_Requests.c
3 //-----------------------------------------------------------------------------
4 // Copyright 2005 Silicon Laboratories, Inc.
5 // http://www.silabs.com
6 //
7 // Program Description:
8 //
9 // This source file contains the subroutines used to handle incoming
10 // setup packets. These are called by Handle_Setup in USB_ISR.c and used for
11 // USB chapter 9 compliance.
12 //
13
14 // How To Test: See Readme.txt
15 //
16 //
17 // FID: 3XX000040
18 // Target: C8051F32x
19 // Tool chain: Keil C51 7.50 / Keil EVAL C51
20 // Silicon Laboratories IDE version 2.6
21 // Command Line: See Readme.txt
22 // Project Name: F3xx_MouseExample
23 //
24 //
25 // Release 1.3
26 // - Changes by PD, GP
27 // - Modified Descriptors
28 // - Changed name from USB_Descriptor.c
29 // - 07 December 2005
30 // Release 1.0
31 // -Initial Revision (DM)
32 // -22 NOV 2002
33 //
34
35 //-----------------------------------------------------------------------------
36 // Header Files
37 //-----------------------------------------------------------------------------
38 #include "c8051f3xx.h"
*** WARNING C318 IN LINE 30 OF c8051f3xx.h: can't open file 'c8051f326.h'
39 #include "F3xx_USB0_Register.h"
40 #include "F3xx_USB0_InterruptServiceRoutine.h"
41 #include "F3xx_USB0_Descriptor.h"
42 #include "F3xx_USB0_ReportHandler.h"
43
44 //-----------------------------------------------------------------------------
45 // Variables
46 //-----------------------------------------------------------------------------
47 extern device_descriptor DEVICEDESC; // These are created in F3xx_USB0_Descriptor.h
48 extern unsigned char* STRINGDESCTABLE[];
49
50 // Additional declarations for HID:
51 extern hid_configuration_descriptor HIDCONFIGDESC;
52 extern hid_report_descriptor HIDREPORTDESC;
53
54 extern setup_buffer SETUP; // Buffer for current device request
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 2
55 // information
56 extern unsigned int DATASIZE;
57 extern unsigned int DATASENT;
58 extern unsigned char* DATAPTR;
59
60 // These are response packets used for
61 code unsigned char ONES_PACKET[2] = {0x01, 0x00};
62 // communication with host
63 code unsigned char ZERO_PACKET[2] = {0x00, 0x00};
64
65 extern unsigned char USB0_STATE; // Determines current usb device state
66
67 //-----------------------------------------------------------------------------
68 // Definitions
69 //-----------------------------------------------------------------------------
70 // Redefine existing variable names to refer to the descriptors within the
71 // HID configuration descriptor.
72 // This minimizes the impact on the existing source code.
73 #define ConfigDesc (HIDCONFIGDESC.hid_configuration_descriptor)
74 #define InterfaceDesc (HIDCONFIGDESC.hid_interface_descriptor)
75 #define HidDesc (HIDCONFIGDESC.hid_descriptor)
76 #define Endpoint1Desc (HIDCONFIGDESC.hid_endpoint_in_descriptor)
77 #define Endpoint2Desc (HIDCONFIGDESC.hid_endpoint_out_descriptor)
78
79 //-----------------------------------------------------------------------------
80 // Get_Status
81 //-----------------------------------------------------------------------------
82 //
83 // Return Value - None
84 // Parameters - None
85 //
86 // Standard request that should not change for custom HID designs.
87 //
88 // ----------------------------------------------------------------------------
89 void Get_Status (void) // This routine returns a two byte
90 { // status packet to the host
91 1
92 1 if (SETUP.wValue.c[MSB] || SETUP.wValue.c[LSB] ||
93 1 // If non-zero return length or data
94 1 // length not
95 1 SETUP.wLength.c[MSB] || (SETUP.wLength.c[LSB] != 2))
96 1 // equal to 2 then send a stall
97 1 { // indicating invalid request
98 2 Force_Stall ();
99 2 }
100 1
101 1 switch(SETUP.bmRequestType) // Determine if recipient was device,
102 1 { // interface, or EP
103 2 case OUT_DEVICE: // If recipient was device
104 2 if (SETUP.wIndex.c[MSB] || SETUP.wIndex.c[LSB])
105 2 {
106 3 Force_Stall (); // Send stall if request is invalid
107 3 }
108 2 else
109 2 {
110 3 // Otherwise send 0x00, indicating bus power and no
111 3 // remote wake-up supported
112 3 DATAPTR = (unsigned char*)&ZERO_PACKET;
113 3 DATASIZE = 2;
114 3 }
115 2 break;
116 2
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 3
117 2 case OUT_INTERFACE: // See if recipient was interface
118 2 if ((USB0_STATE != DEV_CONFIGURED) ||
119 2 SETUP.wIndex.c[MSB] || SETUP.wIndex.c[LSB])
120 2 // Only valid if device is configured
121 2 // and non-zero index
122 2 {
123 3 Force_Stall (); // Otherwise send stall to host
124 3 }
125 2 else
126 2 {
127 3 // Status packet always returns 0x00
128 3 DATAPTR = (unsigned char*)&ZERO_PACKET;
129 3 DATASIZE = 2;
130 3 }
131 2 break;
132 2
133 2 case OUT_ENDPOINT: // See if recipient was an endpoint
134 2 if ((USB0_STATE != DEV_CONFIGURED) ||
135 2 SETUP.wIndex.c[MSB]) // Make sure device is configured
136 2 // and index msb = 0x00
137 2 { // otherwise return stall to host
138 3 Force_Stall();
139 3 }
140 2 else
141 2 {
142 3 // Handle case if request is directed to EP 1
143 3 if (SETUP.wIndex.c[LSB] == IN_EP1)
144 3 {
145 4 if (EP_STATUS[1] == EP_HALT)
146 4 { // If endpoint is halted,
147 5 // return 0x01,0x00
148 5 DATAPTR = (unsigned char*)&ONES_PACKET;
149 5 DATASIZE = 2;
150 5 }
151 4 else
152 4 {
153 5 // Otherwise return 0x00,0x00 to indicate endpoint active
154 5 DATAPTR = (unsigned char*)&ZERO_PACKET;
155 5 DATASIZE = 2;
156 5 }
157 4 }
158 3 else
159 3 {
160 4 Force_Stall (); // Send stall if unexpected data
161 4 // encountered
162 4 }
163 3 }
164 2 break;
165 2
166 2 default:
167 2 Force_Stall ();
168 2 break;
169 2 }
170 1 if (EP_STATUS[0] != EP_STALL)
171 1 {
172 2 // Set serviced SETUP Packet, Endpoint 0 in transmit mode, and
173 2 // reset DATASENT counter
174 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
*** ERROR C202 IN LINE 174 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 174 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 174 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
175 2 EP_STATUS[0] = EP_TX;
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 4
176 2 DATASENT = 0;
177 2 }
178 1 }
179
180 //-----------------------------------------------------------------------------
181 // Clear_Feature
182 //-----------------------------------------------------------------------------
183 //
184 // Return Value - None
185 // Parameters - None
186 //
187 // Standard request that should not change in custom HID designs.
188 //
189 //-----------------------------------------------------------------------------
190 void Clear_Feature () // This routine can clear Halt Endpoint
191 { // features on endpoint 1
192 1
193 1 // Send procedural stall if device isn't configured
194 1 if ( (USB0_STATE != DEV_CONFIGURED) ||
195 1 // or request is made to host(remote wakeup not supported)
196 1 (SETUP.bmRequestType == IN_DEVICE) ||
197 1 // or request is made to interface
198 1 (SETUP.bmRequestType == IN_INTERFACE) ||
199 1 // or msbs of value or index set to non-zero value
200 1 SETUP.wValue.c[MSB] || SETUP.wIndex.c[MSB] ||
201 1 // or data length set to non-zero.
202 1 SETUP.wLength.c[MSB] || SETUP.wLength.c[LSB])
203 1 {
204 2 Force_Stall ();
205 2 }
206 1
207 1 else
208 1 {
209 2 // Verify that packet was directed at an endpoint
210 2 if ( (SETUP.bmRequestType == IN_ENDPOINT)&&
211 2 // the feature selected was HALT_ENDPOINT
212 2 (SETUP.wValue.c[LSB] == ENDPOINT_HALT) &&
213 2 // and that the request was directed at EP 1 in
214 2 ((SETUP.wIndex.c[LSB] == IN_EP1) ) )
215 2 {
216 3 if (SETUP.wIndex.c[LSB] == IN_EP1)
217 3 {
218 4 POLL_WRITE_BYTE (INDEX, 1);// Clear feature endpoint 1 halt
*** ERROR C202 IN LINE 218 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 218 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 218 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
219 4 POLL_WRITE_BYTE (EINCSR1, rbInCLRDT);
*** ERROR C202 IN LINE 219 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 219 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 219 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
220 4 EP_STATUS[1] = EP_IDLE; // Set endpoint 1 status back to idle
221 4 }
222 3 }
223 2 else
224 2 {
225 3 Force_Stall (); // Send procedural stall
226 3 }
227 2 }
228 1 POLL_WRITE_BYTE (INDEX, 0); // Reset Index to 0
*** ERROR C202 IN LINE 228 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 228 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 228 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
C51 COMPILER V7.50 F3XX_USB0_STANDARD_REQUESTS 06/22/2006 17:45:49 PAGE 5
229 1 if (EP_STATUS[0] != EP_STALL)
230 1 {
231 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
*** ERROR C202 IN LINE 231 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 231 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0ADR': undefined identifier
*** ERROR C202 IN LINE 231 OF F3XX_USB0_STANDARD_REQUESTS.C: 'USB0DAT': undefined identifier
232 2 // Set Serviced Out packet ready and
233 2 // data end to indicate transaction
234 2 // is over
235 2 }
236 1 }
237
238 //-----------------------------------------------------------------------------
239 // Set_Feature
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -