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