Commit 061eb6fa authored by Dave Hylands's avatar Dave Hylands Committed by Damien George
Browse files

stmahl: Fix usbd_conf.c for devices which don't have USB_HS at all.

The STMCube examples define both USE_USB_HS and USE_USB_HS_IN_FS when they
use the HS in FS mode.

The STM32F401 doesn't have a USB_HS at all, so the USB_OTG_HS instance
doesn't even exist.
parent 7dec35d7
......@@ -46,6 +46,7 @@
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
#define USE_USB_HS
#define USE_USB_HS_IN_FS
/* ########################## Module Selection ############################## */
......
......@@ -301,7 +301,7 @@ void SysTick_Handler(void) {
#if defined(USE_USB_FS)
#define OTG_XX_IRQHandler OTG_FS_IRQHandler
#define OTG_XX_WKUP_IRQHandler OTG_FS_WKUP_IRQHandler
#elif defined(USE_USB_HS) || defined(USE_USB_HS_IN_FS)
#elif defined(USE_USB_HS)
#define OTG_XX_IRQHandler OTG_HS_IRQHandler
#define OTG_XX_WKUP_IRQHandler OTG_HS_WKUP_IRQHandler
#endif
......@@ -352,7 +352,7 @@ void OTG_XX_WKUP_IRQHandler(void) {
#ifdef USE_USB_FS
/* Clear EXTI pending Bit*/
__HAL_USB_FS_EXTI_CLEAR_FLAG();
#elif defined(USE_USB_HS) || defined(USE_USB_HS_IN_FS)
#elif defined(USE_USB_HS)
/* Clear EXTI pending Bit*/
__HAL_USB_HS_EXTI_CLEAR_FLAG();
#endif
......
......@@ -74,6 +74,6 @@ void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef USE_USB_FS
void OTG_FS_IRQHandler(void);
#elif defined(USE_USB_HS) || defined(USE_USB_HS_IN_FS)
#elif defined(USE_USB_HS)
void OTG_HS_IRQHandler(void);
#endif
......@@ -95,7 +95,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* Enable USBFS Interrupt */
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
}
#if defined(USE_USB_HS)
else if(hpcd->Instance == USB_OTG_HS)
{
#if defined(USE_USB_HS_IN_FS)
......@@ -139,7 +139,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* Enable USB HS Clocks */
__USB_OTG_HS_CLK_ENABLE();
#elif defined(USE_USB_HS)
#else // !USE_USB_HS_IN_FS
/* Configure USB HS GPIOs */
__GPIOA_CLK_ENABLE();
......@@ -196,7 +196,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* Enable USB HS Clocks */
__USB_OTG_HS_CLK_ENABLE();
__USB_OTG_HS_ULPI_CLK_ENABLE();
#endif
#endif // !USE_USB_HS_IN_FS
/* Set USBHS Interrupt to the lowest priority */
HAL_NVIC_SetPriority(OTG_HS_IRQn, IRQ_PRI_OTG_HS, IRQ_SUBPRI_OTG_HS);
......@@ -204,6 +204,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* Enable USBHS Interrupt */
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
}
#endif // USE_USB_HS
}
/**
* @brief DeInitializes the PCD MSP.
......@@ -218,7 +219,7 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd)
__USB_OTG_FS_CLK_DISABLE();
__SYSCFG_CLK_DISABLE();
}
#if defined(USE_USB_HS) || defined(USE_USB_HS_IN_FS)
#if defined(USE_USB_HS)
else if(hpcd->Instance == USB_OTG_HS)
{
/* Disable USB FS Clocks */
......@@ -404,7 +405,8 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x40);
HAL_PCD_SetTxFiFo(&pcd_handle, 2, 0x20);
HAL_PCD_SetTxFiFo(&pcd_handle, 3, 0x40);
#elif defined(USE_USB_HS_IN_FS)
#elif defined(USE_USB_HS)
#if defined(USE_USB_HS_IN_FS)
/*Set LL Driver parameters */
pcd_handle.Instance = USB_OTG_HS;
pcd_handle.Init.dev_endpoints = 4;
......@@ -431,7 +433,7 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x40);
HAL_PCD_SetTxFiFo(&pcd_handle, 2, 0x20);
HAL_PCD_SetTxFiFo(&pcd_handle, 3, 0x40);
#elif defined(USE_USB_HS)
#else // !defined(USE_USB_HS_IN_FS)
/*Set LL Driver parameters */
pcd_handle.Instance = USB_OTG_HS;
pcd_handle.Init.dev_endpoints = 6;
......@@ -460,8 +462,8 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
HAL_PCD_SetTxFiFo(&pcd_handle, 0, 0x80);
HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x174);
#endif
#endif // !USE_USB_HS_IN_FS
#endif // USE_USB_HS
return USBD_OK;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment