/** * @brief USBD_DataOutStage * Handle data out stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ static uint8_t USBD_DataOutStage(USB_CORE_HANDLE *pdev , uint8_t epnum) { USB_EP *ep; if(epnum == 0) { ep = &pdev->dev.out_ep[0]; if ( pdev->dev.device_state == USB_EP0_DATA_OUT) { if(ep->rem_data_len > ep->maxpacket) { ep->rem_data_len -= ep->maxpacket; USBD_CtlContinueRx (pdev, ep->xfer_buff, MIN(ep->rem_data_len ,ep->maxpacket)); } else { if((pdev->dev.class_cb->EP0_RxReady != NULL)&& (pdev->dev.device_status == USB_CONFIGURED)) { pdev->dev.class_cb->EP0_RxReady(pdev); } USBD_CtlSendStatus(pdev); } } } else if((pdev->dev.class_cb->DataOut != NULL)&& (pdev->dev.device_status == USB_CONFIGURED)) { pdev->dev.class_cb->DataOut(pdev, epnum); } return USBD_OK; }
/** * @brief USBD_DataOutStage * Handle data out stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ static uint8_t USBD_DataOutStage ( USB_OTG_CORE_HANDLE *pdev , uint8_t epnum ) { USB_OTG_EP *ep; if ( epnum == 0 ) { ep = &pdev->dev.out_ep[0]; if ( pdev->dev.device_state == USB_OTG_EP0_DATA_OUT ) { if ( ep->rem_data_len > ep->maxpacket ) { ep->rem_data_len -= ep->maxpacket; if ( pdev->cfg.dma_enable == 1 ) { /* in slave mode this, is handled by the RxSTSQLvl ISR */ ep->xfer_buff += ep->maxpacket; } USBD_CtlContinueRx ( pdev, ep->xfer_buff, MIN ( ep->rem_data_len ,ep->maxpacket ) ); } else { if ( ( pdev->dev.class_cb->EP0_RxReady != NULL ) && ( pdev->dev.device_status == USB_OTG_CONFIGURED ) ) { pdev->dev.class_cb->EP0_RxReady ( pdev ); } USBD_CtlSendStatus ( pdev ); } } } else if ( ( pdev->dev.class_cb->DataOut != NULL ) && ( pdev->dev.device_status == USB_OTG_CONFIGURED ) ) { pdev->dev.class_cb->DataOut ( pdev, epnum ); } return USBD_OK; }
/** * @brief USBD_DataOutStage * Handle data OUT stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; if(epnum == 0) { pep = &pdev->ep_out[0]; if ( pdev->ep0_state == USBD_EP0_DATA_OUT) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; USBD_CtlContinueRx (pdev, pdata, MIN(pep->rem_length ,pep->maxpacket)); } else { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->EP0_RxReady != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((EP0_RxReady_t)PIC(pdev->interfacesClass[intf].pClass->EP0_RxReady))(pdev); } } USBD_CtlSendStatus(pdev); } } } else { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if( usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->DataOut != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((DataOut_t)PIC(pdev->interfacesClass[intf].pClass->DataOut))(pdev, epnum, pdata); } } } return USBD_OK; }
/** * @brief USBD_DataOutStage * Handle data OUT stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; if(epnum == 0) { pep = &pdev->ep_out[0]; if ( pdev->ep0_state == USBD_EP0_DATA_OUT) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; USBD_CtlContinueRx (pdev, pdata, MIN(pep->rem_length ,pep->maxpacket)); } else { if((pdev->pClass->EP0_RxReady != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { pdev->pClass->EP0_RxReady(pdev); } USBD_CtlSendStatus(pdev); } } } else if((pdev->pClass->DataOut != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { pdev->pClass->DataOut(pdev, epnum); } return USBD_OK; }