xiaoshu = HextoDecxs(x);
sdata = HextoDec(sdata);
//using EP8 to transfer data in
if(!(EP2468STAT & bmEP8FULL))
{
EP8FIFOBUF[ 0 ] = sdata;
EP8FIFOBUF[ 1 ] = xiaoshu;
EP8FIFOBUF[ 2 ] = fg;
SYNCDELAY;
EP8BCH = 0x00;
SYNCDELAY;
EP8BCL = 3;
}
EP0BCH = 0;
EP0BCL = 1;
EP0CS |= bmHSNAK;
*EP0BUF = VX_22;
// Acknowledge handshake phase of device request
break;
}
case VX_33:
{ //
if( !(EP2468STAT & bmEP8FULL))
{
EP8FIFOBUF[ 0 ] = readI2C(0x37);
EP8FIFOBUF[ 1 ] = readI2C(0x36);
EP8FIFOBUF[ 2 ] = readI2C(0x35);
EP8FIFOBUF[ 3 ] = readI2C(0x34);
EP8FIFOBUF[ 4 ] = readI2C(0x33);
EP8FIFOBUF[ 5 ] = readI2C(0x32);
EP8FIFOBUF[ 6 ] = readI2C(0x31);
EP8FIFOBUF[ 7 ] = readI2C(0x30);
}
EP8BCH = 0x00;
SYNCDELAY;
EP8BCL = 8;
SYNCDELAY;
EP0BCH = 0;
EP0BCL = 1; // Arm endpoint with # bytes to transfer
*EP0BUF = VX_33;
EP0CS |= bmHSNAK; // Acknowledge handshake phase of device request
break;
}
case VX_FF:
{ //
IOE = 0xFF;
SYNCDELAY;
EP0BCH = 0;
EP0BCL = 1; // Arm endpoint with # bytes to transfer
EP0CS |= bmHSNAK; // Acknowledge handshake phase of device request
*EP0BUF = VX_FF;
break;
}
default:
{
break;
}
}
return( FALSE ); // no error; command handled OK
}
当然由于篇幅关系,这里没有详细地给出各个部分的详细代码,只给出了调用的函数,详细代码请参考附件:模块综合中。昨天上午编写的代码,编完测试觉得系统完全可以正常工作,当然这是个初步的模型,后面还有很多的器件需要加载在这个控制命令系统上。
(需要说明的是:在CPLD端完全可以加一个LED灯,发一个命令驱动Y[n],Y[n]驱动灯亮,通过灯亮与灭可以知道现在正在工作的是哪一个模块,该模块工作在什么模式下,一目了然。期待进一步的更新)197
文章评论(0条评论)
登录后参与讨论