void USBOUTDATA_Process ( void)
{
static u32_t *usb_buff = NULL;
switch ( DataOUTBuff[OUTProcIdx].State)
{
case DATA_OUT_STATE_IDLE:
// wait until device is configured, this state is only for startup.
// USBDATA_Init() will start the FSM
break;
case DATA_OUT_STATE_PRIMED:
// wait for data packet from host. When data received the ISR callback
// will set the state to DATA_OUT_STATE_RCVD.
break;
case DATA_OUT_STATE_RCVD:
// data received on buffer X.
// before we will start processing this buffer, prime the other buffer for new transfer
OUTPrimeIdx = OUTProcIdx ^ 1;
DataOUTBuff[OUTPrimeIdx].State = DATA_OUT_STATE_PRIMED;
DcdDataTransfer ( 0, USB_PHYEP_DATA_OUT, (u8_t*)&DataOUTBuff[OUTPrimeIdx].Data[0], 512);
// set this buffer to processing
DataOUTBuff[OUTProcIdx].State = DATA_OUT_STATE_PROC;
usb_buff = &DataOUTBuff[OUTProcIdx].Data[0]; // initialize data pointer
// fall through
// break;
case DATA_OUT_STATE_PROC:
// process data buffer
......
if ( data_finished)
{
// go to other buffer
OUTProcIdx ^= 1;
return;
}
break;
}
}
|