📄 fx2_to_extsyncfifo.lst
字号:
247 1
248 1
249 1
250 1
251 1 /*
252 1 SYNCDELAY;
253 1
254 1 xFIFOBC_IN = ( ( EP6FIFOBCH << 8 ) + EP6FIFOBCL ); // get EP6FIFOBCH/L value
255 1
256 1 if( xFIFOBC_IN < 0x0200 ) // if pkt is short,
257 1 {
258 1 INPKTEND = 0x06; // force a commit to the host
259 1 }
260 1 */
261 1
262 1 /*
263 1
264 1 if(in_enable) // if IN transfers are enabled,
265 1 {
266 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
267 1 {
268 1 ;
269 1 }
270 1 SYNCDELAY;
271 1 GPIFTCB1 = 0x10;//MSB(Tcount); // setup transaction count with Tcount value
272 1 SYNCDELAY;
273 1 GPIFTCB0 = 0x0;//LSB(Tcount);
274 1 SYNCDELAY;
275 1
276 1 GPIFTRIG = GPIFTRIGRD | GPIF_EP6; // launch GPIF FIFO READ Transaction to EP6IN
277 1 SYNCDELAY;
278 1
279 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 GPIF Done bit
280 1 {
281 1 ;
282 1 }
283 1
284 1 SYNCDELAY;
285 1
286 1 xFIFOBC_IN = ( ( EP6FIFOBCH << 8 ) + EP6FIFOBCL ); // get EP6FIFOBCH/L value
287 1
288 1 if( xFIFOBC_IN < 0x0200 ) // if pkt is short,
289 1 {
290 1 INPKTEND = 0x06; // force a commit to the host
291 1 }
292 1
293 1 LEDIO=0;
294 1 EZUSB_Delay(30);
295 1 LEDIO=1;
296 1 EZUSB_Delay(30);
297 1 cmd_buffer[0]='R';
298 1 WriteCMD_GPIF(cmd_buffer);
299 1 in_enable=0;
300 1 EX0 = 1;
301 1 }
302 1 */
C51 COMPILER V7.20 FX2_TO_EXTSYNCFIFO 03/12/2008 15:34:04 PAGE 6
303 1
304 1 }
305
306
307 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
308 {
309 1 return(TRUE);
310 1 }
311
312 BOOL TD_Resume(void) // Called after the device resumes
313 {
314 1 return(TRUE);
315 1 }
316
317 //-----------------------------------------------------------------------------
318 // Device Request hooks
319 // The following hooks are called by the end point 0 device request parser.
320 //-----------------------------------------------------------------------------
321
322 BOOL DR_GetDescriptor(void)
323 {
324 1 return(TRUE);
325 1 }
326
327 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
328 {
329 1 if( EZUSB_HIGHSPEED( ) )
330 1 { // FX2 enumerated at high speed
331 2 SYNCDELAY; //
332 2 EP6AUTOINLENH = 0x02; // set AUTOIN commit length to 512 bytes
333 2 SYNCDELAY; //
334 2 EP6AUTOINLENL = 0x00;
335 2 SYNCDELAY;
336 2 enum_high_speed = TRUE;
337 2 }
338 1 else
339 1 { // FX2 enumerated at full speed
340 2 SYNCDELAY;
341 2 EP6AUTOINLENH = 0x00; // set AUTOIN commit length to 64 bytes
342 2 SYNCDELAY;
343 2 EP6AUTOINLENL = 0x40;
344 2 SYNCDELAY;
345 2 enum_high_speed = FALSE;
346 2 }
347 1
348 1 Configuration = SETUPDAT[2];
349 1 return(TRUE); // Handled by user code
350 1 }
351
352 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
353 {
354 1 EP0BUF[0] = Configuration;
355 1 EP0BCH = 0;
356 1 EP0BCL = 1;
357 1 return(TRUE); // Handled by user code
358 1 }
359
360 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
361 {
362 1 AlternateSetting = SETUPDAT[2];
363 1 return(TRUE); // Handled by user code
364 1 }
C51 COMPILER V7.20 FX2_TO_EXTSYNCFIFO 03/12/2008 15:34:04 PAGE 7
365
366 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
367 {
368 1 EP0BUF[0] = AlternateSetting;
369 1 EP0BCH = 0;
370 1 EP0BCL = 1;
371 1 return(TRUE); // Handled by user code
372 1 }
373
374 BOOL DR_GetStatus(void)
375 {
376 1 return(TRUE);
377 1 }
378
379 BOOL DR_ClearFeature(void)
380 {
381 1 return(TRUE);
382 1 }
383
384 BOOL DR_SetFeature(void)
385 {
386 1 return(TRUE);
387 1 }
388
389
390 #define VR_UPLOAD 0xc0
391 #define VR_DOWNLOAD 0x40
392 #define VR_CONFIGNUMB 0xB2
393 #define VR_RD_CONFIGNUMB 0xB3
394 #define VR_USRCMD 0xB4
395 #define VR_LEDON 0xB5
396 #define VR_LEDOFF 0xB6
397
398 BOOL DR_VendorCmnd(void)
399 {
400 1
401 1 switch (SETUPDAT[1])
402 1 {
403 2 case VR_CONFIGNUMB:
404 2 *EP0BUF = VR_CONFIGNUMB;
405 2 ConfigNumb=0;
406 2 ConfigNumb=SETUPDAT[2];
407 2 ConfigNumb<<=8;
408 2 ConfigNumb|=SETUPDAT[3];
409 2 if(ConfigNumb>0)
410 2 { nCONFIG=0;
411 3 EZUSB_Delay(200);
412 3 nCONFIG=1;
413 3 EZUSB_Delay(400);
414 3 if(nSTATUS)
415 3 {LEDIO=0;
416 4 EZUSB_Delay(400);
417 4 LEDIO=1;
418 4 }
419 3 else
420 3 LEDIO=0;
421 3
422 3 }
423 2
424 2 EP0BCH = 0;
425 2 EP0BCL = 1;
426 2 EP0CS |= bmHSNAK;
C51 COMPILER V7.20 FX2_TO_EXTSYNCFIFO 03/12/2008 15:34:04 PAGE 8
427 2 break;
428 2 case VR_RD_CONFIGNUMB:
429 2
430 2 *(EP0BUF)= (BYTE)(ConfigNumb>>8);
431 2 *(EP0BUF+1)=(BYTE)(ConfigNumb);
432 2 *(EP0BUF+2)= (BYTE)(RxdCounter>>8);
433 2 *(EP0BUF+3)=(BYTE)(RxdCounter);
434 2 *(EP0BUF+4)=rxd_len;
435 2 *(EP0BUF+5)= TrigSite_H;
436 2 *(EP0BUF+6)=TrigSite_L;
437 2
438 2 EP0BCH = 0;
439 2 EP0BCL =7;
440 2 EP0CS |= bmHSNAK;
441 2 break;
442 2 case VR_LEDON:
443 2 *EP0BUF = VR_LEDON;
444 2 LEDIO=0;
445 2 nCONFIG=0;
446 2 EP0BCH = 0;
447 2 EP0BCL = 1;
448 2 EP0CS |= bmHSNAK;
449 2 break;
450 2
451 2 case VR_LEDOFF:
452 2 *EP0BUF = VR_LEDOFF;
453 2 nCONFIG=1;
454 2 LEDIO=1;
455 2 EP0BCH = 0;
456 2 EP0BCL = 1;
457 2 EP0CS |= bmHSNAK;
458 2 break;
459 2
460 2 case VR_USRCMD:
461 2 rxd_len=SETUPDAT[2];
462 2 if(SETUPDAT[0] == VR_DOWNLOAD)
463 2 { EP0BCH = 0;
464 3 EP0BCL = 0; // Clear bytecount to allow new data in; also stops NAKing
465 3 while(EP0CS & bmEPBUSY);
466 3 if(*EP0BUF=='R'){
467 4 in_enable=1;
468 4 }else
469 3 if(*EP0BUF=='P'){
470 4 in_enable=0;}
471 3
472 3 WriteCMD_GPIF(EP0BUF);
473 3
474 3
475 3 }
476 2 break;
477 2 default:
478 2 return(TRUE);
479 2 }
480 1
481 1 return(FALSE);
482 1 }
483
484 //-----------------------------------------------------------------------------
485 // USB Interrupt Handlers
486 // The following functions are called by the USB interrupt jump table.
487 //-----------------------------------------------------------------------------
488
C51 COMPILER V7.20 FX2_TO_EXTSYNCFIFO 03/12/2008 15:34:04 PAGE 9
489 // Setup Data Available Interrupt Handler
490 void ISR_Sudav(void) interrupt 0
491 {
492 1 GotSUD = TRUE; // Set flag
493 1 EZUSB_IRQ_CLEAR();
494 1 USBIRQ = bmSUDAV; // Clear SUDAV IRQ
495 1
496 1 }
497
498 // Setup Token Interrupt Handler
499 void ISR_Sutok(void) interrupt 0
500 {
501 1 EZUSB_IRQ_CLEAR();
502 1 USBIRQ = bmSUTOK; // Clear SUTOK IRQ
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -