From c581230cd3d663e0e77a06d6b6908e2225a03c1f Mon Sep 17 00:00:00 2001 From: Michel Jaouen Date: Mon, 24 Apr 2017 10:09:43 +0200 Subject: [PATCH] USBHOST: TARGET_STM fix in hal for hub support --- .../TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_hcd.c | 8 ++++++-- .../TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_hcd.c | 8 ++++++-- .../TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_hcd.c | 7 +++++-- .../TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_hcd.c | 7 +++++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_hcd.c b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_hcd.c index 4f49587a87..1d1e015721 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_hcd.c +++ b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_hcd.c @@ -930,11 +930,15 @@ static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum) /* re-activate the channel */ tmpreg = USBx_HC(chnum)->HCCHAR; tmpreg &= ~USB_OTG_HCCHAR_CHDIS; - tmpreg |= USB_OTG_HCCHAR_CHENA; + if ( hhcd->hc[chnum].urb_state != URB_ERROR) { + tmpreg |= USB_OTG_HCCHAR_CHENA; + reactivate = 1; + } USBx_HC(chnum)->HCCHAR = tmpreg; - reactivate = 1; } __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH); + if (hhcd->hc[chnum].state == 0) reactivate = 1; + if (reactivate == 0) HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state); } diff --git a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_hcd.c b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_hcd.c index 25a8e574df..91c0e76d59 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_hcd.c +++ b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_hcd.c @@ -931,10 +931,14 @@ static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum) /* re-activate the channel */ tmpreg = USBx_HC(chnum)->HCCHAR; tmpreg &= ~USB_OTG_HCCHAR_CHDIS; - tmpreg |= USB_OTG_HCCHAR_CHENA; + if ( hhcd->hc[chnum].urb_state != URB_ERROR) { + tmpreg |= USB_OTG_HCCHAR_CHENA; + reactivate = 1; + } USBx_HC(chnum)->HCCHAR = tmpreg; - reactivate = 1; + } + if (hhcd->hc[chnum].state == 0) reactivate = 1; __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH); if (reactivate == 0) HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state); } diff --git a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_hcd.c b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_hcd.c index 860708d4a2..962ee719bf 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_hcd.c +++ b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_hcd.c @@ -932,11 +932,14 @@ static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) /* re-activate the channel */ tmpreg = USBx_HC(chnum)->HCCHAR; tmpreg &= ~USB_OTG_HCCHAR_CHDIS; - tmpreg |= USB_OTG_HCCHAR_CHENA; + if ( hhcd->hc[chnum].urb_state != URB_ERROR) { + tmpreg |= USB_OTG_HCCHAR_CHENA; + reactivate = 1; + } USBx_HC(chnum)->HCCHAR = tmpreg; - reactivate = 1; } __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH); + if (hhcd->hc[chnum].state == 0) reactivate = 1; if (reactivate == 0 )HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state); } diff --git a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_hcd.c b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_hcd.c index f43fde3ea9..b51d39040e 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_hcd.c +++ b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_hcd.c @@ -939,11 +939,14 @@ static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) /* re-activate the channel */ tmpreg = USBx_HC(chnum)->HCCHAR; tmpreg &= ~USB_OTG_HCCHAR_CHDIS; - tmpreg |= USB_OTG_HCCHAR_CHENA; + if ( hhcd->hc[chnum].urb_state != URB_ERROR) { + tmpreg |= USB_OTG_HCCHAR_CHENA; + reactivate = 1; + } USBx_HC(chnum)->HCCHAR = tmpreg; - reactivate = 1; } __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH); + if (hhcd->hc[chnum].state == 0) reactivate = 1; if (reactivate == 0) HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state); }