设为首页 加入收藏

TOP

USB学习笔记连载(二十一):CY7C68013A进行数据传输(一)(一)
2017-10-10 12:22:30 】 浏览:5650
Tags:USB 学习 笔记 连载 二十一 CY7C68013A 进行 数据传输

  官方手册中给出了bulkloop参考例程,此例程是PC从端口2发送出数据,然后从端口6接收到数据,那么根据这个思想,可以进行修改,使得PC机接收到的数据不是从EP2发送过来的,而是从外部逻辑,比如FPGA处送来的数据。那么如何进行修改呢?

//=============================================

void TD_Init(void)             // Called once at startup
{
   BYTE dum;                    // For the LEDS
   CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;    // 48 MHz CPU clock
   // Turn off all 4 LEDS
   dum = D2OFF;
   dum = D3OFF;
   dum = D4OFF;
   dum = D5OFF;

// EP2CFG & EP6CFG configure our two endpoints, EP2-OUT and EP6-IN
// b7:        Valid
// b6:        DIR (0=OUT, 1=IN)
// b[5:4]    Type (01=ISO, 10=BULK, 11=INT)
// b3:        Size (0=512, 1=1024 bytes)
// b2:        0
// b[1:0]    Buffering (00=quad, 10=double, 11=triple)       
//

  EP2CFG = 0xA2;    // Valid, BULK-OUT, 512 byte buffer, double-buffered
  SYNCDELAY;        // Some regs take longer to update, see TRM Section 15.14.                   
  EP6CFG = 0xE2;    // Valid, BULK-IN, 512 byte buffer, double-buffered
  SYNCDELAY;                   

  // OUT endpoints do not come up armed
  // Since the endpoint is double buffered we must write dummy byte counts twice
  EP2BCL = 0x80;      // arm EP2OUT by writing byte count w/skip.
  SYNCDELAY;                   
  EP2BCL = 0x80;    // again
  SYNCDELAY;                   
  // enable dual autopointer feature
  AUTOPTRSETUP |= 0x01;

  USBIE |= bmSOF;                // Enable the SOF IRQ to serve as LED timers
  EPIE = bmEP6IRQ | bmEP2IRQ;    // Enable EP6 and EP2 Interrupts to turn on transfer LEDS
}

//=============================================

void TD_Poll(void)              // Called repeatedly while the device is idle
{
  WORD i;
  WORD count;
//  BYTE dummy_LED2;        // ***For the LED
  BYTE waiting_inpkts;

#ifdef ENABLE_7_SEG_DISPLAY
if(start_7_seg_display)
{
// update 7-seg readout with number of IN packets waiting for transfer to the host
  waiting_inpkts = (EP6CS & 0xF0)>>4;
  EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[waiting_inpkts]));
  EZUSB_WaitForEEPROMWrite(LED_ADDR);
}
#endif

// Trans

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇USB学习笔记连载(二十):FX2LP.. 下一篇Detected confilicting assignmen..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目