/******************************************************************************* * Function Name : DataStageIn. * Description : Data stage of a Control Read Transfer. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DataStageIn(void) { ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info; u32 save_wLength = pEPinfo->Usb_wLength; u32 ControlState = pInformation->ControlState; u8 *DataBuffer; u32 Length; if ((save_wLength == 0) && (ControlState == LAST_IN_DATA)) { /* no more data to send so STALL the TX Status*/ ControlState = WAIT_STATUS_OUT; vSetEPTxStatus(EP_TX_STALL); goto Expect_Status_Out; } Length = pEPinfo->PacketSize; ControlState = (save_wLength <= Length) ? LAST_IN_DATA : IN_DATA; if (Length > save_wLength) { Length = save_wLength; } DataBuffer = (*pEPinfo->CopyData)(Length); UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length); SetEPTxCount(ENDP0, Length); pEPinfo->Usb_wLength -= Length; pEPinfo->Usb_wOffset += Length; vSetEPTxStatus(EP_TX_VALID); USB_StatusOut();/* Expect the host to abort the data IN stage */ Expect_Status_Out: pInformation->ControlState = ControlState; }
/******************************************************************************* * Function Name : DataStageIn. * Description : Data stage of a Control Read Transfer. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DataStageIn(void) { ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info; uint32_t save_wLength = pEPinfo->Usb_wLength; uint32_t ControlState = pInformation->ControlState; uint8_t *DataBuffer; uint32_t Length; if ((save_wLength == 0) && (ControlState == LAST_IN_DATA)) { if(Data_Mul_MaxPacketSize == TRUE) { /* No more data to send and empty packet */ Send0LengthData(); ControlState = LAST_IN_DATA; Data_Mul_MaxPacketSize = FALSE; } else { /* No more data to send so STALL the TX Status*/ ControlState = WAIT_STATUS_OUT; #ifdef STM32F10X_CL PCD_EP_Read (ENDP0, 0, 0); #endif /* STM32F10X_CL */ #ifndef STM32F10X_CL vSetEPTxStatus(EP_TX_STALL); #endif /* STM32F10X_CL */ } goto Expect_Status_Out; } Length = pEPinfo->PacketSize; ControlState = (save_wLength <= Length) ? LAST_IN_DATA : IN_DATA; if (Length > save_wLength) { Length = save_wLength; } DataBuffer = (*pEPinfo->CopyData)(Length); #ifdef STM32F10X_CL PCD_EP_Write (ENDP0, DataBuffer, Length); #else UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length); #endif /* STM32F10X_CL */ SetEPTxCount(ENDP0, Length); pEPinfo->Usb_wLength -= Length; pEPinfo->Usb_wOffset += Length; vSetEPTxStatus(EP_TX_VALID); USB_StatusOut();/* Expect the host to abort the data IN stage */ Expect_Status_Out: pInformation->ControlState = ControlState; }