Merge pull request #3167 from Guozhanxin/usbd

完善stm32 usb 驱动,在驱动开启中断,不需要在cubemx里配置了
This commit is contained in:
Bernard Xiong 2019-10-31 08:35:00 +08:00 committed by GitHub
commit 75ae3435d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 373 additions and 243 deletions

View File

@ -11,10 +11,17 @@
#ifndef __USBD_CONFIG_H__ #ifndef __USBD_CONFIG_H__
#define __USBD_CONFIG_H__ #define __USBD_CONFIG_H__
#define USBD_IRQ_TYPE USB_LP_CAN1_RX0_IRQn
#define USBD_IRQ_HANDLER USB_LP_CAN1_RX0_IRQHandler #define USBD_IRQ_HANDLER USB_LP_CAN1_RX0_IRQHandler
#define USBD_INSTANCE USB #define USBD_INSTANCE USB
#define USBD_PCD_SPEED PCD_SPEED_FULL #define USBD_PCD_SPEED PCD_SPEED_FULL
#define USBD_PCD_PHY_MODULE PCD_PHY_EMBEDDED #define USBD_PCD_PHY_MODULE PCD_PHY_EMBEDDED
#define BSP_USB_CONNECT_PIN -1
#ifndef BSP_USB_CONNECT_PIN
#define BSP_USB_CONNECT_PIN -1
#endif
#ifndef BSP_USB_PULL_UP_STATUS
#define BSP_USB_PULL_UP_STATUS 1
#endif
#endif #endif

View File

@ -14,9 +14,11 @@
#include <rtconfig.h> #include <rtconfig.h>
#ifdef BSP_USBD_TYPE_HS #ifdef BSP_USBD_TYPE_HS
#define USBD_IRQ_TYPE OTG_HS_IRQn
#define USBD_IRQ_HANDLER OTG_HS_IRQHandler #define USBD_IRQ_HANDLER OTG_HS_IRQHandler
#define USBD_INSTANCE USB_OTG_HS #define USBD_INSTANCE USB_OTG_HS
#else #else
#define USBD_IRQ_TYPE OTG_FS_IRQn
#define USBD_IRQ_HANDLER OTG_FS_IRQHandler #define USBD_IRQ_HANDLER OTG_FS_IRQHandler
#define USBD_INSTANCE USB_OTG_FS #define USBD_INSTANCE USB_OTG_FS
#endif #endif

View File

@ -14,9 +14,11 @@
#include <rtconfig.h> #include <rtconfig.h>
#ifdef BSP_USBD_TYPE_HS #ifdef BSP_USBD_TYPE_HS
#define USBD_IRQ_TYPE OTG_HS_IRQn
#define USBD_IRQ_HANDLER OTG_HS_IRQHandler #define USBD_IRQ_HANDLER OTG_HS_IRQHandler
#define USBD_INSTANCE USB_OTG_HS #define USBD_INSTANCE USB_OTG_HS
#else #else
#define USBD_IRQ_TYPE OTG_FS_IRQn
#define USBD_IRQ_HANDLER OTG_FS_IRQHandler #define USBD_IRQ_HANDLER OTG_FS_IRQHandler
#define USBD_INSTANCE USB_OTG_FS #define USBD_INSTANCE USB_OTG_FS
#endif #endif

View File

@ -14,9 +14,11 @@
#include <rtconfig.h> #include <rtconfig.h>
#ifdef BSP_USBD_TYPE_HS #ifdef BSP_USBD_TYPE_HS
#define USBD_IRQ_TYPE OTG_HS_IRQn
#define USBD_IRQ_HANDLER OTG_HS_IRQHandler #define USBD_IRQ_HANDLER OTG_HS_IRQHandler
#define USBD_INSTANCE USB_OTG_HS #define USBD_INSTANCE USB_OTG_HS
#else #else
#define USBD_IRQ_TYPE OTG_FS_IRQn
#define USBD_IRQ_HANDLER OTG_FS_IRQHandler #define USBD_IRQ_HANDLER OTG_FS_IRQHandler
#define USBD_INSTANCE USB_OTG_FS #define USBD_INSTANCE USB_OTG_FS
#endif #endif

View File

@ -14,9 +14,11 @@
#include <rtconfig.h> #include <rtconfig.h>
#ifdef BSP_USBD_TYPE_HS #ifdef BSP_USBD_TYPE_HS
#define USBD_IRQ_TYPE OTG_HS_IRQn
#define USBD_IRQ_HANDLER OTG_HS_IRQHandler #define USBD_IRQ_HANDLER OTG_HS_IRQHandler
#define USBD_INSTANCE USB_OTG_HS #define USBD_INSTANCE USB_OTG_HS
#else #else
#define USBD_IRQ_TYPE OTG_FS_IRQn
#define USBD_IRQ_HANDLER OTG_FS_IRQHandler #define USBD_IRQ_HANDLER OTG_FS_IRQHandler
#define USBD_INSTANCE USB_OTG_FS #define USBD_INSTANCE USB_OTG_FS
#endif #endif

