AnsweredAssumed Answered

STM32F207 USB driver

Question asked by kong.xie on Nov 18, 2014
Latest reply on Nov 19, 2014 by Architect
Hello,
When I study the STM32F207 USB HOST MSC project, the free channel function index confuse me a lot.  Why the index in USBH_DeAllocate_AllChannel () starts from 2 not 0? In other function, the index is from 0 to 7.  The channel 0 and 1 can't be DeAllocate?

/**
  * @brief  USBH_DeAllocate_AllChannel
  *         Free all USB host channel
* @param  pdev : core instance
  * @retval Status
  */
uint8_t USBH_DeAllocate_AllChannel  (USB_OTG_CORE_HANDLE *pdev)
{
   uint8_t idx;
  
   for (idx = 2; idx < HC_MAX ; idx ++) // Here is the index
   {
  pdev->host.channel[idx] = 0;
   }
   return USBH_OK;
}

/**
  * @brief  USBH_GetFreeChannel
  *         Get a free channel number for allocation to a device endpoint
  * @param  None
  * @retval idx: Free Channel number
  */
static uint16_t USBH_GetFreeChannel (USB_OTG_CORE_HANDLE *pdev)
{
  uint8_t idx = 0;
 
  for (idx = 0 ; idx < HC_MAX ; idx++)
  {
 if ((pdev->host.channel[idx] & HC_USED) == 0)
 {
    return idx;
 }
  }
  return HC_ERROR;
}

Outcomes