1. TD_Init代码
void TD_Init(void) // Called once at startup
{
// set the CPU clock to 48MHz
CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1);
SYNCDELAY;
IFCONFIG =0x43; //使用外部IFCLK,时钟频率48MHz
//数据读写与时钟同步,SlaveFIFO接口模式
SYNCDELAY;
EP2CFG=0xA0; //EP2为批量输出端点,buffer:512*4
SYNCDELAY;
EP4CFG=0; //EP4禁用
SYNCDELAY;
EP6CFG=0xE0; //EP6为批量输入端点,buffer:512*4
SYNCDELAY;
EP8CFG=0; //EP8禁用
SYNCDELAY;
FIFORESET = 0x80; //activate NAK-ALL to avoid conditions
SYNCDELAY;
FIFORESET = 0x02; //复位FIFO2
SYNCDELAY;
FIFORESET = 0x04; //复位FIFO4
SYNCDELAY;
FIFORESET = 0x06; //复位FIFO6
SYNCDELAY;
FIFORESET = 0x08