View File

@ -99,14 +99,14 @@ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
{ {
#if defined(SOC_SERIES_STM32F1) #if defined(SOC_SERIES_STM32F1)
rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT); rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT);
rt_pin_write(BSP_USB_CONNECT_PIN, PIN_HIGH); rt_pin_write(BSP_USB_CONNECT_PIN, BSP_USB_PULL_UP_STATUS);
#endif #endif
} }
else else
{ {
#if defined(SOC_SERIES_STM32F1) #if defined(SOC_SERIES_STM32F1)
rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT); rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT);
rt_pin_write(BSP_USB_CONNECT_PIN, PIN_LOW); rt_pin_write(BSP_USB_CONNECT_PIN, !BSP_USB_PULL_UP_STATUS);
#endif #endif
} }
} }
@ -201,6 +201,9 @@ static rt_err_t _init(rt_device_t device)
#endif #endif
/* Initialize LL Driver */ /* Initialize LL Driver */
HAL_PCD_Init(pcd); HAL_PCD_Init(pcd);
/* USB interrupt Init */
HAL_NVIC_SetPriority(USBD_IRQ_TYPE, 2, 0);
HAL_NVIC_EnableIRQ(USBD_IRQ_TYPE);
#if !defined(SOC_SERIES_STM32F1) #if !defined(SOC_SERIES_STM32F1)
HAL_PCDEx_SetRxFiFo(pcd, 0x80); HAL_PCDEx_SetRxFiFo(pcd, 0x80);
HAL_PCDEx_SetTxFiFo(pcd, 0, 0x40); HAL_PCDEx_SetTxFiFo(pcd, 0, 0x40);
@ -246,6 +249,9 @@ int stm_usbd_register(void)
/* Register endpoint infomation */ /* Register endpoint infomation */
_stm_udc.ep_pool = _ep_pool; _stm_udc.ep_pool = _ep_pool;
_stm_udc.ep0.id = &_ep_pool[0]; _stm_udc.ep0.id = &_ep_pool[0];
#ifdef BSP_USBD_SPEED_HS
_stm_udc.device_is_hs = RT_TRUE;
#endif
rt_device_register((rt_device_t)&_stm_udc, "usbd", 0); rt_device_register((rt_device_t)&_stm_udc, "usbd", 0);
rt_usb_device_init(); rt_usb_device_init();
return RT_EOK; return RT_EOK;

View File

