first generate
This commit is contained in:
		
							
								
								
									
										97
									
								
								Core/Inc/main.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								Core/Inc/main.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,97 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file           : main.h
 | 
			
		||||
  * @brief          : Header for main.c file.
 | 
			
		||||
  *                   This file contains the common defines of the application.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @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 */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __MAIN_H
 | 
			
		||||
#define __MAIN_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32f3xx_hal.h"
 | 
			
		||||
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN ET */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END ET */
 | 
			
		||||
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN EC */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EC */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN EM */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EM */
 | 
			
		||||
 | 
			
		||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
 | 
			
		||||
 | 
			
		||||
/* Exported functions prototypes ---------------------------------------------*/
 | 
			
		||||
void Error_Handler(void);
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
/* Private defines -----------------------------------------------------------*/
 | 
			
		||||
#define RELAY_EN_Pin GPIO_PIN_0
 | 
			
		||||
#define RELAY_EN_GPIO_Port GPIOA
 | 
			
		||||
#define _60V_EN_Pin GPIO_PIN_1
 | 
			
		||||
#define _60V_EN_GPIO_Port GPIOA
 | 
			
		||||
#define PWM_PG_FAN1_Pin GPIO_PIN_2
 | 
			
		||||
#define PWM_PG_FAN1_GPIO_Port GPIOA
 | 
			
		||||
#define PWM_PG_FAN2_Pin GPIO_PIN_3
 | 
			
		||||
#define PWM_PG_FAN2_GPIO_Port GPIOA
 | 
			
		||||
#define STATUS_LED_R_Pin GPIO_PIN_0
 | 
			
		||||
#define STATUS_LED_R_GPIO_Port GPIOB
 | 
			
		||||
#define STATUS_LED_B_Pin GPIO_PIN_1
 | 
			
		||||
#define STATUS_LED_B_GPIO_Port GPIOB
 | 
			
		||||
#define STATUS_LED_G_Pin GPIO_PIN_2
 | 
			
		||||
#define STATUS_LED_G_GPIO_Port GPIOB
 | 
			
		||||
#define PRECHARGE_EN_Pin GPIO_PIN_11
 | 
			
		||||
#define PRECHARGE_EN_GPIO_Port GPIOB
 | 
			
		||||
#define AUX_IN_Pin GPIO_PIN_13
 | 
			
		||||
#define AUX_IN_GPIO_Port GPIOB
 | 
			
		||||
#define AUX_OUT_Pin GPIO_PIN_14
 | 
			
		||||
#define AUX_OUT_GPIO_Port GPIOB
 | 
			
		||||
#define RELAY_BATT_SIDE_ON_Pin GPIO_PIN_8
 | 
			
		||||
#define RELAY_BATT_SIDE_ON_GPIO_Port GPIOA
 | 
			
		||||
#define RELAY_ESC_SIDE_ON_Pin GPIO_PIN_9
 | 
			
		||||
#define RELAY_ESC_SIDE_ON_GPIO_Port GPIOA
 | 
			
		||||
#define CURRENT_SENSOR_ON_Pin GPIO_PIN_10
 | 
			
		||||
#define CURRENT_SENSOR_ON_GPIO_Port GPIOA
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN Private defines */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Private defines */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __MAIN_H */
 | 
			
		||||
							
								
								
									
										359
									
								
								Core/Inc/stm32f3xx_hal_conf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										359
									
								
								Core/Inc/stm32f3xx_hal_conf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,359 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32f3xx_hal_conf.h
 | 
			
		||||
  * @brief   HAL configuration file.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2016 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 */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32F3xx_HAL_CONF_H
 | 
			
		||||
#define __STM32F3xx_HAL_CONF_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* ########################## Module Selection ############################## */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This is the list of modules to be used in the HAL driver
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define HAL_MODULE_ENABLED
 | 
			
		||||
  /*#define HAL_ADC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_CRYP_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_CAN_MODULE_ENABLED
 | 
			
		||||
/*#define HAL_CEC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_NAND_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_NOR_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_PCCARD_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_SRAM_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_HRTIM_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_OPAMP_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_SDADC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_TSC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_COMP_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_CRC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_CRYP_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_DAC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_I2S_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_IWDG_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_LCD_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_LPTIM_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_RNG_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_RTC_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_SPI_MODULE_ENABLED
 | 
			
		||||
#define HAL_TIM_MODULE_ENABLED
 | 
			
		||||
#define HAL_UART_MODULE_ENABLED
 | 
			
		||||
/*#define HAL_USART_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_IRDA_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_SMARTCARD_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_SMBUS_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_WWDG_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_PCD_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_GPIO_MODULE_ENABLED
 | 
			
		||||
#define HAL_EXTI_MODULE_ENABLED
 | 
			
		||||
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
 | 
			
		||||
#define HAL_DMA_MODULE_ENABLED
 | 
			
		||||
#define HAL_RCC_MODULE_ENABLED
 | 
			
		||||
#define HAL_FLASH_MODULE_ENABLED
 | 
			
		||||
#define HAL_PWR_MODULE_ENABLED
 | 
			
		||||
#define HAL_CORTEX_MODULE_ENABLED
 | 
			
		||||
#define HAL_I2C_MODULE_ENABLED
 | 
			
		||||
/* ########################## HSE/HSI Values adaptation ##################### */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
 | 
			
		||||
  *        This value is used by the RCC HAL module to compute the system frequency
 | 
			
		||||
  *        (when HSE is used as system clock source, directly or through the PLL).
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (HSE_VALUE)
 | 
			
		||||
  #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
 | 
			
		||||
#endif /* HSE_VALUE */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
 | 
			
		||||
  *        Timeout value
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (HSE_STARTUP_TIMEOUT)
 | 
			
		||||
  #define HSE_STARTUP_TIMEOUT    ((uint32_t)100)   /*!< Time out for HSE start up, in ms */
 | 
			
		||||
#endif /* HSE_STARTUP_TIMEOUT */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Internal High Speed oscillator (HSI) value.
 | 
			
		||||
  *        This value is used by the RCC HAL module to compute the system frequency
 | 
			
		||||
  *        (when HSI is used as system clock source, directly or through the PLL).
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (HSI_VALUE)
 | 
			
		||||
  #define HSI_VALUE    ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
 | 
			
		||||
#endif /* HSI_VALUE */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
 | 
			
		||||
  *        Timeout value
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (HSI_STARTUP_TIMEOUT)
 | 
			
		||||
 #define HSI_STARTUP_TIMEOUT   ((uint32_t)5000) /*!< Time out for HSI start up */
 | 
			
		||||
