STM32 USB Host Library 学习笔记 (3) USBH_HandleControl()

/**
 * @brief  USBH_HandleControl
 *         Handles the USB control transfer state machine
 * @param  pdev: Selected device
 * @retval Status
 */
USBH_Status USBH_HandleControl(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
{
    switch (phost->Control.state)
case CTRL_DATA_IN_WAIT: URB_Status = HCD_GetURB_State( pdev, phost->Control.hc_num_in ); /* check is DATA packet transfered successfully */ if (URB_Status == URB_DONE) { phost->Control.state = CTRL_STATUS_OUT; } /* manage error cases*/ else // add -- only when if (URB_Status != URB_DONE)
if (URB_Status == URB_STALL)
      {
        /* In stall case, return to previous machine state*/
        phost->gState = phost->gStateBkp;

        phost->Control.state = CTRL_STALLED; // add

// SETUP DATA ACK : IN : STALL
} }
posted @ 2012-09-02 00:20  IAmAProgrammer  阅读(2598)  评论(0编辑  收藏  举报