cancel
Showing results for 
Search instead for 
Did you mean: 

USBH_BulkReceiveData not working

ABouk.1
Associate III

Hello everybody,

I am currently trying to implement a RTL2832 on STM32, the initialisation process works just fine (USBH_CtlReq). But during the USBH_RTLSDR_Process, my program first uses a USBH_BulkReceiveData and loops on USBH_LL_GetURBState. the states i am getting are :

DEBUG : RTLSDR Init Complete

DEBUG : Error, usbh IDLE ... {0}

DEBUG : Error, usbh not ready ... {1}

DEBUG : Xfer error {2}

DEBUG : Error, usbh IDLE ... {3}

DEBUG : Error, usbh IDLE ... {4}

DEBUG : Xfer error {5}

DEBUG : Error, usbh IDLE ... {6}

DEBUG : Error, usbh IDLE ... {7}

DEBUG : Xfer error {8}

DEBUG : Error, usbh IDLE ... {9}

DEBUG : Error, usbh IDLE ... {10}

DEBUG : Xfer error {11}

DEBUG : Error, usbh IDLE ... {12}

DEBUG : Xfer error {13}

DEBUG : Error, usbh IDLE ... {14}

DEBUG : Error, usbh IDLE ... {15}

DEBUG : Xfer error {16}

Here is the RTLSDR process code, it uses a FSM :

static USBH_StatusTypeDef USBH_RTLSDR_Process (USBH_HandleTypeDef *phost)
{
	USBH_StatusTypeDef rStatus = USBH_FAIL;  
  USBH_URBStateTypeDef urbStatus = USBH_URB_ERROR;
  static int cnt = 0;
  //USBH_DbgLog("Enter RTLSDR_Process");
  
  RTLSDR_HandleTypeDef *RTLSDR_Handle =  
    (RTLSDR_HandleTypeDef*) phost->pActiveClass->pData; 
  
  switch (RTLSDR_Handle->xferState) {
		case RTLSDR_XFER_START:
            //RTLSDR_Handle->TimHandle.Instance->CNT=0;
			rStatus = USBH_BulkReceiveData(phost, 
											&(RTLSDR_Handle->CommItf.buff[0]),
											RTLSDR_Handle->CommItf.buffSize,
											RTLSDR_Handle->CommItf.SdrPipe);
 
			RTLSDR_Handle->xferState = RTLSDR_XFER_WAIT;
			RTLSDR_Handle->xferWaitNo=0;
		break;
		
		case RTLSDR_XFER_WAIT:
			RTLSDR_Handle->xferWaitNo++;
			urbStatus = USBH_LL_GetURBState(phost , RTLSDR_Handle->CommItf.SdrPipe);
			switch(urbStatus){
			case USBH_URB_DONE:
				USBH_DbgLog("Xfer complete %d B, %d kB/s", USBH_LL_GetLastXferSize(phost,RTLSDR_Handle->CommItf.SdrPipe), USBH_LL_GetLastXferSize(phost,RTLSDR_Handle->CommItf.SdrPipe) * 100 / RTLSDR_Handle->TimHandle.Instance->CNT);
				RTLSDR_Handle->TimHandle.Instance->CNT=0;
				rStatus = USBH_OK;
				RTLSDR_Handle->xferState = RTLSDR_XFER_COMPLETE;
				break;
			case USBH_URB_ERROR:
				USBH_DbgLog("Xfer error {%d}", cnt);
				rStatus = USBH_FAIL;
				RTLSDR_Handle->xferState = RTLSDR_XFER_START;
				break;
			case USBH_URB_NOTREADY:
				USBH_DbgLog("Error, usbh not ready ... {%d}", cnt);
				break;
			case USBH_URB_IDLE:
				USBH_DbgLog("Error, usbh IDLE ... {%d}", cnt);
				break;
			default:
				USBH_DbgLog("Error, another case spotten {%d}", cnt);
				break;
			}
			cnt++;
		break;
		
		case RTLSDR_XFER_COMPLETE:
			RTLSDR_Handle->xferState = RTLSDR_XFER_START;
			rStatus = USBH_OK;
			break;
	}
 
  return rStatus;
}

The big question is why i am never getting a USBH_URB_DONE, and what does USBH_URB_IDLE, USBH_URB_NOTREADY and USBH_URB_ERROR means ?

Thanks,

0 REPLIES 0