STM32F207 USB driver
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2014-11-17 11:26 PM
Posted on November 18, 2014 at 08:26
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; } #stm32f207-usb-dirver
Labels:
- Labels:
-
STM32F2 Series
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2014-11-19 11:03 AM
Posted on November 19, 2014 at 20:03
As I understand each host example allocates 2 channels as part of the host interface initialization code. These 2 channels supposed to stay alive during the live of the application. They are de allocated explicitly at the end of the application.
USBH_DeAllocate_AllChannel is supposed to be called to free any other channels that were allocated to communicate with a device. It is called by the host when that device is detached.