/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : Target/usbd_conf.c
* @version : v2.0_Cube
* @brief : This file implements the board support package for the USB device library
******************************************************************************
* @attention
*
* Copyright (c) 2022 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 "stm32l4xx.h"
#include "stm32l4xx_hal.h"
#include "usbd_def.h"
#include "usbd_core.h"
#include "usbd_cdc.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
PCD_HandleTypeDef hpcd_USB_OTG_FS;
void Error_Handler(void);
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* Exported function prototypes ----------------------------------------------*/
extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* Private functions ---------------------------------------------------------*/
/* USER CODE BEGIN 1 */
static void SystemClockConfig_Resume(void);
/* USER CODE END 1 */
extern void SystemClock_Config(void);
/*******************************************************************************
LL Driver Callbacks (PCD -> USB Device Library)
*******************************************************************************/
/* MSP Init */
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(pcdHandle->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
/* USER CODE END USB_OTG_FS_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;
PeriphClkInit.PLLSAI1.PLLSAI1M = 5;
PeriphClkInit.PLLSAI1.PLLSAI1N = 12;
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USB_OTG_FS GPIO Configuration
PA11 ------> USB_OTG_FS_DM
PA12 ------> USB_OTG_FS_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_OTG_FS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
/* Enable VDDUSB */
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
}
else
{
HAL_PWREx_EnableVddUSB();
}
/* Peripheral interrupt init */
HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
/* USER CODE END USB_OTG_FS_MspInit 1 */
}
}
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
{
if(pcdHandle->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
/* USER CODE END USB_OTG_FS_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USB_OTG_FS_CLK_DISABLE();
/**USB_OTG_FS GPIO Configuration
PA11 ------> USB_OTG_FS_DM
PA12 ------> USB_OTG_FS_DP
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
/* Disable VDDUSB */
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_DisableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
}
else
{
HAL_PWREx_DisableVddUSB();
}
/* Peripheral interrupt Deinit*/
HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
/* USER CODE END USB_OTG_FS_MspDeInit 1 */
}
}
/**
* @brief Setup stage callback
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup);
}
/**
* @brief Data Out stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
}
/**
* @brief Data In stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
}
/**
* @brief SOF callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief Reset callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
if ( hpcd->Init.speed != PCD_SPEED_FULL)
{
Error_Handler();
}
/* Set Speed. */
USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed);
/* Reset Device. */
USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief Suspend callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
__HAL_PCD_GATE_PHYCLOCK(hpcd);
/* Inform USB library that core enters in suspend Mode. */
USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
/* Enter in ST
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
stm32的HAL库硬件SPI驱动AD7606全速SPI 硬件开发 - 单片机.7z (153个子文件)
AD7606_496_SPI.axf 1.02MB
usbd_conf.c 24KB
system_stm32l4xx.c 13KB
usbd_desc.c 12KB
usbd_cdc_if.c 9KB
main.c 7KB
stm32l4xx_it.c 6KB
spi.c 4KB
usart.c 4KB
usb_device.c 2KB
gpio.c 2KB
stm32l4xx_hal_msp.c 2KB
stm32l4xx_hal_i2c.crf 1.01MB
stm32l4xx_hal_uart.crf 1009KB
usbd_conf.crf 1009KB
usbd_cdc.crf 1007KB
stm32l4xx_hal_spi.crf 1007KB
usbd_ctlreq.crf 1005KB
usbd_cdc_if.crf 1004KB
usb_device.crf 1003KB
usbd_core.crf 1003KB
usbd_desc.crf 1003KB
stm32l4xx_hal_rcc_ex.crf 1001KB
usbd_ioreq.crf 1000KB
stm32l4xx_ll_usb.crf 996KB
stm32l4xx_hal_rcc.crf 990KB
main.crf 987KB
stm32l4xx_hal_pcd.crf 986KB
stm32l4xx_hal_pwr_ex.crf 985KB
stm32l4xx_hal_flash_ex.crf 985KB
stm32l4xx_hal_dma.crf 981KB
stm32l4xx_hal_flash.crf 981KB
stm32l4xx_hal_uart_ex.crf 980KB
stm32l4xx_hal_exti.crf 979KB
stm32l4xx_hal_gpio.crf 978KB
stm32l4xx_hal.crf 978KB
stm32l4xx_hal_pwr.crf 977KB
stm32l4xx_hal_cortex.crf 977KB
stm32l4xx_hal_i2c_ex.crf 977KB
spi.crf 976KB
usart.crf 976KB
gpio.crf 976KB
stm32l4xx_it.crf 976KB
stm32l4xx_hal_pcd_ex.crf 976KB
system_stm32l4xx.crf 976KB
stm32l4xx_hal_msp.crf 976KB
stm32l4xx_hal_flash_ramfunc.crf 975KB
stm32l4xx_hal_spi_ex.crf 975KB
stm32l4xx_hal_tim_ex.crf 975KB
stm32l4xx_hal_tim.crf 975KB
stm32l4xx_hal_dma_ex.crf 975KB
usb_device.d 6KB
usbd_cdc_if.d 6KB
usbd_cdc.d 6KB
usbd_ctlreq.d 6KB
usbd_conf.d 6KB
usbd_ioreq.d 6KB
usbd_core.d 6KB
usbd_desc.d 6KB
stm32l4xx_hal_flash_ramfunc.d 5KB
stm32l4xx_hal_pcd_ex.d 5KB
stm32l4xx_hal_flash_ex.d 5KB
stm32l4xx_hal_pcd.d 5KB
stm32l4xx_hal_uart_ex.d 5KB
stm32l4xx_ll_usb.d 5KB
stm32l4xx_hal_rcc_ex.d 5KB
stm32l4xx_hal_spi_ex.d 5KB
stm32l4xx_hal_dma_ex.d 5KB
stm32l4xx_hal_i2c_ex.d 5KB
stm32l4xx_hal_tim_ex.d 5KB
stm32l4xx_hal_pwr_ex.d 5KB
stm32l4xx_hal_cortex.d 5KB
stm32l4xx_hal_flash.d 5KB
stm32l4xx_hal_spi.d 5KB
stm32l4xx_hal_exti.d 5KB
stm32l4xx_hal_uart.d 5KB
stm32l4xx_hal_gpio.d 5KB
stm32l4xx_hal_rcc.d 5KB
stm32l4xx_hal_tim.d 5KB
stm32l4xx_hal_pwr.d 5KB
stm32l4xx_hal_dma.d 5KB
stm32l4xx_hal_i2c.d 5KB
stm32l4xx_hal_msp.d 5KB
system_stm32l4xx.d 5KB
stm32l4xx_hal.d 5KB
stm32l4xx_it.d 5KB
main.d 4KB
usart.d 4KB
gpio.d 4KB
spi.d 4KB
startup_stm32l496xx.d 61B
AD7606_496_SPI_STM32L496RGTx.dbgconf 4KB
AD7606_496_SPI_AD7606_496_SPI.dep 132KB
stm32l4xx_hal_conf.h 17KB
main.h 2KB
stm32l4xx_it.h 2KB
usart.h 1KB
spi.h 1KB
gpio.h 1KB
RTE_Components.h 352B
共 153 条
- 1
- 2
GZM888888
- 粉丝: 513
- 资源: 3069
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Typora(version 1.2.3)导出 pdf 自定义水印的 frame.js 文件
- 【重磅,更新!】全国省市指数、新质生产力等数字经济资源合集(2022年)
- 2024年下半年软考中级网络工程ipsec over gre配置思路文档
- Simulink数值稳定性全攻略:技巧与实践
- Easy to use karmadactl command
- 2024年下半年软考中级网络工程GRE与IPSEC的联动配置思路文档
- Transformer-BiLSTM多特征输入时间序列预测(Pytorch完整源码和数据)
- 2024年下半年软考中级网络工程GRE与IPSEC的联动配置
- 基于Selenium自动化测试工具的youtube和tiktok数据爬虫
- 2024年下半年软考中级网络工程GRE与IPSEC的联动配置
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页