@ -44,7 +44,7 @@
| SPI Flash | 支持 | W25Q64 | | SPI Flash | 支持 | W25Q64 |
| 以太网 | 支持 | W5500 | | 以太网 | 支持 | W5500 |
| 电位器 | 支持 | 使用 ADC1 | | 电位器 | 支持 | 使用 ADC1 |
| SD卡 | 即将支持 | | | SD卡 | 支持 | |
| CAN | 支持 | | | CAN | 支持 | |
| SDRAM | 即将支持 | | | SDRAM | 即将支持 | |
| WIFI ESP8266 | 即将支持 | | | WIFI ESP8266 | 即将支持 | |
@ -57,9 +57,9 @@
| RTC | 支持 | 支持外部晶振和内部低速时钟 | | RTC | 支持 | 支持外部晶振和内部低速时钟 |
| WDT | 支持 | | | WDT | 支持 | |
| FLASH | 支持 | 已适配 [FAL](https://github.com/RT-Thread-packages/fal) | | FLASH | 支持 | 已适配 [FAL](https://github.com/RT-Thread-packages/fal) |
| SDIO | 暂不支持 | 即将支持 | | SDIO | 支持 | |
| PWM | 暂不支持 | 即将支持 | | PWM | 支持 | |
| USB Device | 暂不支持 | 即将支持 | | USB Device | 支持 | |
| USB Host | 暂不支持 | 即将支持 | | USB Host | 暂不支持 | 即将支持 |
| **扩展模块** | **支持情况** | **备注** | | **扩展模块** | **支持情况** | **备注** |
| 暂无 | 暂不支持 | 暂不支持 | | 暂无 | 暂不支持 | 暂不支持 |

File diff suppressed because one or more lines are too long

View File

@ -5,29 +5,13 @@
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2> * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
* *
* Redistribution and use in source and binary forms, with or without modification, * This software component is licensed by ST under BSD 3-Clause license,
* are permitted provided that the following conditions are met: * the "License"; You may not use this file except in compliance with the
* 1. Redistributions of source code must retain the above copyright notice, * License. You may obtain a copy of the License at:
* this list of conditions and the following disclaimer. * opensource.org/licenses/BSD-3-Clause
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************** ******************************************************************************
*/ */
@ -52,6 +36,7 @@
#define HAL_ADC_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED
/*#define HAL_CRYP_MODULE_ENABLED */ /*#define HAL_CRYP_MODULE_ENABLED */
#define HAL_CAN_MODULE_ENABLED #define HAL_CAN_MODULE_ENABLED
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
/*#define HAL_CEC_MODULE_ENABLED */ /*#define HAL_CEC_MODULE_ENABLED */
/*#define HAL_CORTEX_MODULE_ENABLED */ /*#define HAL_CORTEX_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */ /*#define HAL_CRC_MODULE_ENABLED */
@ -67,7 +52,7 @@
/*#define HAL_NOR_MODULE_ENABLED */ /*#define HAL_NOR_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */ /*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_PCCARD_MODULE_ENABLED */ /*#define HAL_PCCARD_MODULE_ENABLED */
/*#define HAL_PCD_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED
/*#define HAL_HCD_MODULE_ENABLED */ /*#define HAL_HCD_MODULE_ENABLED */
/*#define HAL_PWR_MODULE_ENABLED */ /*#define HAL_PWR_MODULE_ENABLED */
/*#define HAL_RCC_MODULE_ENABLED */ /*#define HAL_RCC_MODULE_ENABLED */
@ -82,11 +67,11 @@
#define HAL_UART_MODULE_ENABLED #define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED */ /*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */ /*#define HAL_WWDG_MODULE_ENABLED */
/*#define HAL_EXTI_MODULE_ENABLED */
#define HAL_CORTEX_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED #define HAL_DMA_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED #define HAL_FLASH_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED
@ -147,6 +132,30 @@
#define USE_RTOS 0 #define USE_RTOS 0
#define PREFETCH_ENABLE 1 #define PREFETCH_ENABLE 1
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */ /* ########################## Assert Selection ############################## */
/** /**
* @brief Uncomment the line below to expanse the "assert_param" macro in the * @brief Uncomment the line below to expanse the "assert_param" macro in the
@ -210,6 +219,15 @@
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#define USE_SPI_CRC 0U
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
/** /**
* @brief Include module's header file * @brief Include module's header file
@ -219,14 +237,14 @@
#include "stm32f1xx_hal_rcc.h" #include "stm32f1xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */ #endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f1xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED #ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f1xx_hal_gpio.h" #include "stm32f1xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */ #endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f1xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED #ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f1xx_hal_dma.h" #include "stm32f1xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */ #endif /* HAL_DMA_MODULE_ENABLED */
@ -239,6 +257,10 @@
#include "stm32f1xx_hal_can.h" #include "stm32f1xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */ #endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "Legacy/stm32f1xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED #ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f1xx_hal_cec.h" #include "stm32f1xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */ #endif /* HAL_CEC_MODULE_ENABLED */
@ -299,10 +321,6 @@
#include "stm32f1xx_hal_sd.h" #include "stm32f1xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */ #endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f1xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED #ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f1xx_hal_nand.h" #include "stm32f1xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */ #endif /* HAL_NAND_MODULE_ENABLED */
@ -343,12 +361,15 @@
#include "stm32f1xx_hal_hcd.h" #include "stm32f1xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */ #endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f1xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief The assert_param macro is used for function's parameters check. * @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function * @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source * which reports the name of the source file and the source
* line number of the call that failed. * line number of the call that failed.
* If expr is true, it returns no value. * If expr is true, it returns no value.

View File

@ -64,6 +64,8 @@
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1; ADC_HandleTypeDef hadc1;
CAN_HandleTypeDef hcan;
IWDG_HandleTypeDef hiwdg; IWDG_HandleTypeDef hiwdg;
RTC_HandleTypeDef hrtc; RTC_HandleTypeDef hrtc;
@ -82,6 +84,8 @@ UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2; UART_HandleTypeDef huart2;
UART_HandleTypeDef huart3; UART_HandleTypeDef huart3;
PCD_HandleTypeDef hpcd_USB_FS;
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
@ -103,6 +107,8 @@ static void MX_TIM3_Init(void);
static void MX_TIM4_Init(void); static void MX_TIM4_Init(void);
static void MX_TIM5_Init(void); static void MX_TIM5_Init(void);
static void MX_SDIO_SD_Init(void); static void MX_SDIO_SD_Init(void);
static void MX_CAN_Init(void);
static void MX_USB_PCD_Init(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
@ -123,6 +129,7 @@ int main(void)
/* USER CODE END 1 */ /* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
@ -154,6 +161,8 @@ int main(void)
MX_TIM4_Init(); MX_TIM4_Init();
MX_TIM5_Init(); MX_TIM5_Init();
MX_SDIO_SD_Init(); MX_SDIO_SD_Init();
MX_CAN_Init();
MX_USB_PCD_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/* USER CODE END 2 */ /* USER CODE END 2 */
@ -192,7 +201,7 @@ void SystemClock_Config(void)
RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
@ -206,13 +215,15 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
} }
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC; PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC
|RCC_PERIPHCLK_USB;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV4;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
@ -264,6 +275,43 @@ static void MX_ADC1_Init(void)
} }
/**
* @brief CAN Initialization Function
* @param None
* @retval None
*/
static void MX_CAN_Init(void)
{
/* USER CODE BEGIN CAN_Init 0 */
/* USER CODE END CAN_Init 0 */
/* USER CODE BEGIN CAN_Init 1 */
/* USER CODE END CAN_Init 1 */
hcan.Instance = CAN1;
hcan.Init.Prescaler = 16;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan.Init.TimeSeg1 = CAN_BS1_1TQ;
hcan.Init.TimeSeg2 = CAN_BS2_1TQ;
hcan.Init.TimeTriggeredMode = DISABLE;
hcan.Init.AutoBusOff = DISABLE;
hcan.Init.AutoWakeUp = DISABLE;
hcan.Init.AutoRetransmission = DISABLE;
hcan.Init.ReceiveFifoLocked = DISABLE;
hcan.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN_Init 2 */
/* USER CODE END CAN_Init 2 */
}
/** /**
* @brief IWDG Initialization Function * @brief IWDG Initialization Function
* @param None * @param None
@ -735,6 +783,37 @@ static void MX_USART3_UART_Init(void)
} }
/**
* @brief USB Initialization Function
* @param None
* @retval None
*/
static void MX_USB_PCD_Init(void)
{
/* USER CODE BEGIN USB_Init 0 */
/* USER CODE END USB_Init 0 */
/* USER CODE BEGIN USB_Init 1 */
/* USER CODE END USB_Init 1 */
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.lpm_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_Init 2 */
/* USER CODE END USB_Init 2 */
}
/** /**
* @brief GPIO Initialization Function * @brief GPIO Initialization Function
* @param None * @param None

View File

@ -111,7 +111,6 @@ void HAL_MspInit(void)
*/ */
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hadc->Instance==ADC1) if(hadc->Instance==ADC1)
{ {
@ -142,10 +141,8 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
* @param hadc: ADC handle pointer * @param hadc: ADC handle pointer
* @retval None * @retval None
*/ */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{ {
if(hadc->Instance==ADC1) if(hadc->Instance==ADC1)
{ {
/* USER CODE BEGIN ADC1_MspDeInit 0 */ /* USER CODE BEGIN ADC1_MspDeInit 0 */
@ -174,7 +171,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
*/ */
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hcan->Instance==CAN1) if(hcan->Instance==CAN1)
{ {
@ -214,10 +210,8 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
* @param hcan: CAN handle pointer * @param hcan: CAN handle pointer
* @retval None * @retval None
*/ */
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
{ {
if(hcan->Instance==CAN1) if(hcan->Instance==CAN1)
{ {
/* USER CODE BEGIN CAN1_MspDeInit 0 */ /* USER CODE BEGIN CAN1_MspDeInit 0 */
@ -247,7 +241,6 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
*/ */
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{ {
if(hrtc->Instance==RTC) if(hrtc->Instance==RTC)
{ {
/* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE BEGIN RTC_MspInit 0 */
@ -271,10 +264,8 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
* @param hrtc: RTC handle pointer * @param hrtc: RTC handle pointer
* @retval None * @retval None
*/ */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
{ {
if(hrtc->Instance==RTC) if(hrtc->Instance==RTC)
{ {
/* USER CODE BEGIN RTC_MspDeInit 0 */ /* USER CODE BEGIN RTC_MspDeInit 0 */
@ -297,7 +288,6 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
*/ */
void HAL_SD_MspInit(SD_HandleTypeDef* hsd) void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hsd->Instance==SDIO) if(hsd->Instance==SDIO)
{ {
@ -341,10 +331,8 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
* @param hsd: SD handle pointer * @param hsd: SD handle pointer
* @retval None * @retval None
*/ */
void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd) void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
{ {
if(hsd->Instance==SDIO) if(hsd->Instance==SDIO)
{ {
/* USER CODE BEGIN SDIO_MspDeInit 0 */ /* USER CODE BEGIN SDIO_MspDeInit 0 */
@ -381,7 +369,6 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
*/ */
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hspi->Instance==SPI1) if(hspi->Instance==SPI1)
{ {
@ -448,10 +435,8 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
* @param hspi: SPI handle pointer * @param hspi: SPI handle pointer
* @retval None * @retval None
*/ */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
{ {
if(hspi->Instance==SPI1) if(hspi->Instance==SPI1)
{ {
/* USER CODE BEGIN SPI1_MspDeInit 0 */ /* USER CODE BEGIN SPI1_MspDeInit 0 */
@ -501,7 +486,6 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/ */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE BEGIN TIM2_MspInit 0 */
@ -551,7 +535,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim->Instance==TIM3) if(htim->Instance==TIM3)
{ {
@ -584,10 +567,8 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
* @param htim_base: TIM_Base handle pointer * @param htim_base: TIM_Base handle pointer
* @retval None * @retval None
*/ */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE BEGIN TIM2_MspDeInit 0 */
@ -643,7 +624,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
*/ */
void HAL_UART_MspInit(UART_HandleTypeDef* huart) void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART1) if(huart->Instance==USART1)
{ {
@ -738,10 +718,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
* @param huart: UART handle pointer * @param huart: UART handle pointer
* @retval None * @retval None
*/ */
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{ {
if(huart->Instance==USART1) if(huart->Instance==USART1)
{ {
/* USER CODE BEGIN USART1_MspDeInit 0 */ /* USER CODE BEGIN USART1_MspDeInit 0 */
@ -801,6 +779,50 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
} }
/**
* @brief PCD MSP Initialization
* This function configures the hardware resources used in this example
* @param hpcd: PCD handle pointer
* @retval None
*/
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
{
if(hpcd->Instance==USB)
{
/* USER CODE BEGIN USB_MspInit 0 */
/* USER CODE END USB_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_USB_CLK_ENABLE();
/* USER CODE BEGIN USB_MspInit 1 */
/* USER CODE END USB_MspInit 1 */
}
}
/**
* @brief PCD MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hpcd: PCD handle pointer
* @retval None
*/
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
{
if(hpcd->Instance==USB)
{
/* USER CODE BEGIN USB_MspDeInit 0 */
/* USER CODE END USB_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USB_CLK_DISABLE();
/* USER CODE BEGIN USB_MspDeInit 1 */
/* USER CODE END USB_MspDeInit 1 */
}
}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */

View File

@ -5,8 +5,8 @@ ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1 ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.master=1 ADC1.master=1
CAN.CalculateTimeBit=1333 CAN.CalculateTimeBit=2000
CAN.CalculateTimeQuantum=444.44444444444446 CAN.CalculateTimeQuantum=666.6666666666666
CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit
File.Version=6 File.Version=6
KeepUserPlacement=false KeepUserPlacement=false
@ -20,6 +20,7 @@ Mcu.IP13=TIM5
Mcu.IP14=USART1 Mcu.IP14=USART1
Mcu.IP15=USART2 Mcu.IP15=USART2
Mcu.IP16=USART3 Mcu.IP16=USART3
Mcu.IP17=USB
Mcu.IP2=IWDG Mcu.IP2=IWDG
Mcu.IP3=NVIC Mcu.IP3=NVIC
Mcu.IP4=RCC Mcu.IP4=RCC
@ -28,7 +29,7 @@ Mcu.IP6=SDIO
Mcu.IP7=SPI1 Mcu.IP7=SPI1
Mcu.IP8=SPI2 Mcu.IP8=SPI2
Mcu.IP9=SYS Mcu.IP9=SYS
Mcu.IPNb=17 Mcu.IPNb=18
Mcu.Name=STM32F103Z(C-D-E)Tx Mcu.Name=STM32F103Z(C-D-E)Tx
Mcu.Package=LQFP144 Mcu.Package=LQFP144
Mcu.Pin0=PC14-OSC32_IN Mcu.Pin0=PC14-OSC32_IN
@ -45,52 +46,59 @@ Mcu.Pin18=PC9
Mcu.Pin19=PA9 Mcu.Pin19=PA9
Mcu.Pin2=OSC_IN Mcu.Pin2=OSC_IN
Mcu.Pin20=PA10 Mcu.Pin20=PA10
Mcu.Pin21=PA13 Mcu.Pin21=PA11
Mcu.Pin22=PA14 Mcu.Pin22=PA12
Mcu.Pin23=PC10 Mcu.Pin23=PA13
Mcu.Pin24=PC11 Mcu.Pin24=PA14
Mcu.Pin25=PC12 Mcu.Pin25=PC10
Mcu.Pin26=PD2 Mcu.Pin26=PC11
Mcu.Pin27=PB5 Mcu.Pin27=PC12
Mcu.Pin28=PB8 Mcu.Pin28=PD2
Mcu.Pin29=PB9 Mcu.Pin29=PB5
Mcu.Pin3=OSC_OUT Mcu.Pin3=OSC_OUT
Mcu.Pin30=VP_IWDG_VS_IWDG Mcu.Pin30=PB8
Mcu.Pin31=VP_RTC_VS_RTC_Activate Mcu.Pin31=PB9
Mcu.Pin32=VP_SYS_VS_Systick Mcu.Pin32=VP_IWDG_VS_IWDG
Mcu.Pin33=VP_TIM2_VS_ClockSourceINT Mcu.Pin33=VP_RTC_VS_RTC_Activate
Mcu.Pin34=VP_TIM3_VS_ClockSourceINT Mcu.Pin34=VP_SYS_VS_Systick
Mcu.Pin35=VP_TIM4_VS_ClockSourceINT Mcu.Pin35=VP_TIM2_VS_ClockSourceINT
Mcu.Pin36=VP_TIM5_VS_ClockSourceINT Mcu.Pin36=VP_TIM3_VS_ClockSourceINT
Mcu.Pin37=VP_TIM4_VS_ClockSourceINT
Mcu.Pin38=VP_TIM5_VS_ClockSourceINT
Mcu.Pin4=PC1 Mcu.Pin4=PC1
Mcu.Pin5=PA2 Mcu.Pin5=PA2
Mcu.Pin6=PA3 Mcu.Pin6=PA3
Mcu.Pin7=PA5 Mcu.Pin7=PA5
Mcu.Pin8=PA6 Mcu.Pin8=PA6
Mcu.Pin9=PA7 Mcu.Pin9=PA7
Mcu.PinsNb=37 Mcu.PinsNb=39
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F103ZETx Mcu.UserName=STM32F103ZETx
MxCube.Version=5.0.1 MxCube.Version=5.4.0
MxDb.Version=DB.5.0.1 MxDb.Version=DB.5.0.40
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.ForceEnableDMAVector=true
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
OSC_IN.Mode=HSE-External-Oscillator OSC_IN.Mode=HSE-External-Oscillator
OSC_IN.Signal=RCC_OSC_IN OSC_IN.Signal=RCC_OSC_IN
OSC_OUT.Mode=HSE-External-Oscillator OSC_OUT.Mode=HSE-External-Oscillator
OSC_OUT.Signal=RCC_OSC_OUT OSC_OUT.Signal=RCC_OSC_OUT
PA10.Mode=Asynchronous PA10.Mode=Asynchronous
PA10.Signal=USART1_RX PA10.Signal=USART1_RX
PA11.Mode=Device
PA11.Signal=USB_DM
PA12.Mode=Device
PA12.Signal=USB_DP
PA13.Mode=Serial_Wire PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire PA14.Mode=Serial_Wire
@ -179,35 +187,35 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5 ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_SPI2_Init-SPI2-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_IWDG_Init-IWDG-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM3_Init-TIM3-false-HAL-true,13-MX_TIM4_Init-TIM4-false-HAL-true,14-MX_TIM5_Init-TIM5-false-HAL-true,15-MX_SDIO_SD_Init-SDIO-false-HAL-true,16-MX_CAN_Init-CAN-false-HAL-true ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_SPI2_Init-SPI2-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_IWDG_Init-IWDG-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM3_Init-TIM3-false-HAL-true,13-MX_TIM4_Init-TIM4-false-HAL-true,14-MX_TIM5_Init-TIM5-false-HAL-true,15-MX_SDIO_SD_Init-SDIO-false-HAL-true,16-MX_CAN_Init-CAN-false-HAL-true,17-MX_USB_PCD_Init-USB-false-HAL-true
RCC.ADCFreqValue=12000000 RCC.ADCFreqValue=12000000
RCC.ADCPresc=RCC_ADCPCLK2_DIV6 RCC.ADCPresc=RCC_ADCPCLK2_DIV4
RCC.AHBFreq_Value=72000000 RCC.AHBFreq_Value=48000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2 RCC.APB1CLKDivider=RCC_HCLK_DIV2
RCC.APB1Freq_Value=36000000 RCC.APB1Freq_Value=24000000
RCC.APB1TimFreq_Value=72000000 RCC.APB1TimFreq_Value=48000000
RCC.APB2Freq_Value=72000000 RCC.APB2Freq_Value=48000000
RCC.APB2TimFreq_Value=72000000 RCC.APB2TimFreq_Value=48000000
RCC.FCLKCortexFreq_Value=72000000 RCC.FCLKCortexFreq_Value=48000000
RCC.FSMCFreq_Value=72000000 RCC.FSMCFreq_Value=48000000
RCC.FamilyName=M RCC.FamilyName=M
RCC.HCLKFreq_Value=72000000 RCC.HCLKFreq_Value=48000000
RCC.I2S2Freq_Value=72000000 RCC.I2S2Freq_Value=48000000
RCC.I2S3Freq_Value=72000000 RCC.I2S3Freq_Value=48000000
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FSMCFreq_Value,FamilyName,HCLKFreq_Value,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,RTCClockSelection,RTCFreq_Value,SDIOFreq_Value,SDIOHCLKDiv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FSMCFreq_Value,FamilyName,HCLKFreq_Value,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,RTCClockSelection,RTCFreq_Value,SDIOFreq_Value,SDIOHCLKDiv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
RCC.MCOFreq_Value=72000000 RCC.MCOFreq_Value=48000000
RCC.PLLCLKFreq_Value=72000000 RCC.PLLCLKFreq_Value=48000000
RCC.PLLMCOFreq_Value=36000000 RCC.PLLMCOFreq_Value=24000000
RCC.PLLMUL=RCC_PLL_MUL9 RCC.PLLMUL=RCC_PLL_MUL6
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
RCC.RTCFreq_Value=32768 RCC.RTCFreq_Value=32768
RCC.SDIOFreq_Value=72000000 RCC.SDIOFreq_Value=48000000
RCC.SDIOHCLKDiv2FreqValue=36000000 RCC.SDIOHCLKDiv2FreqValue=24000000
RCC.SYSCLKFreq_VALUE=72000000 RCC.SYSCLKFreq_VALUE=48000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.TimSysFreq_Value=72000000 RCC.TimSysFreq_Value=48000000
RCC.USBFreq_Value=72000000 RCC.USBFreq_Value=48000000
RCC.VCOOutput2Freq_Value=8000000 RCC.VCOOutput2Freq_Value=8000000
SH.ADCx_IN11.0=ADC1_IN11,IN11 SH.ADCx_IN11.0=ADC1_IN11,IN11
SH.ADCx_IN11.ConfNb=1 SH.ADCx_IN11.ConfNb=1
@ -218,12 +226,12 @@ SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1 SH.S_TIM3_CH4.ConfNb=1
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4
SPI1.CalculateBaudRate=18.0 MBits/s SPI1.CalculateBaudRate=12.0 MBits/s
SPI1.Direction=SPI_DIRECTION_2LINES SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate
SPI1.Mode=SPI_MODE_MASTER SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER SPI1.VirtualType=VM_MASTER
SPI2.CalculateBaudRate=18.0 MBits/s SPI2.CalculateBaudRate=12.0 MBits/s
SPI2.Direction=SPI_DIRECTION_2LINES SPI2.Direction=SPI_DIRECTION_2LINES
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
SPI2.Mode=SPI_MODE_MASTER SPI2.Mode=SPI_MODE_MASTER

View File

@ -290,6 +290,20 @@ menu "On-chip Peripheral Drivers"
bool "using CAN1" bool "using CAN1"
default n default n
endif endif
config BSP_USING_USBD
bool "Enable USB device"
select RT_USING_USB_DEVICE
default n
if BSP_USING_USBD
config BSP_USB_CONNECT_PIN
int "USB connect pin"
default 67
config BSP_USB_PULL_UP_STATUS
int "USB PULL UP STATUS"
default 0
endif
source "../libraries/HAL_Drivers/Kconfig" source "../libraries/HAL_Drivers/Kconfig"
endmenu endmenu

View File

@ -28,7 +28,7 @@ void SystemClock_Config(void)
RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
@ -42,13 +42,15 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
} }
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC; PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC
|RCC_PERIPHCLK_USB;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV4;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{ {
Error_Handler(); Error_Handler();

View File

@ -39,7 +39,8 @@
| :------------ | :----------: | :-----------------------------------: | | :------------ | :----------: | :-----------------------------------: |
| GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...63 | | GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...63 |
| UART | 支持 | UART2,UART3 | | UART | 支持 | UART2,UART3 |
| onchip_flash | 支持 | | | Onchip Flash | 支持 | |
| USB Device | 支持 | |
## 使用说明 ## 使用说明

View File

@ -1,7 +1,7 @@
[PreviousGenFiles] [PreviousGenFiles]
HeaderPath=D:/work/rt-thread-me/bsp/stm32/stm32f412-st-nucleo/board/CubeMX_Config/Inc HeaderPath=D:/work/rt-thread/bsp/stm32/stm32f412-st-nucleo/board/CubeMX_Config/Inc
HeaderFiles=stm32f4xx_it.h;stm32f4xx_hal_conf.h;main.h; HeaderFiles=stm32f4xx_it.h;stm32f4xx_hal_conf.h;main.h;
SourcePath=D:/work/rt-thread-me/bsp/stm32/stm32f412-st-nucleo/board/CubeMX_Config/Src SourcePath=D:/work/rt-thread/bsp/stm32/stm32f412-st-nucleo/board/CubeMX_Config/Src
SourceFiles=stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; SourceFiles=stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c;
[PreviousLibFiles] [PreviousLibFiles]

View File

@ -43,7 +43,6 @@ NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@ -141,7 +140,7 @@ PH0\ -\ OSC_IN.Signal=RCC_OSC_IN
PH1\ -\ OSC_OUT.Mode=HSE-External-Clock-Source PH1\ -\ OSC_OUT.Mode=HSE-External-Clock-Source
PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT
PinOutPanel.RotationAngle=0 PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true ProjectManager.AskForMigrate=false
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6 ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false ProjectManager.ComputerToolchain=false

View File

@ -71,7 +71,6 @@ void SVC_Handler(void);
void DebugMon_Handler(void); void DebugMon_Handler(void);
void PendSV_Handler(void); void PendSV_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
/* USER CODE END EFP */ /* USER CODE END EFP */

View File

@ -197,9 +197,6 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
/* Peripheral clock enable */ /* Peripheral clock enable */
__HAL_RCC_USB_OTG_FS_CLK_ENABLE(); __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
/* USB_OTG_FS 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 BEGIN USB_OTG_FS_MspInit 1 */
/* USER CODE END USB_OTG_FS_MspInit 1 */ /* USER CODE END USB_OTG_FS_MspInit 1 */
@ -233,8 +230,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
*/ */
HAL_GPIO_DeInit(GPIOA, USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin); HAL_GPIO_DeInit(GPIOA, USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin);
/* USB_OTG_FS interrupt DeInit */
HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
/* USER CODE END USB_OTG_FS_MspDeInit 1 */ /* USER CODE END USB_OTG_FS_MspDeInit 1 */

View File

@ -71,7 +71,6 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
/* USER CODE END EV */ /* USER CODE END EV */
@ -212,20 +211,6 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f4xx.s). */ /* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/ /******************************************************************************/
/**
* @brief This function handles USB On The Go FS global interrupt.
*/
void OTG_FS_IRQHandler(void)
{
/* USER CODE BEGIN OTG_FS_IRQn 0 */
/* USER CODE END OTG_FS_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
/* USER CODE BEGIN OTG_FS_IRQn 1 */
/* USER CODE END OTG_FS_IRQn 1 */
}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */

View File

@ -33,12 +33,13 @@ STM32H750 是安富莱推出的一款基于 ARM Cortex-M7 内核的开发板,
本 BSP 目前对外设的支持情况如下: 本 BSP 目前对外设的支持情况如下:
| **板载外设** | **支持情况** | **备注** | | **板载外设** | **支持情况** | **备注** |
| :----------------- | :----------: | :------------------------------------- | | :----------- | :----------: | :------- |
| LCD | 待支持 | | | LCD | 待支持 | |
| ESP32 | 支持 | AT固件 | | ESP32 | 支持 | AT固件 |
| **片上外设** | **支持情况** | **备注** | | **片上外设** | **支持情况** | **备注** |
| GPIO | 支持 | | | GPIO | 支持 | |
| UART | 支持 | UART1 | | UART | 支持 | UART1 |
| USB Device | 支持 | USB HS |
## 使用说明 ## 使用说明

View File

@ -1,7 +1,7 @@
[PreviousGenFiles] [PreviousGenFiles]
HeaderPath=D:/work/rt-thread-me/bsp/stm32/stm32h750-armfly-h7-tool/board/CubeMX_Config/Inc HeaderPath=D:/work/rt-thread/bsp/stm32/stm32h750-armfly-h7-tool/board/CubeMX_Config/Inc
HeaderFiles=stm32h7xx_it.h;stm32h7xx_hal_conf.h;main.h; HeaderFiles=stm32h7xx_it.h;stm32h7xx_hal_conf.h;main.h;
SourcePath=D:/work/rt-thread-me/bsp/stm32/stm32h750-armfly-h7-tool/board/CubeMX_Config/Src SourcePath=D:/work/rt-thread/bsp/stm32/stm32h750-armfly-h7-tool/board/CubeMX_Config/Src
SourceFiles=stm32h7xx_it.c;stm32h7xx_hal_msp.c;main.c; SourceFiles=stm32h7xx_it.c;stm32h7xx_hal_msp.c;main.c;
[PreviousLibFiles] [PreviousLibFiles]

View File

@ -96,7 +96,6 @@ NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.OTG_HS_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@ -224,7 +223,7 @@ PI11.Mode=Device_HS
PI11.Signal=USB_OTG_HS_ULPI_DIR PI11.Signal=USB_OTG_HS_ULPI_DIR
PinOutPanel.CurrentBGAView=Top PinOutPanel.CurrentBGAView=Top
PinOutPanel.RotationAngle=0 PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=false ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6 ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false ProjectManager.ComputerToolchain=false

View File

@ -56,7 +56,6 @@ void SVC_Handler(void);
void DebugMon_Handler(void); void DebugMon_Handler(void);
void PendSV_Handler(void); void PendSV_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void OTG_HS_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
/* USER CODE END EFP */ /* USER CODE END EFP */

View File

@ -871,9 +871,6 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
/* Peripheral clock enable */ /* Peripheral clock enable */
__HAL_RCC_USB_OTG_HS_CLK_ENABLE(); __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
__HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE(); __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
/* USB_OTG_HS interrupt Init */
HAL_NVIC_SetPriority(OTG_HS_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
/* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */
/* USER CODE END USB_OTG_HS_MspInit 1 */ /* USER CODE END USB_OTG_HS_MspInit 1 */
@ -923,8 +920,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_3); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_3);
/* USB_OTG_HS interrupt DeInit */
HAL_NVIC_DisableIRQ(OTG_HS_IRQn);
/* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */
/* USER CODE END USB_OTG_HS_MspDeInit 1 */ /* USER CODE END USB_OTG_HS_MspDeInit 1 */

View File

@ -56,7 +56,7 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_HS;
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
/* USER CODE END EV */ /* USER CODE END EV */
@ -197,20 +197,6 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32h7xx.s). */ /* please refer to the startup file (startup_stm32h7xx.s). */
/******************************************************************************/ /******************************************************************************/
/**
* @brief This function handles USB On The Go HS global interrupt.
*/
void OTG_HS_IRQHandler(void)
{
/* USER CODE BEGIN OTG_HS_IRQn 0 */
/* USER CODE END OTG_HS_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS);
/* USER CODE BEGIN OTG_HS_IRQn 1 */
/* USER CODE END OTG_HS_IRQn 1 */
}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */