From 4c7513a948bbc06cc5f208b45724b933a890e241 Mon Sep 17 00:00:00 2001 From: arighi Date: Wed, 22 Sep 2010 10:18:39 +0000 Subject: [PATCH] STM32: USB: support extended descriptors under a USB interface Do not assume that there are only endpoint descriptors under an interface descriptor. There can be other specific USB descriptors before the list of used endpoints (i.e., usb-hid requires that the HID descriptor is placed just after the interface descriptor and before the list of endpoint descriptors). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4259 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/usb_stm32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bertos/cpu/cortex-m3/drv/usb_stm32.c b/bertos/cpu/cortex-m3/drv/usb_stm32.c index fb86f47c..2348599f 100644 --- a/bertos/cpu/cortex-m3/drv/usb_stm32.c +++ b/bertos/cpu/cortex-m3/drv/usb_stm32.c @@ -781,6 +781,8 @@ static int usb_ep_configure(const usb_endpoint_descriptor_t *epd, bool enable) /* Set Ep Address */ EpCtrlSet_EA(hw, EP >> 1); ep_hw->hw = hw; + LOG_INFO("%s: EP%d-%s configured\n", + __func__, EP >> 1, EP & 1 ? "IN" : "OUT"); /* Low-level endpoint configuration */ usb_ep_low_level_config(EP, Offset, MaxPacketSizeTmp); @@ -975,8 +977,10 @@ usb_configure_ep_interface(unsigned int num, unsigned int alt, bool enable) for (i = start + 1; ; i++) { epd = (usb_endpoint_descriptor_t *)usb_dev->config[i]; - if ((epd == NULL) || (epd->bDescriptorType != USB_DT_ENDPOINT)) + if ((epd == NULL) || (epd->bDescriptorType == USB_DT_INTERFACE)) break; + if (epd->bDescriptorType != USB_DT_ENDPOINT) + continue; if (UNLIKELY(usb_ep_configure(epd, enable) < 0)) { LOG_ERR("%s: out of memory, can't initialize EP\n", -- 2.25.1