Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[H7] H723/H725 support addition (usbd_conf_stm32h7xx.c) #10357

Merged
merged 1 commit into from Nov 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 43 additions & 2 deletions src/main/vcp_hal/usbd_conf_stm32h7xx.c
Expand Up @@ -76,7 +76,7 @@ PCD_HandleTypeDef hpcd;
PCD BSP Routines
*******************************************************************************/

#if defined(USE_USB_FS) && !defined(STM32H7A3xx)&& !defined(STM32H7A3xxQ)
#if defined(USE_USB_FS) && !(defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H723xx) || defined(STM32H725xx))
void OTG_FS_IRQHandler(void)
#else
void OTG_HS_IRQHandler(void)
Expand Down Expand Up @@ -229,6 +229,32 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd)
/* Enable USBHS Interrupt */
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
}

#elif defined(STM32H723xx) || defined(STM32H725xx)
UNUSED(hpcd);

__HAL_RCC_GPIOA_CLK_ENABLE();

/**USB GPIO Configuration
PA11 ------> USB_DM
PA12 ------> USB_DP
*/
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* Peripheral clock enable */
__HAL_RCC_USB1_OTG_HS_CLK_ENABLE();

/* Set USB FS Interrupt priority */
HAL_NVIC_SetPriority(OTG_HS_IRQn, 6, 0);

/* Enable USB FS Interrupt */
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);

#else
#error Unknown MCU type
#endif
Expand Down Expand Up @@ -264,6 +290,21 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd)
__HAL_RCC_USB1_OTG_HS_CLK_DISABLE();
__HAL_RCC_USB1_OTG_HS_ULPI_CLK_DISABLE();
}
#elif defined(STM32H723xx) || defined(STM32H725xx)
if(hpcd->Instance==USB1_OTG_HS)
{
/* Peripheral clock disable */
__HAL_RCC_USB1_OTG_HS_CLK_DISABLE();

/**USB GPIO Configuration
PA11 ------> USB_DM
PA12 ------> USB_DP
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);

/* Peripheral interrupt Deinit*/
HAL_NVIC_DisableIRQ(OTG_HS_IRQn);
}
#else
#error Unknown MCU
#endif
Expand Down Expand Up @@ -422,7 +463,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev)
{
#ifdef USE_USB_FS
/* Set LL Driver parameters */
#if defined(STM32H7A3xx) || defined(STM32H7A3xxQ)
#if defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H723xx) || defined(STM32H725xx)
hpcd.Instance = USB1_OTG_HS;
#elif defined(STM32H743xx) || defined(STM32H750xx)
hpcd.Instance = USB2_OTG_FS;
Expand Down