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