2024-07-06 04:25:33 +08:00
|
|
|
/* USER CODE BEGIN Header */
|
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @file stm32f3xx_hal_msp.c
|
|
|
|
* @brief This file provides code for the MSP Initialization
|
|
|
|
* and de-Initialization codes.
|
|
|
|
******************************************************************************
|
|
|
|
* @attention
|
|
|
|
*
|
|
|
|
* Copyright (c) 2024 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 "main.h"
|
|
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN TD */
|
|
|
|
|
|
|
|
/* USER CODE END TD */
|
|
|
|
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN Define */
|
|
|
|
|
|
|
|
/* USER CODE END Define */
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN Macro */
|
|
|
|
|
|
|
|
/* USER CODE END Macro */
|
|
|
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN PV */
|
|
|
|
|
|
|
|
/* USER CODE END PV */
|
|
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
|
|
|
|
/* External functions --------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN ExternalFunctions */
|
|
|
|
|
|
|
|
/* USER CODE END ExternalFunctions */
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
|
|
|
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
|
|
|
/**
|
|
|
|
* Initializes the Global MSP.
|
|
|
|
*/
|
|
|
|
void HAL_MspInit(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* USER CODE BEGIN MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END MspInit 0 */
|
|
|
|
|
|
|
|
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
|
|
|
|
|
|
/* System interrupt init*/
|
|
|
|
|
|
|
|
/* USER CODE BEGIN MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END MspInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ADC MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param hadc: ADC handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
|
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
2024-07-06 04:58:57 +08:00
|
|
|
if(hadc->Instance==ADC2)
|
2024-07-06 04:25:33 +08:00
|
|
|
{
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE BEGIN ADC2_MspInit 0 */
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE END ADC2_MspInit 0 */
|
2024-07-06 04:25:33 +08:00
|
|
|
/* Peripheral clock enable */
|
2024-07-06 04:58:57 +08:00
|
|
|
__HAL_RCC_ADC12_CLK_ENABLE();
|
2024-07-06 04:25:33 +08:00
|
|
|
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
2024-07-06 04:58:57 +08:00
|
|
|
/**ADC2 GPIO Configuration
|
|
|
|
PA4 ------> ADC2_IN1
|
|
|
|
PA5 ------> ADC2_IN2
|
|
|
|
PA6 ------> ADC2_IN3
|
|
|
|
PA7 ------> ADC2_IN4
|
2024-07-06 04:25:33 +08:00
|
|
|
*/
|
2024-07-06 04:58:57 +08:00
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
|
2024-07-06 04:25:33 +08:00
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE BEGIN ADC2_MspInit 1 */
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE END ADC2_MspInit 1 */
|
2024-07-06 04:25:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ADC MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param hadc: ADC handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
|
|
|
{
|
2024-07-06 04:58:57 +08:00
|
|
|
if(hadc->Instance==ADC2)
|
2024-07-06 04:25:33 +08:00
|
|
|
{
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE BEGIN ADC2_MspDeInit 0 */
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE END ADC2_MspDeInit 0 */
|
2024-07-06 04:25:33 +08:00
|
|
|
/* Peripheral clock disable */
|
2024-07-06 04:58:57 +08:00
|
|
|
__HAL_RCC_ADC12_CLK_DISABLE();
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/**ADC2 GPIO Configuration
|
|
|
|
PA4 ------> ADC2_IN1
|
|
|
|
PA5 ------> ADC2_IN2
|
|
|
|
PA6 ------> ADC2_IN3
|
|
|
|
PA7 ------> ADC2_IN4
|
2024-07-06 04:25:33 +08:00
|
|
|
*/
|
2024-07-06 04:58:57 +08:00
|
|
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE BEGIN ADC2_MspDeInit 1 */
|
2024-07-06 04:25:33 +08:00
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/* USER CODE END ADC2_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief CAN MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param hcan: CAN handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
|
|
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
if(hcan->Instance==CAN)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN CAN_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END CAN_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_CAN1_CLK_ENABLE();
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**CAN GPIO Configuration
|
|
|
|
PB8 ------> CAN_RX
|
|
|
|
PB9 ------> CAN_TX
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN CAN_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END CAN_MspInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief CAN MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param hcan: CAN handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
|
|
|
|
{
|
|
|
|
if(hcan->Instance==CAN)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN CAN_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END CAN_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_CAN1_CLK_DISABLE();
|
|
|
|
|
|
|
|
/**CAN GPIO Configuration
|
|
|
|
PB8 ------> CAN_RX
|
|
|
|
PB9 ------> CAN_TX
|
|
|
|
*/
|
|
|
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN CAN_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END CAN_MspDeInit 1 */
|
2024-07-06 04:25:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief SPI MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param hspi: SPI handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
if(hspi->Instance==SPI2)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN SPI2_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI2_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_SPI2_CLK_ENABLE();
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**SPI2 GPIO Configuration
|
|
|
|
PB13 ------> SPI2_SCK
|
|
|
|
PB14 ------> SPI2_MISO
|
|
|
|
PB15 ------> SPI2_MOSI
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN SPI2_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI2_MspInit 1 */
|
|
|
|
}
|
|
|
|
else if(hspi->Instance==SPI3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN SPI3_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI3_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_SPI3_CLK_ENABLE();
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**SPI3 GPIO Configuration
|
|
|
|
PB3 ------> SPI3_SCK
|
|
|
|
PB4 ------> SPI3_MISO
|
|
|
|
PB5 ------> SPI3_MOSI
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN SPI3_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI3_MspInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief SPI MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param hspi: SPI handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
|
|
|
{
|
|
|
|
if(hspi->Instance==SPI2)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI2_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_SPI2_CLK_DISABLE();
|
|
|
|
|
|
|
|
/**SPI2 GPIO Configuration
|
|
|
|
PB13 ------> SPI2_SCK
|
|
|
|
PB14 ------> SPI2_MISO
|
|
|
|
PB15 ------> SPI2_MOSI
|
|
|
|
*/
|
|
|
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI2_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
else if(hspi->Instance==SPI3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN SPI3_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI3_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_SPI3_CLK_DISABLE();
|
|
|
|
|
|
|
|
/**SPI3 GPIO Configuration
|
|
|
|
PB3 ------> SPI3_SCK
|
|
|
|
PB4 ------> SPI3_MISO
|
|
|
|
PB5 ------> SPI3_MOSI
|
|
|
|
*/
|
|
|
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN SPI3_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END SPI3_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief TIM_PWM MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param htim_pwm: TIM_PWM handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
|
|
|
|
{
|
|
|
|
if(htim_pwm->Instance==TIM2)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM2_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_TIM2_CLK_ENABLE();
|
|
|
|
/* USER CODE BEGIN TIM2_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspInit 1 */
|
|
|
|
}
|
2024-07-06 04:58:57 +08:00
|
|
|
else if(htim_pwm->Instance==TIM3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM3_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
|
|
|
/* USER CODE BEGIN TIM3_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspInit 1 */
|
|
|
|
}
|
2024-07-06 04:25:33 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief TIM_Base MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param htim_base: TIM_Base handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
|
|
|
{
|
|
|
|
if(htim_base->Instance==TIM17)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM17_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_TIM17_CLK_ENABLE();
|
|
|
|
/* USER CODE BEGIN TIM17_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
|
|
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
2024-07-06 04:58:57 +08:00
|
|
|
if(htim->Instance==TIM2)
|
2024-07-06 04:25:33 +08:00
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM2_MspPostInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspPostInit 0 */
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
|
|
/**TIM2 GPIO Configuration
|
|
|
|
PA0 ------> TIM2_CH1
|
|
|
|
PA1 ------> TIM2_CH2
|
|
|
|
PA2 ------> TIM2_CH3
|
|
|
|
PA3 ------> TIM2_CH4
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
|
|
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM2_MspPostInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspPostInit 1 */
|
|
|
|
}
|
2024-07-06 04:58:57 +08:00
|
|
|
else if(htim->Instance==TIM3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspPostInit 0 */
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**TIM3 GPIO Configuration
|
|
|
|
PB0 ------> TIM3_CH3
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspPostInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspPostInit 1 */
|
|
|
|
}
|
2024-07-06 04:25:33 +08:00
|
|
|
else if(htim->Instance==TIM17)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM17_MspPostInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspPostInit 0 */
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**TIM17 GPIO Configuration
|
|
|
|
PB7 ------> TIM17_CH1N
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = ALARM_PWM_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF1_TIM17;
|
|
|
|
HAL_GPIO_Init(ALARM_PWM_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM17_MspPostInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspPostInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @brief TIM_PWM MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param htim_pwm: TIM_PWM handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
|
|
|
|
{
|
|
|
|
if(htim_pwm->Instance==TIM2)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_TIM2_CLK_DISABLE();
|
|
|
|
/* USER CODE BEGIN TIM2_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspDeInit 1 */
|
|
|
|
}
|
2024-07-06 04:58:57 +08:00
|
|
|
else if(htim_pwm->Instance==TIM3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM3_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_TIM3_CLK_DISABLE();
|
|
|
|
/* USER CODE BEGIN TIM3_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspDeInit 1 */
|
|
|
|
}
|
2024-07-06 04:25:33 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief TIM_Base MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param htim_base: TIM_Base handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
|
|
|
{
|
|
|
|
if(htim_base->Instance==TIM17)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN TIM17_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_TIM17_CLK_DISABLE();
|
|
|
|
/* USER CODE BEGIN TIM17_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END TIM17_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief UART MSP Initialization
|
|
|
|
* This function configures the hardware resources used in this example
|
|
|
|
* @param huart: UART handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
if(huart->Instance==USART3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN USART3_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END USART3_MspInit 0 */
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_USART3_CLK_ENABLE();
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/**USART3 GPIO Configuration
|
|
|
|
PB10 ------> USART3_TX
|
|
|
|
PB11 ------> USART3_RX
|
|
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_MspInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END USART3_MspInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief UART MSP De-Initialization
|
|
|
|
* This function freeze the hardware resources used in this example
|
|
|
|
* @param huart: UART handle pointer
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|
|
|
{
|
|
|
|
if(huart->Instance==USART3)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN USART3_MspDeInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END USART3_MspDeInit 0 */
|
|
|
|
/* Peripheral clock disable */
|
|
|
|
__HAL_RCC_USART3_CLK_DISABLE();
|
|
|
|
|
|
|
|
/**USART3 GPIO Configuration
|
|
|
|
PB10 ------> USART3_TX
|
|
|
|
PB11 ------> USART3_RX
|
|
|
|
*/
|
|
|
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
|
|
|
|
|
|
|
|
/* USART3 interrupt DeInit */
|
|
|
|
HAL_NVIC_DisableIRQ(USART3_IRQn);
|
|
|
|
/* USER CODE BEGIN USART3_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END USART3_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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)
|
|
|
|
{
|
2024-07-06 04:58:57 +08:00
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
2024-07-06 04:25:33 +08:00
|
|
|
if(hpcd->Instance==USB)
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN USB_MspInit 0 */
|
|
|
|
|
|
|
|
/* USER CODE END USB_MspInit 0 */
|
2024-07-06 04:58:57 +08:00
|
|
|
|
|
|
|
__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_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF14_USB;
|
|
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
|
2024-07-06 04:25:33 +08:00
|
|
|
/* Peripheral clock enable */
|
|
|
|
__HAL_RCC_USB_CLK_ENABLE();
|
|
|
|
/* USB interrupt Init */
|
2024-07-06 04:58:57 +08:00
|
|
|
__HAL_REMAPINTERRUPT_USB_ENABLE();
|
|
|
|
HAL_NVIC_SetPriority(USB_HP_IRQn, 0, 0);
|
|
|
|
HAL_NVIC_EnableIRQ(USB_HP_IRQn);
|
2024-07-06 04:25:33 +08:00
|
|
|
/* 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();
|
|
|
|
|
2024-07-06 04:58:57 +08:00
|
|
|
/**USB GPIO Configuration
|
|
|
|
PA11 ------> USB_DM
|
|
|
|
PA12 ------> USB_DP
|
|
|
|
*/
|
|
|
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
|
|
|
|
2024-07-06 04:25:33 +08:00
|
|
|
/* USB interrupt DeInit */
|
2024-07-06 04:58:57 +08:00
|
|
|
HAL_NVIC_DisableIRQ(USB_HP_IRQn);
|
2024-07-06 04:25:33 +08:00
|
|
|
/* USER CODE BEGIN USB_MspDeInit 1 */
|
|
|
|
|
|
|
|
/* USER CODE END USB_MspDeInit 1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
|
|
|
|
/* USER CODE END 1 */
|