/******************************************************************************* * Function Name : USB_SIL_Read * Description : Write a buffer of data to a selected endpoint. * Input : - bEpAddr: The address of the non control endpoint. * - pBufferPointer: The pointer to which will be saved the * received data buffer. * Output : None. * Return : Number of received data (in Bytes). *******************************************************************************/ u32 USB_SIL_Read(u8 bEpAddr, u8* pBufferPointer) { u32 DataLength = 0; #ifndef STM32F10X_CL /* Get the number of received data on the selected Endpoint */ DataLength = GetEPRxCount(bEpAddr & 0x7F); /* Use the memory interface function to write to the selected endpoint */ PMAToUserBufferCopy(pBufferPointer, GetEPRxAddr(bEpAddr & 0x7F), DataLength); #else USB_OTG_EP *ep; /* Get the structure pointer of the selected Endpoint */ ep = OTGD_FS_PCD_GetOutEP(bEpAddr); /* Get the number of received data */ DataLength = ep->xfer_len; /* Use the PCD interface layer function to read the selected endpoint */ OTGD_FS_PCD_EP_Read (bEpAddr, pBufferPointer, DataLength); #endif /* STM32F10X_CL */ /* Return the number of received data */ return DataLength; }
/******************************************************************************* * Function Name : Setup0_Process * Description : Get the device request data and dispatch to individual process. * Input : None. * Output : None. * Return : Post0_Process. *******************************************************************************/ uint8_t Setup0_Process(void) { union { uint8_t* b; uint16_t* w; } pBuf; #ifdef STM32F10X_CL USB_OTG_EP *ep; uint16_t offset = 0; ep = OTGD_FS_PCD_GetOutEP(ENDP0); pBuf.b = ep->xfer_buff; OTGD_FS_EP0StartXfer(ep); #else uint16_t offset = 1; pBuf.b = PMAAddr + (uint8_t *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */ #endif /* STM32F10X_CL */ if (pInformation->ControlState != PAUSE) { pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */ pInformation->USBbRequest = *pBuf.b++; /* bRequest */ pBuf.w += offset; /* word not accessed because of 32 bits addressing */ pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */ pBuf.w += offset; /* word not accessed because of 32 bits addressing */ pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */ pBuf.w += offset; /* word not accessed because of 32 bits addressing */ pInformation->USBwLength = *pBuf.w; /* wLength */ } pInformation->ControlState = SETTING_UP; if (pInformation->USBwLength == 0) { /* Setup with no data stage */ NoData_Setup0(); } else { /* Setup with data stage */ Data_Setup0(); } return Post0_Process(); }