[HAL][LL][USB] fix device connection in case battery charging used with HS instance linked to internal FS PHY
Signed-off-by: Aymen Bouattay <aymen.bouattay@st.com>
diff --git a/Src/stm32f7xx_hal_pcd.c b/Src/stm32f7xx_hal_pcd.c
index 603a57e..eb026aa 100644
--- a/Src/stm32f7xx_hal_pcd.c
+++ b/Src/stm32f7xx_hal_pcd.c
@@ -122,7 +122,9 @@
*/
HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)
{
- USB_OTG_GlobalTypeDef *USBx;
+#if defined (USB_OTG_FS)
+ const USB_OTG_GlobalTypeDef *USBx;
+#endif /* defined (USB_OTG_FS) */
uint8_t i;
/* Check the PCD handle allocation */
@@ -134,7 +136,9 @@
/* Check the parameters */
assert_param(IS_PCD_ALL_INSTANCE(hpcd->Instance));
+#if defined (USB_OTG_FS)
USBx = hpcd->Instance;
+#endif /* defined (USB_OTG_FS) */
if (hpcd->State == HAL_PCD_STATE_RESET)
{
@@ -169,11 +173,13 @@
hpcd->State = HAL_PCD_STATE_BUSY;
+#if defined (USB_OTG_FS)
/* Disable DMA mode for FS instance */
- if ((USBx->CID & (0x1U << 8)) == 0U)
+ if (USBx == USB_OTG_FS)
{
hpcd->Init.dma_enable = 0U;
}
+#endif /* defined (USB_OTG_FS) */
/* Disable the Interrupts */
__HAL_PCD_DISABLE(hpcd);
@@ -1419,16 +1425,17 @@
*/
void HAL_PCD_WKUP_IRQHandler(PCD_HandleTypeDef *hpcd)
{
+#if defined (USB_OTG_FS)
USB_OTG_GlobalTypeDef *USBx;
-
USBx = hpcd->Instance;
- if ((USBx->CID & (0x1U << 8)) == 0U)
+ if (USBx == USB_OTG_FS)
{
/* Clear EXTI pending Bit */
__HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG();
}
else
+#endif /* defined (USB_OTG_FS) */
{
/* Clear EXTI pending Bit */
__HAL_USB_OTG_HS_WAKEUP_EXTI_CLEAR_FLAG();