#endif /* HSI_STARTUP_TIMEOUT */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Internal Low Speed oscillator (LSI) value.
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (LSI_VALUE)
 | 
			
		||||
 #define LSI_VALUE  ((uint32_t)40000)
 | 
			
		||||
#endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz
 | 
			
		||||
                                             The real value may vary depending on the variations
 | 
			
		||||
                                             in voltage and temperature.  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief External Low Speed oscillator (LSE) value.
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (LSE_VALUE)
 | 
			
		||||
 #define LSE_VALUE  ((uint32_t)32768)    /*!< Value of the External Low Speed oscillator in Hz */
 | 
			
		||||
#endif /* LSE_VALUE */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Time out for LSE start up value in ms.
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (LSE_STARTUP_TIMEOUT)
 | 
			
		||||
  #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000)   /*!< Time out for LSE start up, in ms */
 | 
			
		||||
#endif /* LSE_STARTUP_TIMEOUT */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief External clock source for I2S peripheral
 | 
			
		||||
  *        This value is used by the I2S HAL module to compute the I2S clock source
 | 
			
		||||
  *        frequency, this source is inserted directly through I2S_CKIN pad.
 | 
			
		||||
  *        - External clock generated through external PLL component on EVAL 303 (based on MCO or crystal)
 | 
			
		||||
  *        - External clock not generated on EVAL 373
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (EXTERNAL_CLOCK_VALUE)
 | 
			
		||||
  #define EXTERNAL_CLOCK_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz*/
 | 
			
		||||
#endif /* EXTERNAL_CLOCK_VALUE */
 | 
			
		||||
 | 
			
		||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
 | 
			
		||||
   ===  you can define the HSE value in your toolchain compiler preprocessor. */
 | 
			
		||||
 | 
			
		||||
/* ########################### System Configuration ######################### */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This is the HAL system configuration section
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define  VDD_VALUE                   ((uint32_t)3300) /*!< Value of VDD in mv */
 | 
			
		||||
#define  TICK_INT_PRIORITY            ((uint32_t)15)    /*!< tick interrupt priority (lowest by default)  */
 | 
			
		||||
#define  USE_RTOS                     0
 | 
			
		||||
#define  PREFETCH_ENABLE              1
 | 
			
		||||
#define  INSTRUCTION_CACHE_ENABLE     0
 | 
			
		||||
#define  DATA_CACHE_ENABLE            0
 | 
			
		||||
#define USE_SPI_CRC                     0U
 | 
			
		||||
 | 
			
		||||
#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_COMP_REGISTER_CALLBACKS        0U /* COMP 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_SRAM_REGISTER_CALLBACKS        0U /* SRAM register callback disabled      */
 | 
			
		||||
#define  USE_HAL_SMBUS_REGISTER_CALLBACKS       0U /* SMBUS 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_HRTIM_REGISTER_CALLBACKS       0U /* HRTIM register callback disabled     */
 | 
			
		||||
#define  USE_HAL_I2C_REGISTER_CALLBACKS         0U /* I2C 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_IRDA_REGISTER_CALLBACKS        0U /* IRDA register callback disabled      */
 | 
			
		||||
#define  USE_HAL_SMARTCARD_REGISTER_CALLBACKS   0U /* SMARTCARD register callback disabled */
 | 
			
		||||
#define  USE_HAL_WWDG_REGISTER_CALLBACKS        0U /* WWDG register callback disabled      */
 | 
			
		||||
#define  USE_HAL_OPAMP_REGISTER_CALLBACKS       0U /* OPAMP register callback disabled     */
 | 
			
		||||
#define  USE_HAL_RTC_REGISTER_CALLBACKS         0U /* RTC register callback disabled       */
 | 
			
		||||
#define  USE_HAL_SPI_REGISTER_CALLBACKS         0U /* SPI register callback disabled       */
 | 
			
		||||
#define  USE_HAL_I2S_REGISTER_CALLBACKS         0U /* I2S register callback disabled       */
 | 
			
		||||
#define  USE_HAL_TIM_REGISTER_CALLBACKS         0U /* TIM register callback disabled       */
 | 
			
		||||
#define  USE_HAL_TSC_REGISTER_CALLBACKS         0U /* TSC register callback disabled       */
 | 
			
		||||
#define  USE_HAL_PCD_REGISTER_CALLBACKS         0U /* PCD register callback disabled       */
 | 
			
		||||
 | 
			
		||||
/* ########################## Assert Selection ############################## */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Uncomment the line below to expanse the "assert_param" macro in the
 | 
			
		||||
  *        HAL drivers code
 | 
			
		||||
  */
 | 
			
		||||
/* #define USE_FULL_ASSERT    1U */
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Include module's header file
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_RCC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_rcc.h"
 | 
			
		||||
#endif /* HAL_RCC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_GPIO_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_gpio.h"
 | 
			
		||||
#endif /* HAL_GPIO_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_EXTI_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_exti.h"
 | 
			
		||||
#endif /* HAL_EXTI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DMA_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_dma.h"
 | 
			
		||||
#endif /* HAL_DMA_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CORTEX_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_cortex.h"
 | 
			
		||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_ADC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_adc.h"
 | 
			
		||||
#endif /* HAL_ADC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CAN_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_can.h"
 | 
			
		||||
#endif /* HAL_CAN_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_can_legacy.h"
 | 
			
		||||
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CEC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_cec.h"
 | 
			
		||||
#endif /* HAL_CEC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_COMP_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_comp.h"
 | 
			
		||||
#endif /* HAL_COMP_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CRC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_crc.h"
 | 
			
		||||
#endif /* HAL_CRC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DAC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_dac.h"
 | 
			
		||||
#endif /* HAL_DAC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_FLASH_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_flash.h"
 | 
			
		||||
#endif /* HAL_FLASH_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SRAM_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_sram.h"
 | 
			
		||||
#endif /* HAL_SRAM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_NOR_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_nor.h"
 | 
			
		||||
#endif /* HAL_NOR_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_NAND_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_nand.h"
 | 
			
		||||
#endif /* HAL_NAND_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PCCARD_MODULE_ENABLED
 | 
			
		||||
  #include "stm32f3xx_hal_pccard.h"
 | 
			
		||||
#endif /* HAL_PCCARD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_HRTIM_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_hrtim.h"
 | 
			
		||||
#endif /* HAL_HRTIM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_I2C_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_i2c.h"
 | 
			
		||||
#endif /* HAL_I2C_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_I2S_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_i2s.h"
 | 
			
		||||
#endif /* HAL_I2S_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_IRDA_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_irda.h"
 | 
			
		||||
#endif /* HAL_IRDA_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_IWDG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_iwdg.h"
 | 
			
		||||
#endif /* HAL_IWDG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_OPAMP_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_opamp.h"
 | 
			
		||||
