cancel
Showing results for 
Search instead for 
Did you mean: 

用STM32CubeMx5.3版本生�?的USB HOST �?始化U盘一直�?�在HOST_DEV_WAIT_FOR_ATTACHMENT这个环节,请问是怎么回事

新药.970
Associate
switch (phost->gState)
  {
    case HOST_IDLE :
 
      if (phost->device.is_connected)
      {
        USBH_UsrLog("USB Device Connected");
 
        /* Wait for 200 ms after connection */
        phost->gState = HOST_DEV_WAIT_FOR_ATTACHMENT;
        USBH_Delay(200U);
        USBH_LL_ResetPort(phost);
 
#if (USBH_USE_OS == 1U)
        phost->os_msg = (uint32_t)USBH_PORT_EVENT;
#if (osCMSIS < 0x20000U)
        (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
#else
        (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
#endif
#endif
      }
      break;
 
    case HOST_DEV_WAIT_FOR_ATTACHMENT: /* Wait for Port Enabled */
 
      if (phost->device.PortEnabled == 1U)
      {
        USBH_UsrLog("USB Device Reset Completed");
        phost->gState = HOST_DEV_ATTACHED;
      }
      break;
 
    case HOST_DEV_ATTACHED :
 
      if (phost->pUser != NULL)
      {
        phost->pUser(phost, HOST_USER_CONNECTION);
      }
 
      /* Wait for 100 ms after Reset */
      USBH_Delay(100U);
 
      phost->device.speed = USBH_LL_GetSpeed(phost);
 
      phost->gState = HOST_ENUMERATION;
 
      phost->Control.pipe_out = USBH_AllocPipe(phost, 0x00U);
      phost->Control.pipe_in  = USBH_AllocPipe(phost, 0x80U);
 
 
      /* Open Control pipes */
      USBH_OpenPipe(phost,
                    phost->Control.pipe_in,
                    0x80U,
                    phost->device.address,
                    phost->device.speed,
                    USBH_EP_CONTROL,
                    (uint16_t)phost->Control.pipe_size);
 
      /* Open Control pipes */
      USBH_OpenPipe(phost,
                    phost->Control.pipe_out,
                    0x00U,
                    phost->device.address,
                    phost->device.speed,
                    USBH_EP_CONTROL,
                    (uint16_t)phost->Control.pipe_size);
 
#if (USBH_USE_OS == 1U)
      phost->os_msg = (uint32_t)USBH_PORT_EVENT;
#if (osCMSIS < 0x20000U)
      (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
#else
      (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
#endif
#endif
      break;
 
    case HOST_ENUMERATION:
      /* Check for enumeration status */
      if (USBH_HandleEnum(phost) == USBH_OK)
      {
        /* The function shall return USBH_OK when full enumeration is complete */
        USBH_UsrLog("Enumeration done.");
 
        phost->device.current_interface = 0U;
 
        if (phost->device.DevDesc.bNumConfigurations == 1U)
        {
          USBH_UsrLog("This device has only 1 configuration.");
          phost->gState = HOST_SET_CONFIGURATION;
 
        }
        else
        {
          phost->gState = HOST_INPUT;
        }
 
      }
      break;

0 REPLIES 0