119 lines
3.3 KiB
C
119 lines
3.3 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file usb_otg.c
|
|
* @brief This file provides code for the configuration
|
|
* of the USB_OTG instances.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2026 STMicroelectronics.
|
|
* All rights reserved.
|
|
*
|
|
* This software is licensed under terms that can be found in the LICENSE file
|
|
* in the root directory of this software component.
|
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "usb_otg.h"
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
PCD_HandleTypeDef hpcd_USB_OTG_HS;
|
|
|
|
/* USB_OTG_HS init function */
|
|
|
|
void MX_USB_OTG_HS_PCD_Init(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN USB_OTG_HS_Init 0 */
|
|
|
|
/* USER CODE END USB_OTG_HS_Init 0 */
|
|
|
|
/* USER CODE BEGIN USB_OTG_HS_Init 1 */
|
|
|
|
/* USER CODE END USB_OTG_HS_Init 1 */
|
|
hpcd_USB_OTG_HS.Instance = USB_OTG_HS;
|
|
hpcd_USB_OTG_HS.Init.dev_endpoints = 9;
|
|
hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL;
|
|
hpcd_USB_OTG_HS.Init.dma_enable = ENABLE;
|
|
hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY;
|
|
hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE;
|
|
hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE;
|
|
hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE;
|
|
hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE;
|
|
hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE;
|
|
hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE;
|
|
if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN USB_OTG_HS_Init 2 */
|
|
|
|
/* USER CODE END USB_OTG_HS_Init 2 */
|
|
|
|
}
|
|
|
|
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
|
|
{
|
|
|
|
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
|
if(pcdHandle->Instance==USB_OTG_HS)
|
|
{
|
|
/* USER CODE BEGIN USB_OTG_HS_MspInit 0 */
|
|
|
|
/* USER CODE END USB_OTG_HS_MspInit 0 */
|
|
|
|
/** Initializes the peripherals clock
|
|
*/
|
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
|
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
|
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
/** Enable USB Voltage detector
|
|
*/
|
|
HAL_PWREx_EnableUSBVoltageDetector();
|
|
|
|
/* USB_OTG_HS clock enable */
|
|
__HAL_RCC_USB_OTG_HS_CLK_ENABLE();
|
|
|
|
/* USB_OTG_HS interrupt Init */
|
|
HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);
|
|
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
|
|
/* USER CODE BEGIN USB_OTG_HS_MspInit 1 */
|
|
|
|
/* USER CODE END USB_OTG_HS_MspInit 1 */
|
|
}
|
|
}
|
|
|
|
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
|
|
{
|
|
|
|
if(pcdHandle->Instance==USB_OTG_HS)
|
|
{
|
|
/* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */
|
|
|
|
/* USER CODE END USB_OTG_HS_MspDeInit 0 */
|
|
/* Peripheral clock disable */
|
|
__HAL_RCC_USB_OTG_HS_CLK_DISABLE();
|
|
|
|
/* USB_OTG_HS interrupt Deinit */
|
|
HAL_NVIC_DisableIRQ(OTG_HS_IRQn);
|
|
/* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */
|
|
|
|
/* USER CODE END USB_OTG_HS_MspDeInit 1 */
|
|
}
|
|
}
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|