?? fw.lst
字號(hào):
185 1 // clear the Sleep flag.
186 1 Sleep = FALSE;
187 1
188 1 // Task Dispatcher
189 1 while(TRUE) // Main Loop
190 1 {
191 2 if(GotSUD) // Wait for SUDAV
192 2 {
193 3 SetupCommand(); // Implement setup command
194 3 GotSUD = FALSE; // Clear SUDAV flag
195 3 }
196 2
197 2 // Poll User Device
198 2 // NOTE: Idle mode stops the processor clock. There are only two
199 2 // ways out of idle mode, the WAKEUP pin, and detection of the USB
200 2 // resume state on the USB bus. The timers will stop and the
201 2 // processor will not wake up on any other interrupts.
202 2 if (Sleep)
203 2 {
204 3 if(TD_Suspend())
205 3 {
206 4 Sleep = FALSE; // Clear the "go to sleep" flag. Do it here to prevent any race c
-ondition between wakeup and the next sleep.
207 4 do
208 4 {
209 5 EZUSB_Susp(); // Place processor in idle mode.
210 5 }
211 4 while(!Rwuen && EZUSB_EXTWAKEUP());
212 4 // Must continue to go back into suspend if the host has disabled remote wakeup
213 4 // *and* the wakeup was caused by the external wakeup pin.
214 4
215 4 // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
216 4 EZUSB_Resume(); // If source is the Wakeup# pin, signal the host to Resume.
217 4 TD_Resume();
218 4 }
219 3 }
220 2 TD_Poll();
221 2 }
222 1 }
223
224 // Device request parser
225 void SetupCommand(void)
226 {
227 1 void *dscr_ptr;
228 1
229 1 switch(SETUPDAT[1])
230 1 {
231 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
232 2 if(DR_GetDescriptor())
233 2 switch(SETUPDAT[3])
234 2 {
235 3 case GD_DEVICE: // Device
236 3 SUDPTRH = MSB(pDeviceDscr);
237 3 SUDPTRL = LSB(pDeviceDscr);
238 3 break;
239 3 case GD_DEVICE_QUALIFIER: // Device Qualifier
240 3 SUDPTRH = MSB(pDeviceQualDscr);
C51 COMPILER V8.05a FW 02/09/2009 15:21:59 PAGE 5
241 3 SUDPTRL = LSB(pDeviceQualDscr);
242 3 break;
243 3 case GD_CONFIGURATION: // Configuration
244 3 SUDPTRH = MSB(pConfigDscr);
245 3 SUDPTRL = LSB(pConfigDscr);
246 3 break;
247 3 case GD_OTHER_SPEED_CONFIGURATION: // Other Speed Configuration
248 3 SUDPTRH = MSB(pOtherConfigDscr);
249 3 SUDPTRL = LSB(pOtherConfigDscr);
250 3 break;
251 3 case GD_STRING: // String
252 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
253 3 {
254 4 SUDPTRH = MSB(dscr_ptr);
255 4 SUDPTRL = LSB(dscr_ptr);
256 4 }
257 3 else
258 3 EZUSB_STALL_EP0(); // Stall End Point 0
259 3 break;
260 3 default: // Invalid request
261 3 EZUSB_STALL_EP0(); // Stall End Point 0
262 3 }
263 2 break;
264 2 case SC_GET_INTERFACE: // *** Get Interface
265 2 DR_GetInterface();
266 2 break;
267 2 case SC_SET_INTERFACE: // *** Set Interface
268 2 DR_SetInterface();
269 2 break;
270 2 case SC_SET_CONFIGURATION: // *** Set Configuration
271 2 DR_SetConfiguration();
272 2 break;
273 2 case SC_GET_CONFIGURATION: // *** Get Configuration
274 2 DR_GetConfiguration();
275 2 break;
276 2 case SC_GET_STATUS: // *** Get Status
277 2 if(DR_GetStatus())
278 2 switch(SETUPDAT[0])
279 2 {
280 3 case GS_DEVICE: // Device
281 3 EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
282 3 EP0BUF[1] = 0;
283 3 EP0BCH = 0;
284 3 EP0BCL = 2;
285 3 break;
286 3 case GS_INTERFACE: // Interface
287 3 EP0BUF[0] = 0;
288 3 EP0BUF[1] = 0;
289 3 EP0BCH = 0;
290 3 EP0BCL = 2;
291 3 break;
292 3 case GS_ENDPOINT: // End Point
293 3 EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
294 3 EP0BUF[1] = 0;
295 3 EP0BCH = 0;
296 3 EP0BCL = 2;
297 3 break;
298 3 default: // Invalid Command
299 3 EZUSB_STALL_EP0(); // Stall End Point 0
300 3 }
301 2 break;
302 2 case SC_CLEAR_FEATURE: // *** Clear Feature
C51 COMPILER V8.05a FW 02/09/2009 15:21:59 PAGE 6
303 2 if(DR_ClearFeature())
304 2 switch(SETUPDAT[0])
305 2 {
306 3 case FT_DEVICE: // Device
307 3 if(SETUPDAT[2] == 1)
308 3 Rwuen = FALSE; // Disable Remote Wakeup
309 3 else
310 3 EZUSB_STALL_EP0(); // Stall End Point 0
311 3 break;
312 3 case FT_ENDPOINT: // End Point
313 3 if(SETUPDAT[2] == 0)
314 3 {
315 4 *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
316 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
317 4 }
318 3 else
319 3 EZUSB_STALL_EP0(); // Stall End Point 0
320 3 break;
321 3 }
322 2 break;
323 2 case SC_SET_FEATURE: // *** Set Feature
324 2 if(DR_SetFeature())
325 2 switch(SETUPDAT[0])
326 2 {
327 3 case FT_DEVICE: // Device
328 3 if(SETUPDAT[2] == 1)
329 3 Rwuen = TRUE; // Enable Remote Wakeup
330 3 else if(SETUPDAT[2] == 2)
331 3 // Set Feature Test Mode. The core handles this request. However, it is
332 3 // necessary for the firmware to complete the handshake phase of the
333 3 // control transfer before the chip will enter test mode. It is also
334 3 // necessary for FX2 to be physically disconnected (D+ and D-)
335 3 // from the host before it will enter test mode.
336 3 break;
337 3 else
338 3 EZUSB_STALL_EP0(); // Stall End Point 0
339 3 break;
340 3 case FT_ENDPOINT: // End Point
341 3 *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
342 3 break;
343 3 }
344 2 break;
345 2 default: // *** Invalid Command
346 2 if(DR_VendorCmnd())
347 2 EZUSB_STALL_EP0(); // Stall End Point 0
348 2 }
349 1
350 1 // Acknowledge handshake phase of device request
351 1 EP0CS |= bmHSNAK;
352 1 }
353
354 // Wake-up interrupt handler
355 void resume_isr(void) interrupt WKUP_VECT
356 {
357 1 EZUSB_CLEAR_RSMIRQ();
358 1 }
359
360
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 989 ----
C51 COMPILER V8.05a FW 02/09/2009 15:21:59 PAGE 7
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 14 16
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -