void Get_Report (void)
{
unsigned char test[] = {0x01, 0x02, 0x03, 0x04};
// call appropriate handler to prepare buffer
ReportHandler_IN_ISR(SETUP.wValue.c[LSB]);
// set DATAPTR to buffer used inside Control Endpoint
DATAPTR = test;
DATASIZE = SETUP.wLength.c[LSB];
/*
DATAPTR = IN_BUFFER.Ptr;
DATASIZE = IN_BUFFER.Length;
*/
if (EP_STATUS[0] != EP_STALL)
{
// Set serviced SETUP Packet
POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
EP_STATUS[0] = EP_TX; // Endpoint 0 in transmit mode
DATASENT = 0; // Reset DATASENT counter
}
}
中断里面的处理是这样的
Fifo_Write_InterruptServiceRoutine (FIFO_EP0, DATASIZE, (unsigned char*)DATAPTR);
ControlReg |= rbDATAEND;// Add Data End bit to bitmask
EP_STATUS[0] = EP_IDLE; // Return EP 0 to idle state
还有发送函数
void Fifo_Write_InterruptServiceRoutine (unsigned char addr, unsigned int uNumBytes, unsigned char * pData)
{
int i;
// If >0 bytes requested,
if (uNumBytes)
{
while (USB0ADR & 0x80); // Wait for BUSY->'0'(register available)
USB0ADR = (addr); // Set address (mask out bits7-6)
// Write <NumBytes> to the selected FIFO
for (i=0; i<uNumBytes; i++)
{
USB0DAT = pData;
while (USB0ADR & 0x80); // Wait for BUSY->'0' (data ready)
}
}
}
流程是接收到get_report命令后进入函数,然后进入中断,再fifo_write发送出去
可我接收到的数据不对,只有00和DATASIZE
想问下是什么原因呢? |