Question
A patch for USB HOST Library Bug
Posted on January 27, 2012 at 20:58
There is bug in USB Host library that causes to wrongbehavior if the attached device has more that one interface. EP properties for interface 0 is overriding by the values for next interfaces.
There is also a problem that if there are more interfaces that value ofUSBH_MAX_NUM_INTERFACESthen library will not work at all. For me there is no reason for suchbehavior, it's perfect if it will fork with firstUSBH_MAX_NUM_INTERFACES ignoring rest of them (there is no patch for this yet).
--- a/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_HOST_Library/Core/src/usbh_stdreq.c
+++ b/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_HOST_Library/Core/src/usbh_stdreq.c
@@ -77,7 +77,7 @@
static
void
USBH_ParseDevDesc (USBH_DevDesc_TypeDef* , uint8_t *buf, uint16_t le
static
void
USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
USBH_InterfaceDesc_TypeDef* itf_desc,
- USBH_EpDesc_TypeDef* ep_desc,
+ USBH_EpDesc_TypeDef ep_desc[USBH_MAX_NUM_INTERFACES][USBH_MAX_NUM_ENDPOINTS], ^M
uint8_t *buf,
uint16_t length);
static
USBH_DescHeader_t *USBH_GetNextDesc (uint8_t *pbuf,
@@ -156,7 +156,7 @@ USBH_Status USBH_Get_CfgDesc(USB_OTG_CORE_HANDLE *pdev,
/* Commands successfully sent and Response Received */
USBH_ParseCfgDesc (&phost->device_prop.Cfg_Desc,
phost->device_prop.Itf_Desc,
- phost->device_prop.Ep_Desc[0],
+ phost->device_prop.Ep_Desc, ^M
pdev->host.Rx_Buffer,
length);
@@ -356,7 +356,7 @@
static
void
USBH_ParseDevDesc (USBH_DevDesc_TypeDef* dev_desc,
*/
static
void
USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
USBH_InterfaceDesc_TypeDef* itf_desc,
- USBH_EpDesc_TypeDef* ep_desc,
+ USBH_EpDesc_TypeDef ep_desc[USBH_MAX_NUM_INTERFACES][USBH_MAX_NUM_ENDPOINTS], ^M
uint8_t *buf,
uint16_t length)
{
@@ -409,7 +409,7 @@
static
void
USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
pdesc = USBH_GetNextDesc((
void
* )pdesc, &ptr);
if
(pdesc->bDescriptorType == USB_DESC_TYPE_ENDPOINT)
{
- pep = &ep_desc[ep_ix];
+ pep = &(ep_desc[if_ix][ep_ix]);^M
USBH_ParseEPDesc (pep, (uint8_t *)pdesc);
ep_ix++;
}