我用Cy7C64251做了一个HID键盘,目前问题:不能在bois下工作。windows下没问题。接口描述等等都对照了,没问题。
请问有高手做过键盘吗?请指教,谢谢
附上主程序:
void main(void)
{
int temp,i;
M8C_EnableGInt; //Enable Global Interrupts
Timer8_1_EnableInt(); // Enable the Timer8 interrupt
Timer8_1_Start(); // Timer8 Start and initialization
USBFS_Start(0, USB_5V_OPERATION); //Start USBFS Operation using device 0 and with 5V operation
while(!USBFS_bGetConfiguration()); //Wait for Device to enumerate
//Enumeration is completed load endpoint 1. Do not toggle the first time
USBFS_LoadInEP(1, keycode, 8, USB_NO_TOGGLE);
while(!USBFS_bGetEPAckState(1)); //Check and see if ACK has occured
while(!(USBFS_bGetEPState(1) & IN_BUFFER_EMPTY));
USBFS_LoadInEP(1, keycode, 8, USB_TOGGLE);
USBFS_EnableOutEP(2);
while(1)
{
scan();
PRT0DR_BUF&=0xcf;
PRT0DR=PRT0DR_BUF;
temp=PRT0DR&0x07;
if(temp==0x07)
{
if(codeflag==1)
{
for(i=0;i<8;i++)
{
keycode[i]=0;
}
if(USBFS_bGetEPAckState(1)) //Wait for ACK before loading data
{
USBFS_LoadInEP(1, keycode, 8, USB_TOGGLE);
}
for(i=0;i<6;i++)
{
OldInbuf[i]=0;
Inbuf[i]=0;
}
codeflag=0;
}
}
if(USBFS_bGetEPState(2))
{
USBFS_bReadOutEP(2, Buf, 8);
USBFS_EnableOutEP(2);
if(Buf[0]&0x02)
{
PRT0DR_BUF&=0xf7;
PRT0DR=PRT0DR_BUF;
}
else
{
PRT0DR_BUF|=0xcf;
PRT0DR=PRT0DR_BUF;
}
USBFS_EnableOutEP(2);
Delay(4000);
}
}
} |