本帖最后由 devilzsq 于 2015-6-4 22:33 编辑
EP4和EP8分别作为slavefifo下out/in端点,512 8bit 2x autoout/autoin bulk。
没有i2c模块的情况下fpga正常工作,读写数据正常。
fpga加入i2c模块后,EP2和EP6分别为i2c的out/in端点,此时我连接68013a sda/scl与fpga对应的pin后,烧录iic文件时提示"eeprom was not enabled",各位大神能否帮忙分析下原因。
拜谢!void TD_Init( void )
{
CPUCS = 0x12;
SYNCDELAY;
IFCONFIG = 0xE3;
SYNCDELAY;
PINFLAGSAB = 0xD9;
SYNCDELAY;
PINFLAGSCD = 0xFB;
SYNCDELAY;
EP1OUTCFG = 0xA0;
EP1INCFG = 0xA0;
SYNCDELAY; // see TRM section 15.14
EP2CFG = 0xA2;
SYNCDELAY; //
EP4CFG = 0xA2;
SYNCDELAY; //
EP6CFG = 0xE2;
SYNCDELAY; //
EP8CFG = 0xE2;
SYNCDELAY; //
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY; //
EP4BCL = 0x80;
SYNCDELAY; //
EP2BCL = 0x80; // arm EP4OUT by writing byte count w/skip.
SYNCDELAY; //
EP4BCL = 0x80;
I2CTL &= 0xFE;
FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
SYNCDELAY; // see TRM section 15.14
FIFORESET = 0x04; // reset, FIFO 4
SYNCDELAY; //
FIFORESET = 0x08; // reset, FIFO 8
SYNCDELAY; //
FIFORESET = 0x00; // deactivate NAK-ALL
SYNCDELAY;
EP4FIFOCFG = 0x00;
SYNCDELAY;
EP4FIFOCFG = 0x10; // AUTOOUT=1, WORDWIDE=0
SYNCDELAY; //
EP8FIFOCFG = 0x08; // AUTOIN=1, ZEROLENIN=0, WORDWIDE=0
SYNCDELAY;
OUTPKTEND = 0x84;
SYNCDELAY;
OUTPKTEND = 0x84;
SYNCDELAY;
INPKTEND = 0x88;
SYNCDELAY;
INPKTEND = 0x88;
SYNCDELAY;
}
void TD_Poll( void )
{
if((!(EP2468STAT & bmEP2EMPTY)) && (!(EP2468STAT & bmEP6FULL)))
{
I2CSeq();
SYNCDELAY;
EP2BCL = 0x80;
}
}
I2CSeq()函数代码略长,详见附件
|