#endif /* HAL_OPAMP_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PCD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_pcd.h"
 | 
			
		||||
#endif /* HAL_PCD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PWR_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_pwr.h"
 | 
			
		||||
#endif /* HAL_PWR_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_RTC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_rtc.h"
 | 
			
		||||
#endif /* HAL_RTC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SDADC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_sdadc.h"
 | 
			
		||||
#endif /* HAL_SDADC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_smartcard.h"
 | 
			
		||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SMBUS_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_smbus.h"
 | 
			
		||||
#endif /* HAL_SMBUS_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SPI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_spi.h"
 | 
			
		||||
#endif /* HAL_SPI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_TIM_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_tim.h"
 | 
			
		||||
#endif /* HAL_TIM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_TSC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_tsc.h"
 | 
			
		||||
#endif /* HAL_TSC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_UART_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_uart.h"
 | 
			
		||||
#endif /* HAL_UART_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_USART_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_usart.h"
 | 
			
		||||
#endif /* HAL_USART_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_WWDG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32f3xx_hal_wwdg.h"
 | 
			
		||||
#endif /* HAL_WWDG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  The assert_param macro is used for function's parameters check.
 | 
			
		||||
  * @param  expr If expr is false, it calls assert_failed function
 | 
			
		||||
  *         which reports the name of the source file and the source
 | 
			
		||||
  *         line number of the call that failed.
 | 
			
		||||
  *         If expr is true, it returns no value.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
  #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
 | 
			
		||||
/* Exported functions ------------------------------------------------------- */
 | 
			
		||||
  void assert_failed(uint8_t* file, uint32_t line);
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif /* USE_FULL_ASSERT */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32F3xx_HAL_CONF_H */
 | 
			
		||||
							
								
								
									
										66
									
								
								Core/Inc/stm32f3xx_it.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								Core/Inc/stm32f3xx_it.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,66 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32f3xx_it.h
 | 
			
		||||
  * @brief   This file contains the headers of the interrupt handlers.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @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 */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32F3xx_IT_H
 | 
			
		||||
#define __STM32F3xx_IT_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN ET */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END ET */
 | 
			
		||||
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN EC */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EC */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN EM */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EM */
 | 
			
		||||
 | 
			
		||||
/* Exported functions prototypes ---------------------------------------------*/
 | 
			
		||||
void NMI_Handler(void);
 | 
			
		||||
void HardFault_Handler(void);
 | 
			
		||||
void MemManage_Handler(void);
 | 
			
		||||
void BusFault_Handler(void);
 | 
			
		||||
void UsageFault_Handler(void);
 | 
			
		||||
void SVC_Handler(void);
 | 
			
		||||
void DebugMon_Handler(void);
 | 
			
		||||
void PendSV_Handler(void);
 | 
			
		||||
void SysTick_Handler(void);
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32F3xx_IT_H */
 | 
			
		||||
							
								
								
									
										573
									
								
								Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										573
									
								
								Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,573 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file           : main.c
 | 
			
		||||
  * @brief          : Main program body
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @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"
 | 
			
		||||
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
/* Private typedef -----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PTD */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PTD */
 | 
			
		||||
 | 
			
		||||
/* Private define ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PD */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PD */
 | 
			
		||||
 | 
			
		||||
/* Private macro -------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PM */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PM */
 | 
			
		||||
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
CAN_HandleTypeDef hcan;
 | 
			
		||||
 | 
			
		||||
I2C_HandleTypeDef hi2c1;
 | 
			
		||||
 | 
			
		||||
SPI_HandleTypeDef hspi1;
 | 
			
		||||
 | 
			
		||||
TIM_HandleTypeDef htim1;
 | 
			
		||||
TIM_HandleTypeDef htim15;
 | 
			
		||||
 | 
			
		||||
UART_HandleTypeDef huart1;
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN PV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PV */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
void SystemClock_Config(void);
 | 
			
		||||
static void MX_GPIO_Init(void);
 | 
			
		||||
static void MX_CAN_Init(void);
 | 
			
		||||
static void MX_I2C1_Init(void);
 | 
			
		||||
static void MX_SPI1_Init(void);
 | 
			
		||||
static void MX_TIM15_Init(void);
 | 
			
		||||
static void MX_USART1_UART_Init(void);
 | 
			
		||||
static void MX_TIM1_Init(void);
 | 
			
		||||
/* USER CODE BEGIN PFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PFP */
 | 
			
		||||
 | 
			
		||||
/* Private user code ---------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN 0 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  The application entry point.
 | 
			
		||||
  * @retval int
 | 
			
		||||
  */
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END 1 */
 | 
			
		||||
 | 
			
		||||
  /* MCU Configuration--------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 | 
			
		||||
  HAL_Init();
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN Init */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END Init */
 | 
			
		||||
 | 
			
		||||
  /* Configure the system clock */
 | 
			
		||||
  SystemClock_Config();
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SysInit */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SysInit */
 | 
			
		||||
 | 
			
		||||
  /* Initialize all configured peripherals */
 | 
			
		||||
  MX_GPIO_Init();
 | 
			
		||||
  MX_CAN_Init();
 | 
			
		||||
  MX_I2C1_Init();
 | 
			
		||||
  MX_SPI1_Init();
 | 
			
		||||
  MX_TIM15_Init();
 | 
			
		||||
  MX_USART1_UART_Init();
 | 
			
		||||
  MX_TIM1_Init();
 | 
			
		||||
  /* USER CODE BEGIN 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END 2 */
 | 
			
		||||
 | 
			
		||||
  /* Infinite loop */
 | 
			
		||||
  /* USER CODE BEGIN WHILE */
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
    /* USER CODE END WHILE */
 | 
			
		||||
 | 
			
		||||
    /* USER CODE BEGIN 3 */
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END 3 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief System Clock Configuration
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void SystemClock_Config(void)
 | 
			
		||||
{
 | 
			
		||||
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 | 
			
		||||
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 | 
			
		||||
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 | 
			
		||||
 | 
			
		||||
  /** Initializes the RCC Oscillators according to the specified parameters
 | 
			
		||||
  * in the RCC_OscInitTypeDef structure.
 | 
			
		||||
  */
 | 
			
		||||
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
 | 
			
		||||
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 | 
			
		||||
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 | 
			
		||||
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Initializes the CPU, AHB and APB buses clocks
 | 
			
		||||
  */
 | 
			
		||||
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 | 
			
		||||
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 | 
			
		||||
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
 | 
			
		||||
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 | 
			
		||||
 | 
			
		||||
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1
 | 
			
		||||
                              |RCC_PERIPHCLK_TIM1;
 | 
			
		||||
  PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
 | 
			
		||||
  PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
 | 
			
		||||
  PeriphClkInit.Tim1ClockSelection = RCC_TIM1CLK_HCLK;
 | 
			
		||||
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @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 = CAN;
 | 
			
		||||
  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 I2C1 Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_I2C1_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN I2C1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN I2C1_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_Init 1 */
 | 
			
		||||
  hi2c1.Instance = I2C1;
 | 
			
		||||
  hi2c1.Init.Timing = 0x2000090E;
 | 
			
		||||
  hi2c1.Init.OwnAddress1 = 0;
 | 
			
		||||
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
 | 
			
		||||
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
 | 
			
		||||
  hi2c1.Init.OwnAddress2 = 0;
 | 
			
		||||
  hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
 | 
			
		||||
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
 | 
			
		||||
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
 | 
			
		||||
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Configure Analogue filter
 | 
			
		||||
  */
 | 
			
		||||
  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Configure Digital filter
 | 
			
		||||
  */
 | 
			
		||||
  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN I2C1_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_Init 2 */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief SPI1 Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_SPI1_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 1 */
 | 
			
		||||
  /* SPI1 parameter configuration*/
 | 
			
		||||
  hspi1.Instance = SPI1;
 | 
			
		||||
  hspi1.Init.Mode = SPI_MODE_MASTER;
 | 
			
		||||
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
 | 
			
		||||
  hspi1.Init.DataSize = SPI_DATASIZE_4BIT;
 | 
			
		||||
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
 | 
			
		||||
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
 | 
			
		||||
  hspi1.Init.NSS = SPI_NSS_HARD_INPUT;
 | 
			
		||||
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
 | 
			
		||||
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
 | 
			
		||||
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
 | 
			
		||||
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
 | 
			
		||||
  hspi1.Init.CRCPolynomial = 7;
 | 
			
		||||
  hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
 | 
			
		||||
  hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
 | 
			
		||||
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 2 */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief TIM1 Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_TIM1_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  TIM_MasterConfigTypeDef sMasterConfig = {0};
 | 
			
		||||
  TIM_OC_InitTypeDef sConfigOC = {0};
 | 
			
		||||
  TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM1_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_Init 1 */
 | 
			
		||||
  htim1.Instance = TIM1;
 | 
			
		||||
  htim1.Init.Prescaler = 0;
 | 
			
		||||
  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
 | 
			
		||||
  htim1.Init.Period = 65535;
 | 
			
		||||
  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
 | 
			
		||||
  htim1.Init.RepetitionCounter = 0;
 | 
			
		||||
  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
 | 
			
		||||
  if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
 | 
			
		||||
  sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
 | 
			
		||||
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
 | 
			
		||||
  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
 | 
			
		||||
  sConfigOC.Pulse = 0;
 | 
			
		||||
  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
 | 
			
		||||
  sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
 | 
			
		||||
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
 | 
			
		||||
  sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
 | 
			
		||||
  sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
 | 
			
		||||
  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
 | 
			
		||||
  sBreakDeadTimeConfig.DeadTime = 0;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakFilter = 0;
 | 
			
		||||
  sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
 | 
			
		||||
  sBreakDeadTimeConfig.Break2Filter = 0;
 | 
			
		||||
  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
 | 
			
		||||
  if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN TIM1_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_Init 2 */
 | 
			
		||||
  HAL_TIM_MspPostInit(&htim1);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief TIM15 Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_TIM15_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM15_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_Init 0 */
 | 
			
		||||
 | 
			
		||||
  TIM_MasterConfigTypeDef sMasterConfig = {0};
 | 
			
		||||
  TIM_OC_InitTypeDef sConfigOC = {0};
 | 
			
		||||
  TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM15_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_Init 1 */
 | 
			
		||||
  htim15.Instance = TIM15;
 | 
			
		||||
  htim15.Init.Prescaler = 0;
 | 
			
		||||
  htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
 | 
			
		||||
  htim15.Init.Period = 65535;
 | 
			
		||||
  htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
 | 
			
		||||
  htim15.Init.RepetitionCounter = 0;
 | 
			
		||||
  htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
 | 
			
		||||
  if (HAL_TIM_PWM_Init(&htim15) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
 | 
			
		||||
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
 | 
			
		||||
  if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
 | 
			
		||||
  sConfigOC.Pulse = 0;
 | 
			
		||||
  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
 | 
			
		||||
  sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
 | 
			
		||||
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
 | 
			
		||||
  sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
 | 
			
		||||
  sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
 | 
			
		||||
  if (HAL_TIM_PWM_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  if (HAL_TIM_PWM_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
 | 
			
		||||
  sBreakDeadTimeConfig.DeadTime = 0;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
 | 
			
		||||
  sBreakDeadTimeConfig.BreakFilter = 0;
 | 
			
		||||
  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
 | 
			
		||||
  if (HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN TIM15_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_Init 2 */
 | 
			
		||||
  HAL_TIM_MspPostInit(&htim15);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief USART1 Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_USART1_UART_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART1_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_Init 1 */
 | 
			
		||||
  huart1.Instance = USART1;
 | 
			
		||||
  huart1.Init.BaudRate = 38400;
 | 
			
		||||
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
 | 
			
		||||
  huart1.Init.StopBits = UART_STOPBITS_1;
 | 
			
		||||
  huart1.Init.Parity = UART_PARITY_NONE;
 | 
			
		||||
  huart1.Init.Mode = UART_MODE_TX_RX;
 | 
			
		||||
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 | 
			
		||||
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
 | 
			
		||||
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
 | 
			
		||||
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
 | 
			
		||||
  if (HAL_UART_Init(&huart1) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN USART1_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_Init 2 */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief GPIO Initialization Function
 | 
			
		||||
  * @param None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
static void MX_GPIO_Init(void)
 | 
			
		||||
{
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
/* USER CODE BEGIN MX_GPIO_Init_1 */
 | 
			
		||||
/* USER CODE END MX_GPIO_Init_1 */
 | 
			
		||||
 | 
			
		||||
  /* GPIO Ports Clock Enable */
 | 
			
		||||
  __HAL_RCC_GPIOC_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOF_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOA, RELAY_EN_Pin|_60V_EN_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOB, PRECHARGE_EN_Pin|AUX_IN_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : PC13 PC14 PC15 */
 | 
			
		||||
  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : RELAY_EN_Pin _60V_EN_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = RELAY_EN_Pin|_60V_EN_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : STATUS_LED_R_Pin STATUS_LED_B_Pin STATUS_LED_G_Pin AUX_OUT_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = STATUS_LED_R_Pin|STATUS_LED_B_Pin|STATUS_LED_G_Pin|AUX_OUT_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : PB10 PB12 PB4 PB5
 | 
			
		||||
                           PB8 */
 | 
			
		||||
  GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_5
 | 
			
		||||
                          |GPIO_PIN_8;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : PRECHARGE_EN_Pin AUX_IN_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = PRECHARGE_EN_Pin|AUX_IN_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : RELAY_BATT_SIDE_ON_Pin RELAY_ESC_SIDE_ON_Pin CURRENT_SENSOR_ON_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = RELAY_BATT_SIDE_ON_Pin|RELAY_ESC_SIDE_ON_Pin|CURRENT_SENSOR_ON_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
 | 
			
		||||
/* USER CODE END MX_GPIO_Init_2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 4 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 4 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  This function is executed in case of error occurrence.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void Error_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN Error_Handler_Debug */
 | 
			
		||||
  /* User can add his own implementation to report the HAL error return state */
 | 
			
		||||
  __disable_irq();
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END Error_Handler_Debug */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Reports the name of the source file and the source line number
 | 
			
		||||
  *         where the assert_param error has occurred.
 | 
			
		||||
  * @param  file: pointer to the source file name
 | 
			
		||||
  * @param  line: assert_param error line source number
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void assert_failed(uint8_t *file, uint32_t line)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN 6 */
 | 
			
		||||
  /* User can add his own implementation to report the file name and line number,
 | 
			
		||||
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
 | 
			
		||||
  /* USER CODE END 6 */
 | 
			
		||||
}
 | 
			
		||||
#endif /* USE_FULL_ASSERT */
 | 
			
		||||
							
								
								
									
										471
									
								
								Core/Src/stm32f3xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										471
									
								
								Core/Src/stm32f3xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,471 @@
 | 
			
		||||
/* 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 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_GPIOA_CLK_ENABLE();
 | 
			
		||||
    /**CAN GPIO Configuration
 | 
			
		||||
    PA11     ------> CAN_RX
 | 
			
		||||
    PA12     ------> CAN_TX
 | 
			
		||||
    */
 | 
			
		||||
    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_AF9_CAN;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &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
 | 
			
		||||
    PA11     ------> CAN_RX
 | 
			
		||||
    PA12     ------> CAN_TX
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN CAN_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END CAN_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @brief I2C MSP Initialization
 | 
			
		||||
* This function configures the hardware resources used in this example
 | 
			
		||||
* @param hi2c: I2C handle pointer
 | 
			
		||||
* @retval None
 | 
			
		||||
*/
 | 
			
		||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
 | 
			
		||||
{
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
  if(hi2c->Instance==I2C1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN I2C1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
    /**I2C1 GPIO Configuration
 | 
			
		||||
    PA15     ------> I2C1_SCL
 | 
			
		||||
    PB9     ------> I2C1_SDA
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_15;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_9;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_I2C1_CLK_ENABLE();
 | 
			
		||||
  /* USER CODE BEGIN I2C1_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @brief I2C MSP De-Initialization
 | 
			
		||||
* This function freeze the hardware resources used in this example
 | 
			
		||||
* @param hi2c: I2C handle pointer
 | 
			
		||||
* @retval None
 | 
			
		||||
*/
 | 
			
		||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
 | 
			
		||||
{
 | 
			
		||||
  if(hi2c->Instance==I2C1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN I2C1_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_I2C1_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**I2C1 GPIO Configuration
 | 
			
		||||
    PA15     ------> I2C1_SCL
 | 
			
		||||
    PB9     ------> I2C1_SDA
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN I2C1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END I2C1_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @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==SPI1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspInit 0 */
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_SPI1_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
    /**SPI1 GPIO Configuration
 | 
			
		||||
    PA4     ------> SPI1_NSS
 | 
			
		||||
    PA5     ------> SPI1_SCK
 | 
			
		||||
    PA6     ------> SPI1_MISO
 | 
			
		||||
    PA7     ------> SPI1_MOSI
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_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==SPI1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_SPI1_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**SPI1 GPIO Configuration
 | 
			
		||||
    PA4     ------> SPI1_NSS
 | 
			
		||||
    PA5     ------> SPI1_SCK
 | 
			
		||||
    PA6     ------> SPI1_MISO
 | 
			
		||||
    PA7     ------> SPI1_MOSI
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_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==TIM1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspInit 0 */
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_TIM1_CLK_ENABLE();
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
  else if(htim_pwm->Instance==TIM15)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_MspInit 0 */
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_TIM15_CLK_ENABLE();
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
 | 
			
		||||
{
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
  if(htim->Instance==TIM1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspPostInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspPostInit 0 */
 | 
			
		||||
    __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
    /**TIM1 GPIO Configuration
 | 
			
		||||
    PB15     ------> TIM1_CH3N
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_15;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF4_TIM1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspPostInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspPostInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
  else if(htim->Instance==TIM15)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspPostInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_MspPostInit 0 */
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
    /**TIM15 GPIO Configuration
 | 
			
		||||
    PA2     ------> TIM15_CH1
 | 
			
		||||
    PA3     ------> TIM15_CH2
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = PWM_PG_FAN1_Pin|PWM_PG_FAN2_Pin;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF9_TIM15;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspPostInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_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==TIM1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_TIM1_CLK_DISABLE();
 | 
			
		||||
  /* USER CODE BEGIN TIM1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM1_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
  else if(htim_pwm->Instance==TIM15)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_TIM15_CLK_DISABLE();
 | 
			
		||||
  /* USER CODE BEGIN TIM15_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM15_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==USART1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN USART1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_MspInit 0 */
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_USART1_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
    /**USART1 GPIO Configuration
 | 
			
		||||
    PB6     ------> USART1_TX
 | 
			
		||||
    PB7     ------> USART1_RX
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART1_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_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==USART1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN USART1_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_USART1_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**USART1 GPIO Configuration
 | 
			
		||||
    PB6     ------> USART1_TX
 | 
			
		||||
    PB7     ------> USART1_RX
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART1_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
							
								
								
									
										203
									
								
								Core/Src/stm32f3xx_it.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										203
									
								
								Core/Src/stm32f3xx_it.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,203 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32f3xx_it.c
 | 
			
		||||
  * @brief   Interrupt Service Routines.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @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"
 | 
			
		||||
#include "stm32f3xx_it.h"
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
/* Private typedef -----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN TD */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END TD */
 | 
			
		||||
 | 
			
		||||
/* Private define ------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PD */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PD */
 | 
			
		||||
 | 
			
		||||
/* Private macro -------------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PM */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PM */
 | 
			
		||||
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PV */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN PFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PFP */
 | 
			
		||||
 | 
			
		||||
/* Private user code ---------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN 0 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/* External variables --------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN EV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EV */
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/*           Cortex-M4 Processor Interruption and Exception Handlers          */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Non maskable interrupt.
 | 
			
		||||
  */
 | 
			
		||||
void NMI_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END NonMaskableInt_IRQn 0 */
 | 
			
		||||
  /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
 | 
			
		||||
   while (1)
 | 
			
		||||
  {
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END NonMaskableInt_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Hard fault interrupt.
 | 
			
		||||
  */
 | 
			
		||||
void HardFault_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN HardFault_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END HardFault_IRQn 0 */
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
 | 
			
		||||
    /* USER CODE END W1_HardFault_IRQn 0 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Memory management fault.
 | 
			
		||||
  */
 | 
			
		||||
void MemManage_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN MemoryManagement_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END MemoryManagement_IRQn 0 */
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
    /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
 | 
			
		||||
    /* USER CODE END W1_MemoryManagement_IRQn 0 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Pre-fetch fault, memory access fault.
 | 
			
		||||
  */
 | 
			
		||||
void BusFault_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN BusFault_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END BusFault_IRQn 0 */
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
    /* USER CODE BEGIN W1_BusFault_IRQn 0 */
 | 
			
		||||
    /* USER CODE END W1_BusFault_IRQn 0 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Undefined instruction or illegal state.
 | 
			
		||||
  */
 | 
			
		||||
void UsageFault_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN UsageFault_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END UsageFault_IRQn 0 */
 | 
			
		||||
  while (1)
 | 
			
		||||
  {
 | 
			
		||||
    /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
 | 
			
		||||
    /* USER CODE END W1_UsageFault_IRQn 0 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles System service call via SWI instruction.
 | 
			
		||||
  */
 | 
			
		||||
void SVC_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN SVCall_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SVCall_IRQn 0 */
 | 
			
		||||
  /* USER CODE BEGIN SVCall_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SVCall_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Debug monitor.
 | 
			
		||||
  */
 | 
			
		||||
void DebugMon_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN DebugMonitor_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END DebugMonitor_IRQn 0 */
 | 
			
		||||
  /* USER CODE BEGIN DebugMonitor_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END DebugMonitor_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles Pendable request for system service.
 | 
			
		||||
  */
 | 
			
		||||
void PendSV_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN PendSV_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END PendSV_IRQn 0 */
 | 
			
		||||
  /* USER CODE BEGIN PendSV_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END PendSV_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles System tick timer.
 | 
			
		||||
  */
 | 
			
		||||
void SysTick_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN SysTick_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SysTick_IRQn 0 */
 | 
			
		||||
  HAL_IncTick();
 | 
			
		||||
  /* USER CODE BEGIN SysTick_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SysTick_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/* STM32F3xx Peripheral Interrupt Handlers                                    */
 | 
			
		||||
/* Add here the Interrupt Handlers for the used peripherals.                  */
 | 
			
		||||
/* For the available peripheral interrupt handler names,                      */
 | 
			
		||||
/* please refer to the startup file (startup_stm32f3xx.s).                    */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
							
								
								
									
										176
									
								
								Core/Src/syscalls.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								Core/Src/syscalls.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,176 @@
 | 
			
		||||
/**
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @file      syscalls.c
 | 
			
		||||
 * @author    Auto-generated by STM32CubeMX
 | 
			
		||||
 * @brief     Minimal System calls file
 | 
			
		||||
 *
 | 
			
		||||
 *            For more information about which c-functions
 | 
			
		||||
 *            need which of these lowlevel functions
 | 
			
		||||
 *            please consult the Newlib libc-manual
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @attention
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2020-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.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Includes */
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
#include <sys/times.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Variables */
 | 
			
		||||
extern int __io_putchar(int ch) __attribute__((weak));
 | 
			
		||||
extern int __io_getchar(void) __attribute__((weak));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char *__env[1] = { 0 };
 | 
			
		||||
char **environ = __env;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Functions */
 | 
			
		||||
void initialise_monitor_handles()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _getpid(void)
 | 
			
		||||
{
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _kill(int pid, int sig)
 | 
			
		||||
{
 | 
			
		||||
  (void)pid;
 | 
			
		||||
  (void)sig;
 | 
			
		||||
  errno = EINVAL;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void _exit (int status)
 | 
			
		||||
{
 | 
			
		||||
  _kill(status, -1);
 | 
			
		||||
  while (1) {}    /* Make sure we hang here */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__((weak)) int _read(int file, char *ptr, int len)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  int DataIdx;
 | 
			
		||||
 | 
			
		||||
  for (DataIdx = 0; DataIdx < len; DataIdx++)
 | 
			
		||||
  {
 | 
			
		||||
    *ptr++ = __io_getchar();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__((weak)) int _write(int file, char *ptr, int len)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  int DataIdx;
 | 
			
		||||
 | 
			
		||||
  for (DataIdx = 0; DataIdx < len; DataIdx++)
 | 
			
		||||
  {
 | 
			
		||||
    __io_putchar(*ptr++);
 | 
			
		||||
  }
 | 
			
		||||
  return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _close(int file)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int _fstat(int file, struct stat *st)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  st->st_mode = S_IFCHR;
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _isatty(int file)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _lseek(int file, int ptr, int dir)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  (void)ptr;
 | 
			
		||||
  (void)dir;
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _open(char *path, int flags, ...)
 | 
			
		||||
{
 | 
			
		||||
  (void)path;
 | 
			
		||||
  (void)flags;
 | 
			
		||||
  /* Pretend like we always fail */
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _wait(int *status)
 | 
			
		||||
{
 | 
			
		||||
  (void)status;
 | 
			
		||||
  errno = ECHILD;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _unlink(char *name)
 | 
			
		||||
{
 | 
			
		||||
  (void)name;
 | 
			
		||||
  errno = ENOENT;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _times(struct tms *buf)
 | 
			
		||||
{
 | 
			
		||||
  (void)buf;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _stat(char *file, struct stat *st)
 | 
			
		||||
{
 | 
			
		||||
  (void)file;
 | 
			
		||||
  st->st_mode = S_IFCHR;
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _link(char *old, char *new)
 | 
			
		||||
{
 | 
			
		||||
  (void)old;
 | 
			
		||||
  (void)new;
 | 
			
		||||
  errno = EMLINK;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _fork(void)
 | 
			
		||||
{
 | 
			
		||||
  errno = EAGAIN;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _execve(char *name, char **argv, char **env)
 | 
			
		||||
{
 | 
			
		||||
  (void)name;
 | 
			
		||||
  (void)argv;
 | 
			
		||||
  (void)env;
 | 
			
		||||
  errno = ENOMEM;
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								Core/Src/sysmem.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								Core/Src/sysmem.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,79 @@
 | 
			
		||||
/**
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @file      sysmem.c
 | 
			
		||||
 * @author    Generated by STM32CubeMX
 | 
			
		||||
 * @brief     System Memory calls file
 | 
			
		||||
 *
 | 
			
		||||
 *            For more information about which C functions
 | 
			
		||||
 *            need which of these lowlevel functions
 | 
			
		||||
 *            please consult the newlib libc manual
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @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.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Includes */
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pointer to the current high watermark of the heap usage
 | 
			
		||||
 */
 | 
			
		||||
static uint8_t *__sbrk_heap_end = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief _sbrk() allocates memory to the newlib heap and is used by malloc
 | 
			
		||||
 *        and others from the C library
 | 
			
		||||
 *
 | 
			
		||||
 * @verbatim
 | 
			
		||||
 * ############################################################################
 | 
			
		||||
 * #  .data  #  .bss  #       newlib heap       #          MSP stack          #
 | 
			
		||||
 * #         #        #                         # Reserved by _Min_Stack_Size #
 | 
			
		||||
 * ############################################################################
 | 
			
		||||
 * ^-- RAM start      ^-- _end                             _estack, RAM end --^
 | 
			
		||||
 * @endverbatim
 | 
			
		||||
 *
 | 
			
		||||
 * This implementation starts allocating at the '_end' linker symbol
 | 
			
		||||
 * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
 | 
			
		||||
 * The implementation considers '_estack' linker symbol to be RAM end
 | 
			
		||||
 * NOTE: If the MSP stack, at any point during execution, grows larger than the
 | 
			
		||||
 * reserved size, please increase the '_Min_Stack_Size'.
 | 
			
		||||
 *
 | 
			
		||||
 * @param incr Memory size
 | 
			
		||||
 * @return Pointer to allocated memory
 | 
			
		||||
 */
 | 
			
		||||
void *_sbrk(ptrdiff_t incr)
 | 
			
		||||
{
 | 
			
		||||
  extern uint8_t _end; /* Symbol defined in the linker script */
 | 
			
		||||
  extern uint8_t _estack; /* Symbol defined in the linker script */
 | 
			
		||||
  extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
 | 
			
		||||
  const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
 | 
			
		||||
  const uint8_t *max_heap = (uint8_t *)stack_limit;
 | 
			
		||||
  uint8_t *prev_heap_end;
 | 
			
		||||
 | 
			
		||||
  /* Initialize heap end at first call */
 | 
			
		||||
  if (NULL == __sbrk_heap_end)
 | 
			
		||||
  {
 | 
			
		||||
    __sbrk_heap_end = &_end;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Protect heap from growing into the reserved MSP stack */
 | 
			
		||||
  if (__sbrk_heap_end + incr > max_heap)
 | 
			
		||||
  {
 | 
			
		||||
    errno = ENOMEM;
 | 
			
		||||
    return (void *)-1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  prev_heap_end = __sbrk_heap_end;
 | 
			
		||||
  __sbrk_heap_end += incr;
 | 
			
		||||
 | 
			
		||||
  return (void *)prev_heap_end;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										287
									
								
								Core/Src/system_stm32f3xx.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								Core/Src/system_stm32f3xx.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,287 @@
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    system_stm32f3xx.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @brief   CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
 | 
			
		||||
  *
 | 
			
		||||
  * 1. This file provides two functions and one global variable to be called from
 | 
			
		||||
  *    user application:
 | 
			
		||||
  *      - SystemInit(): This function is called at startup just after reset and 
 | 
			
		||||
  *                      before branch to main program. This call is made inside
 | 
			
		||||
  *                      the "startup_stm32f3xx.s" file.
 | 
			
		||||
  *
 | 
			
		||||
  *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
 | 
			
		||||
  *                                  by the user application to setup the SysTick
 | 
			
		||||
  *                                  timer or configure other parameters.
 | 
			
		||||
  *
 | 
			
		||||
  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
 | 
			
		||||
  *                                 be called whenever the core clock is changed
 | 
			
		||||
  *                                 during program execution.
 | 
			
		||||
  *
 | 
			
		||||
  * 2. After each device reset the HSI (8 MHz) is used as system clock source.
 | 
			
		||||
  *    Then SystemInit() function is called, in "startup_stm32f3xx.s" file, to
 | 
			
		||||
  *    configure the system clock before to branch to main program.
 | 
			
		||||
  *
 | 
			
		||||
  * 3. This file configures the system clock as follows:
 | 
			
		||||
  *=============================================================================
 | 
			
		||||
  *                         Supported STM32F3xx device
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        System Clock source                    | HSI
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        SYSCLK(Hz)                             | 8000000
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        HCLK(Hz)                               | 8000000
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        AHB Prescaler                          | 1
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        APB2 Prescaler                         | 1
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        APB1 Prescaler                         | 1
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *        USB Clock                              | DISABLE
 | 
			
		||||
  *-----------------------------------------------------------------------------
 | 
			
		||||
  *=============================================================================
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2016 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.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup CMSIS
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup stm32f3xx_system
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_Includes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#include "stm32f3xx.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_TypesDefinitions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_Defines
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (HSE_VALUE) 
 | 
			
		||||
  #define HSE_VALUE    ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz.
 | 
			
		||||
                                                This value can be provided and adapted by the user application. */
 | 
			
		||||
#endif /* HSE_VALUE */
 | 
			
		||||
 | 
			
		||||
#if !defined  (HSI_VALUE)
 | 
			
		||||
  #define HSI_VALUE    ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz.
 | 
			
		||||
                                                This value can be provided and adapted by the user application. */
 | 
			
		||||
#endif /* HSI_VALUE */
 | 
			
		||||
 | 
			
		||||
/* Note: Following vector table addresses must be defined in line with linker
 | 
			
		||||
         configuration. */
 | 
			
		||||
/*!< Uncomment the following line if you need to relocate the vector table
 | 
			
		||||
     anywhere in Flash or Sram, else the vector table is kept at the automatic
 | 
			
		||||
     remap of boot address selected */
 | 
			
		||||
/* #define USER_VECT_TAB_ADDRESS */
 | 
			
		||||
 | 
			
		||||
#if defined(USER_VECT_TAB_ADDRESS)
 | 
			
		||||
/*!< Uncomment the following line if you need to relocate your vector Table
 | 
			
		||||
     in Sram else user remap will be done in Flash. */
 | 
			
		||||
/* #define VECT_TAB_SRAM */
 | 
			
		||||
#if defined(VECT_TAB_SRAM)
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
 | 
			
		||||
                                                     This value must be a multiple of 0x200. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
 | 
			
		||||
                                                     This value must be a multiple of 0x200. */
 | 
			
		||||
#else
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
 | 
			
		||||
                                                     This value must be a multiple of 0x200. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
 | 
			
		||||
                                                     This value must be a multiple of 0x200. */
 | 
			
		||||
#endif /* VECT_TAB_SRAM */
 | 
			
		||||
#endif /* USER_VECT_TAB_ADDRESS */
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_Variables
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
  /* This variable is updated in three ways:
 | 
			
		||||
      1) by calling CMSIS function SystemCoreClockUpdate()
 | 
			
		||||
      2) by calling HAL API function HAL_RCC_GetHCLKFreq()
 | 
			
		||||
      3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
 | 
			
		||||
         Note: If you use this function to configure the system clock there is no need to
 | 
			
		||||
               call the 2 first functions listed above, since SystemCoreClock variable is 
 | 
			
		||||
               updated automatically.
 | 
			
		||||
  */
 | 
			
		||||
uint32_t SystemCoreClock = 8000000;
 | 
			
		||||
 | 
			
		||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
 | 
			
		||||
const uint8_t APBPrescTable[8]  = {0, 0, 0, 0, 1, 2, 3, 4};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_FunctionPrototypes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32F3xx_System_Private_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Setup the microcontroller system
 | 
			
		||||
  * @param  None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void SystemInit(void)
 | 
			
		||||
{
 | 
			
		||||
/* FPU settings --------------------------------------------------------------*/
 | 
			
		||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
 | 
			
		||||
  SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Configure the Vector Table location -------------------------------------*/
 | 
			
		||||
#if defined(USER_VECT_TAB_ADDRESS)
 | 
			
		||||
  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
 | 
			
		||||
#endif /* USER_VECT_TAB_ADDRESS */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
   * @brief  Update SystemCoreClock variable according to Clock Register Values.
 | 
			
		||||
  *         The SystemCoreClock variable contains the core clock (HCLK), it can
 | 
			
		||||
  *         be used by the user application to setup the SysTick timer or configure
 | 
			
		||||
  *         other parameters.
 | 
			
		||||
  *
 | 
			
		||||
  * @note   Each time the core clock (HCLK) changes, this function must be called
 | 
			
		||||
  *         to update SystemCoreClock variable value. Otherwise, any configuration
 | 
			
		||||
  *         based on this variable will be incorrect.
 | 
			
		||||
  *
 | 
			
		||||
  * @note   - The system frequency computed by this function is not the real
 | 
			
		||||
  *           frequency in the chip. It is calculated based on the predefined
 | 
			
		||||
  *           constant and the selected clock source:
 | 
			
		||||
  *
 | 
			
		||||
  *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
 | 
			
		||||
  *
 | 
			
		||||
  *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
 | 
			
		||||
  *
 | 
			
		||||
  *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
 | 
			
		||||
  *             or HSI_VALUE(*) multiplied/divided by the PLL factors.
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) HSI_VALUE is a constant defined in stm32f3xx_hal.h file (default value
 | 
			
		||||
  *             8 MHz) but the real value may vary depending on the variations
 | 
			
		||||
  *             in voltage and temperature.
 | 
			
		||||
  *
 | 
			
		||||
  *         (**) HSE_VALUE is a constant defined in stm32f3xx_hal.h file (default value
 | 
			
		||||
  *              8 MHz), user has to ensure that HSE_VALUE is same as the real
 | 
			
		||||
  *              frequency of the crystal used. Otherwise, this function may
 | 
			
		||||
  *              have wrong result.
 | 
			
		||||
  *
 | 
			
		||||
  *         - The result of this function could be not correct when using fractional
 | 
			
		||||
  *           value for HSE crystal.
 | 
			
		||||
  *
 | 
			
		||||
  * @param  None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void SystemCoreClockUpdate (void)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmp = 0, pllmull = 0, pllsource = 0, predivfactor = 0;
 | 
			
		||||
 | 
			
		||||
  /* Get SYSCLK source -------------------------------------------------------*/
 | 
			
		||||
  tmp = RCC->CFGR & RCC_CFGR_SWS;
 | 
			
		||||
 | 
			
		||||
  switch (tmp)
 | 
			
		||||
  {
 | 
			
		||||
    case RCC_CFGR_SWS_HSI:  /* HSI used as system clock */
 | 
			
		||||
      SystemCoreClock = HSI_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
    case RCC_CFGR_SWS_HSE:  /* HSE used as system clock */
 | 
			
		||||
      SystemCoreClock = HSE_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
    case RCC_CFGR_SWS_PLL:  /* PLL used as system clock */
 | 
			
		||||
      /* Get PLL clock source and multiplication factor ----------------------*/
 | 
			
		||||
      pllmull = RCC->CFGR & RCC_CFGR_PLLMUL;
 | 
			
		||||
      pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
 | 
			
		||||
      pllmull = ( pllmull >> 18) + 2;
 | 
			
		||||
 | 
			
		||||
#if defined (STM32F302xE) || defined (STM32F303xE) || defined (STM32F398xx)
 | 
			
		||||
        predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1;
 | 
			
		||||
      if (pllsource == RCC_CFGR_PLLSRC_HSE_PREDIV)
 | 
			
		||||
      {
 | 
			
		||||
        /* HSE oscillator clock selected as PREDIV1 clock entry */
 | 
			
		||||
        SystemCoreClock = (HSE_VALUE / predivfactor) * pllmull;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        /* HSI oscillator clock selected as PREDIV1 clock entry */
 | 
			
		||||
        SystemCoreClock = (HSI_VALUE / predivfactor) * pllmull;
 | 
			
		||||
      }
 | 
			
		||||
#else      
 | 
			
		||||
      if (pllsource == RCC_CFGR_PLLSRC_HSI_DIV2)
 | 
			
		||||
      {
 | 
			
		||||
        /* HSI oscillator clock divided by 2 selected as PLL clock entry */
 | 
			
		||||
        SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1;
 | 
			
		||||
        /* HSE oscillator clock selected as PREDIV1 clock entry */
 | 
			
		||||
        SystemCoreClock = (HSE_VALUE / predivfactor) * pllmull;
 | 
			
		||||
      }
 | 
			
		||||
#endif /* STM32F302xE || STM32F303xE || STM32F398xx */
 | 
			
		||||
      break;
 | 
			
		||||
    default: /* HSI used as system clock */
 | 
			
		||||
      SystemCoreClock = HSI_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  /* Compute HCLK clock frequency ----------------*/
 | 
			
		||||
  /* Get HCLK prescaler */
 | 
			
		||||
  tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
 | 
			
		||||
  /* HCLK clock frequency */
 | 
			
		||||
  SystemCoreClock >>= tmp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
		Reference in New Issue
	
	Block a user