cy7c68001的usb产品设计
0赞
发表于 12/20/2013 4:35:10 PM
阅读(4687)
tms320f28335+cy7c68001 usb产品设计
CY7C68001是用来连接微处理器或DSP的DMA从装置,其内部不含微处理器;集成有USB2.0收发器(物理层)、USB2.0串行接口引擎SIE(链路层、实现底层通信协议)、4kB的FIFO和电压调节器、锁相环;支持高速(480Mb/s)或全速(12Mb/s)传输;3.3V操作电压,24MHz外部振荡频率;可以选择8位或16位总线方式;具有同步与异步的FIFO接口;他可以向用户提供足够的端口,缓冲区和传输速度,提供USB2.0协议要求的全部4种传输方式(控制传输、中断传输、批量传输和同步传输),可以满足用户对各种类型数据传输的需求。片上的串行接口处理器(SIE)能完成大部分的USB协议操作,使用户可以摆脱复杂的协议细节,简化了用户配置代码,加快了程序开发过程。但是由于采用的是不带MCU内核的USB接口芯片,USB的应用层协议应该由TMS320VC5416编程实现,USB固件的加载必须靠DSP控制CY7C68001完成。
tms320f28335和cy7c68001的硬件连接:
寄存器读写地址为0x280000,代码如下:
/**********************************************************************************/
BOOL Write_SX2reg(unsigned char addr, unsigned int value)
{
unsigned int transovertime = 0 ;
/*clear the high two bit of the addr*/
addr = addr & 0x3f;
/* write register address to the SX2 */
if(!SX2_comwritebyte(0x80 | addr))
{
return FALSE;
}
/* write high nibble of register data */
SX2_comwritebyte((value >> 4) & 0xF);
/* write low nibble of register data */
SX2_comwritebyte(value & 0x0F);
/*wait the ready is ok*/
transovertime = 0;
while(USB_READY == 0 )
{
if( transovertime++ > usbtimeout )
{
return FALSE;
}
}
/*the write is ok*/
return TRUE;
}
/**********************************************************************************/
/* Function: SX2_comwritebyte */
/* Purpose: Writes to a SX2 command interface */
/* Input: value - value to write to address */
/* Output: TRUE on success */
/* FALSE on failure */
/**********************************************************************************/
BOOL SX2_comwritebyte(unsigned int value)
{
unsigned int time_count = 0;
/*wait the ready is ok*/
while(USB_READY ==0 )
{
if( time_count++ > usbtimeout )
{
return FALSE;
}
}
*USB_COMMAND = value;
/*the write is ok*/
return TRUE;
}
/**********************************************************
*
* Function: Read_SX2reg
* Purpose: Reads a SX2 register
* Input: addr - address of register
* value - value read from register
* Output: TRUE on success
* FALSE on failure
*
**********************************************************/
BOOL Read_SX2reg(unsigned char addr, unsigned int *value)
{
unsigned int transovertime = 0;
/*READY是否准备好,延时时间到,返回*/
while(USB_READY == 0 )
{
if( transovertime++ > usbtimeout )
{
return FALSE;
}
}
/*设置读标志,通知中断程序不做处理读中断,只要返回标志为假就可以了*/
readFlag = TRUE;
/*clear the high two bit of the addr*/
addr = addr & 0x3f;
/* write 'read register' command to SX2 */
*USB_COMMAND = 0xC0 | addr;
/* set read flag to indicate to the interrupt routine that we
are expecting an interrupt to read back the contents of the
addressed register. The interrupt latency of the SX2 is in
tens of microseconds, so it's safe to write this flag after
the initial 'read' byte is written. */
/* wait for read flag to be cleared by an interrupt */
/*等待读标志为假*/
while(1)
{
if(readFlag == FALSE)
{
break;
}
}
/*wait the ready is ok*/
while(USB_READY == 0 )
{
if( transovertime++ > usbtimeout )
{
return FALSE;
}
}
/*读取寄存器的数据*/
*value = *USB_COMMAND;
return TRUE;
}
固件流程:
