Initial commit
This commit is contained in:
		
							
								
								
									
										110
									
								
								Core/Inc/main.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								Core/Inc/main.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,110 @@
 | 
			
		||||
/* 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) 2023 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 "stm32h7xx_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 */
 | 
			
		||||
 | 
			
		||||
/* Exported functions prototypes ---------------------------------------------*/
 | 
			
		||||
void Error_Handler(void);
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
/* Private defines -----------------------------------------------------------*/
 | 
			
		||||
#define B1_Pin GPIO_PIN_13
 | 
			
		||||
#define B1_GPIO_Port GPIOC
 | 
			
		||||
#define OSC32_IN_Pin GPIO_PIN_14
 | 
			
		||||
#define OSC32_IN_GPIO_Port GPIOC
 | 
			
		||||
#define OSC32_OUT_Pin GPIO_PIN_15
 | 
			
		||||
#define OSC32_OUT_GPIO_Port GPIOC
 | 
			
		||||
#define DISP_RESET_Pin GPIO_PIN_7
 | 
			
		||||
#define DISP_RESET_GPIO_Port GPIOF
 | 
			
		||||
#define USB_FS_PWR_EN_Pin GPIO_PIN_10
 | 
			
		||||
#define USB_FS_PWR_EN_GPIO_Port GPIOF
 | 
			
		||||
#define PH0_MCU_Pin GPIO_PIN_0
 | 
			
		||||
#define PH0_MCU_GPIO_Port GPIOH
 | 
			
		||||
#define PH1_MCU_Pin GPIO_PIN_1
 | 
			
		||||
#define PH1_MCU_GPIO_Port GPIOH
 | 
			
		||||
#define SPI1_SDA_Pin GPIO_PIN_7
 | 
			
		||||
#define SPI1_SDA_GPIO_Port GPIOA
 | 
			
		||||
#define LD1_Pin GPIO_PIN_0
 | 
			
		||||
#define LD1_GPIO_Port GPIOB
 | 
			
		||||
#define LD3_Pin GPIO_PIN_14
 | 
			
		||||
#define LD3_GPIO_Port GPIOB
 | 
			
		||||
#define STLINK_RX_Pin GPIO_PIN_8
 | 
			
		||||
#define STLINK_RX_GPIO_Port GPIOD
 | 
			
		||||
#define STLINK_TX_Pin GPIO_PIN_9
 | 
			
		||||
#define STLINK_TX_GPIO_Port GPIOD
 | 
			
		||||
#define USB_FS_OVCR_Pin GPIO_PIN_7
 | 
			
		||||
#define USB_FS_OVCR_GPIO_Port GPIOG
 | 
			
		||||
#define USB_FS_VBUS_Pin GPIO_PIN_9
 | 
			
		||||
#define USB_FS_VBUS_GPIO_Port GPIOA
 | 
			
		||||
#define USB_FS_ID_Pin GPIO_PIN_10
 | 
			
		||||
#define USB_FS_ID_GPIO_Port GPIOA
 | 
			
		||||
#define USB_FS_N_Pin GPIO_PIN_11
 | 
			
		||||
#define USB_FS_N_GPIO_Port GPIOA
 | 
			
		||||
#define USB_FS_P_Pin GPIO_PIN_12
 | 
			
		||||
#define USB_FS_P_GPIO_Port GPIOA
 | 
			
		||||
#define SPI1_CSX_Pin GPIO_PIN_10
 | 
			
		||||
#define SPI1_CSX_GPIO_Port GPIOG
 | 
			
		||||
#define SPI1_SCL_Pin GPIO_PIN_11
 | 
			
		||||
#define SPI1_SCL_GPIO_Port GPIOG
 | 
			
		||||
#define SPI1_DCX_Pin GPIO_PIN_13
 | 
			
		||||
#define SPI1_DCX_GPIO_Port GPIOG
 | 
			
		||||
#define LD2_Pin GPIO_PIN_1
 | 
			
		||||
#define LD2_GPIO_Port GPIOE
 | 
			
		||||
/* USER CODE BEGIN Private defines */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Private defines */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __MAIN_H */
 | 
			
		||||
							
								
								
									
										510
									
								
								Core/Inc/stm32h7xx_hal_conf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										510
									
								
								Core/Inc/stm32h7xx_hal_conf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,510 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32h7xx_hal_conf.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @brief   HAL configuration file.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2017 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 STM32H7xx_HAL_CONF_H
 | 
			
		||||
#define STM32H7xx_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_FDCAN_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_FMAC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_CEC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_COMP_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_CORDIC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_CRC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_CRYP_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DAC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DCMI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DMA2D_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_ETH_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_NAND_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_NOR_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_OTFDEC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SRAM_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SDRAM_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_HASH_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_HRTIM_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_HSEM_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_GFXMMU_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_JPEG_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_OPAMP_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_OSPI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_OSPI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_I2S_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SMBUS_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_IWDG_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_LPTIM_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_LTDC_MODULE_ENABLED
 | 
			
		||||
/* #define HAL_QSPI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_RAMECC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_RNG_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_RTC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SAI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SD_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_MMC_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SPDIFRX_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SPI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_SWPMI_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_WWDG_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_PCD_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_HCD_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DFSDM_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DSI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_JPEG_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_MDIOS_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_PSSI_MODULE_ENABLED   */
 | 
			
		||||
/* #define HAL_DTS_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_GPIO_MODULE_ENABLED
 | 
			
		||||
#define HAL_DMA_MODULE_ENABLED
 | 
			
		||||
#define HAL_MDMA_MODULE_ENABLED
 | 
			
		||||
#define HAL_RCC_MODULE_ENABLED
 | 
			
		||||
#define HAL_FLASH_MODULE_ENABLED
 | 
			
		||||
#define HAL_EXTI_MODULE_ENABLED
 | 
			
		||||
#define HAL_PWR_MODULE_ENABLED
 | 
			
		||||
#define HAL_I2C_MODULE_ENABLED
 | 
			
		||||
#define HAL_CORTEX_MODULE_ENABLED
 | 
			
		||||
#define HAL_HSEM_MODULE_ENABLED
 | 
			
		||||
 | 
			
		||||
/* ########################## Oscillator 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    (8000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
 | 
			
		||||
#endif /* HSE_VALUE */
 | 
			
		||||
 | 
			
		||||
#if !defined  (HSE_STARTUP_TIMEOUT)
 | 
			
		||||
  #define HSE_STARTUP_TIMEOUT    (100UL)   /*!< Time out for HSE start up, in ms */
 | 
			
		||||
#endif /* HSE_STARTUP_TIMEOUT */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Internal  oscillator (CSI) default value.
 | 
			
		||||
  *        This value is the default CSI value after Reset.
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (CSI_VALUE)
 | 
			
		||||
  #define CSI_VALUE    (4000000UL) /*!< Value of the Internal oscillator in Hz*/
 | 
			
		||||
#endif /* CSI_VALUE */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @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    (64000000UL) /*!< Value of the Internal oscillator in Hz*/
 | 
			
		||||
#endif /* HSI_VALUE */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief External Low Speed oscillator (LSE) value.
 | 
			
		||||
  *        This value is used by the UART, RTC HAL module to compute the system frequency
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (LSE_VALUE)
 | 
			
		||||
  #define LSE_VALUE    (32768UL) /*!< Value of the External oscillator in Hz*/
 | 
			
		||||
#endif /* LSE_VALUE */
 | 
			
		||||
 | 
			
		||||
#if !defined  (LSE_STARTUP_TIMEOUT)
 | 
			
		||||
  #define LSE_STARTUP_TIMEOUT    (5000UL)   /*!< Time out for LSE start up, in ms */
 | 
			
		||||
#endif /* LSE_STARTUP_TIMEOUT */
 | 
			
		||||
 | 
			
		||||
#if !defined  (LSI_VALUE)
 | 
			
		||||
  #define LSI_VALUE  (32000UL)              /*!< LSI Typical Value in Hz*/
 | 
			
		||||
#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 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.
 | 
			
		||||
  */
 | 
			
		||||
#if !defined  (EXTERNAL_CLOCK_VALUE)
 | 
			
		||||
  #define EXTERNAL_CLOCK_VALUE    12288000UL /*!< Value of the External clock 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                    (3300UL) /*!< Value of VDD in mv */
 | 
			
		||||
#define  TICK_INT_PRIORITY            (0UL) /*!< tick interrupt priority */
 | 
			
		||||
#define  USE_RTOS                     0
 | 
			
		||||
#define  USE_SD_TRANSCEIVER           0U               /*!< use uSD Transceiver */
 | 
			
		||||
#define  USE_SPI_CRC	              0U               /*!< use CRC in SPI */
 | 
			
		||||
 | 
			
		||||
#define  USE_HAL_ADC_REGISTER_CALLBACKS     0U /* ADC register callback disabled     */
 | 
			
		||||
#define  USE_HAL_CEC_REGISTER_CALLBACKS     0U /* CEC register callback disabled     */
 | 
			
		||||
#define  USE_HAL_COMP_REGISTER_CALLBACKS    0U /* COMP register callback disabled    */
 | 
			
		||||
#define  USE_HAL_CORDIC_REGISTER_CALLBACKS  0U /* CORDIC register callback disabled  */
 | 
			
		||||
#define  USE_HAL_CRYP_REGISTER_CALLBACKS    0U /* CRYP register callback disabled    */
 | 
			
		||||
#define  USE_HAL_DAC_REGISTER_CALLBACKS     0U /* DAC register callback disabled     */
 | 
			
		||||
#define  USE_HAL_DCMI_REGISTER_CALLBACKS    0U /* DCMI register callback disabled    */
 | 
			
		||||
#define  USE_HAL_DFSDM_REGISTER_CALLBACKS   0U /* DFSDM register callback disabled   */
 | 
			
		||||
#define  USE_HAL_DMA2D_REGISTER_CALLBACKS   0U /* DMA2D register callback disabled   */
 | 
			
		||||
#define  USE_HAL_DSI_REGISTER_CALLBACKS     0U /* DSI register callback disabled     */
 | 
			
		||||
#define  USE_HAL_DTS_REGISTER_CALLBACKS     0U /* DTS register callback disabled     */
 | 
			
		||||
#define  USE_HAL_ETH_REGISTER_CALLBACKS     0U /* ETH register callback disabled     */
 | 
			
		||||
#define  USE_HAL_FDCAN_REGISTER_CALLBACKS   0U /* FDCAN register callback disabled   */
 | 
			
		||||
#define  USE_HAL_FMAC_REGISTER_CALLBACKS    0U /* FMAC 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_SDRAM_REGISTER_CALLBACKS   0U /* SDRAM register callback disabled   */
 | 
			
		||||
#define  USE_HAL_SRAM_REGISTER_CALLBACKS    0U /* SRAM register callback disabled    */
 | 
			
		||||
#define  USE_HAL_HASH_REGISTER_CALLBACKS    0U /* HASH register callback disabled    */
 | 
			
		||||
#define  USE_HAL_HCD_REGISTER_CALLBACKS     0U /* HCD register callback disabled     */
 | 
			
		||||
#define  USE_HAL_GFXMMU_REGISTER_CALLBACKS  0U /* GFXMMU 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_I2S_REGISTER_CALLBACKS     0U /* I2S register callback disabled     */
 | 
			
		||||
#define  USE_HAL_IRDA_REGISTER_CALLBACKS    0U /* IRDA register callback disabled    */
 | 
			
		||||
#define  USE_HAL_JPEG_REGISTER_CALLBACKS    0U /* JPEG register callback disabled    */
 | 
			
		||||
#define  USE_HAL_LPTIM_REGISTER_CALLBACKS   0U /* LPTIM register callback disabled   */
 | 
			
		||||
#define  USE_HAL_LTDC_REGISTER_CALLBACKS    0U /* LTDC register callback disabled    */
 | 
			
		||||
#define  USE_HAL_MDIOS_REGISTER_CALLBACKS   0U /* MDIO register callback disabled    */
 | 
			
		||||
#define  USE_HAL_MMC_REGISTER_CALLBACKS     0U /* MMC register callback disabled     */
 | 
			
		||||
#define  USE_HAL_OPAMP_REGISTER_CALLBACKS   0U /* MDIO register callback disabled    */
 | 
			
		||||
#define  USE_HAL_OSPI_REGISTER_CALLBACKS    0U /* OSPI register callback disabled    */
 | 
			
		||||
#define  USE_HAL_OTFDEC_REGISTER_CALLBACKS  0U /* OTFDEC register callback disabled  */
 | 
			
		||||
#define  USE_HAL_PCD_REGISTER_CALLBACKS     0U /* PCD register callback disabled     */
 | 
			
		||||
#define  USE_HAL_QSPI_REGISTER_CALLBACKS    0U /* QSPI register callback disabled    */
 | 
			
		||||
#define  USE_HAL_RNG_REGISTER_CALLBACKS     0U /* RNG register callback disabled     */
 | 
			
		||||
#define  USE_HAL_RTC_REGISTER_CALLBACKS     0U /* RTC register callback disabled     */
 | 
			
		||||
#define  USE_HAL_SAI_REGISTER_CALLBACKS     0U /* SAI register callback disabled     */
 | 
			
		||||
#define  USE_HAL_SD_REGISTER_CALLBACKS      0U /* SD register callback disabled      */
 | 
			
		||||
#define  USE_HAL_SMARTCARD_REGISTER_CALLBACKS  0U /* SMARTCARD register callback disabled */
 | 
			
		||||
#define  USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
 | 
			
		||||
#define  USE_HAL_SMBUS_REGISTER_CALLBACKS   0U /* SMBUS register callback disabled   */
 | 
			
		||||
#define  USE_HAL_SPI_REGISTER_CALLBACKS     0U /* SPI register callback disabled     */
 | 
			
		||||
#define  USE_HAL_SWPMI_REGISTER_CALLBACKS   0U /* SWPMI register callback disabled   */
 | 
			
		||||
#define  USE_HAL_TIM_REGISTER_CALLBACKS     0U /* TIM register callback disabled     */
 | 
			
		||||
#define  USE_HAL_UART_REGISTER_CALLBACKS    0U /* UART register callback disabled    */
 | 
			
		||||
#define  USE_HAL_USART_REGISTER_CALLBACKS   0U /* USART register callback disabled   */
 | 
			
		||||
#define  USE_HAL_WWDG_REGISTER_CALLBACKS    0U /* WWDG register callback disabled    */
 | 
			
		||||
 | 
			
		||||
/* ########################### Ethernet Configuration ######################### */
 | 
			
		||||
#define ETH_TX_DESC_CNT         4  /* number of Ethernet Tx DMA descriptors */
 | 
			
		||||
#define ETH_RX_DESC_CNT         4  /* number of Ethernet Rx DMA descriptors */
 | 
			
		||||
 | 
			
		||||
#define ETH_MAC_ADDR0    (0x02UL)
 | 
			
		||||
#define ETH_MAC_ADDR1    (0x00UL)
 | 
			
		||||
#define ETH_MAC_ADDR2    (0x00UL)
 | 
			
		||||
#define ETH_MAC_ADDR3    (0x00UL)
 | 
			
		||||
#define ETH_MAC_ADDR4    (0x00UL)
 | 
			
		||||
#define ETH_MAC_ADDR5    (0x00UL)
 | 
			
		||||
 | 
			
		||||
/* ########################## 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 "stm32h7xx_hal_rcc.h"
 | 
			
		||||
#endif /* HAL_RCC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_GPIO_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_gpio.h"
 | 
			
		||||
#endif /* HAL_GPIO_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DMA_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dma.h"
 | 
			
		||||
#endif /* HAL_DMA_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_MDMA_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_mdma.h"
 | 
			
		||||
#endif /* HAL_MDMA_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_HASH_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_hash.h"
 | 
			
		||||
#endif /* HAL_HASH_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DCMI_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dcmi.h"
 | 
			
		||||
#endif /* HAL_DCMI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DMA2D_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dma2d.h"
 | 
			
		||||
#endif /* HAL_DMA2D_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DSI_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dsi.h"
 | 
			
		||||
#endif /* HAL_DSI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DFSDM_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dfsdm.h"
 | 
			
		||||
#endif /* HAL_DFSDM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DTS_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_dts.h"
 | 
			
		||||
#endif /* HAL_DTS_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_ETH_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_eth.h"
 | 
			
		||||
#endif /* HAL_ETH_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_EXTI_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_exti.h"
 | 
			
		||||
#endif /* HAL_EXTI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CORTEX_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_cortex.h"
 | 
			
		||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_ADC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_adc.h"
 | 
			
		||||
#endif /* HAL_ADC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_FDCAN_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_fdcan.h"
 | 
			
		||||
#endif /* HAL_FDCAN_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CEC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_cec.h"
 | 
			
		||||
#endif /* HAL_CEC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_COMP_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_comp.h"
 | 
			
		||||
#endif /* HAL_COMP_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CORDIC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_cordic.h"
 | 
			
		||||
#endif /* HAL_CORDIC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CRC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_crc.h"
 | 
			
		||||
#endif /* HAL_CRC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_CRYP_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_cryp.h"
 | 
			
		||||
#endif /* HAL_CRYP_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_DAC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_dac.h"
 | 
			
		||||
#endif /* HAL_DAC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_FLASH_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_flash.h"
 | 
			
		||||
#endif /* HAL_FLASH_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_GFXMMU_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_gfxmmu.h"
 | 
			
		||||
#endif /* HAL_GFXMMU_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_FMAC_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_fmac.h"
 | 
			
		||||
#endif /* HAL_FMAC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_HRTIM_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_hrtim.h"
 | 
			
		||||
#endif /* HAL_HRTIM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_HSEM_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_hsem.h"
 | 
			
		||||
#endif /* HAL_HSEM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SRAM_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_sram.h"
 | 
			
		||||
#endif /* HAL_SRAM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_NOR_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_nor.h"
 | 
			
		||||
#endif /* HAL_NOR_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_NAND_MODULE_ENABLED
 | 
			
		||||
  #include "stm32h7xx_hal_nand.h"
 | 
			
		||||
#endif /* HAL_NAND_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_I2C_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_i2c.h"
 | 
			
		||||
#endif /* HAL_I2C_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_I2S_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_i2s.h"
 | 
			
		||||
#endif /* HAL_I2S_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_IWDG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_iwdg.h"
 | 
			
		||||
#endif /* HAL_IWDG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_JPEG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_jpeg.h"
 | 
			
		||||
#endif /* HAL_JPEG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_MDIOS_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_mdios.h"
 | 
			
		||||
#endif /* HAL_MDIOS_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_MMC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_mmc.h"
 | 
			
		||||
#endif /* HAL_MMC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_LPTIM_MODULE_ENABLED
 | 
			
		||||
#include "stm32h7xx_hal_lptim.h"
 | 
			
		||||
#endif /* HAL_LPTIM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_LTDC_MODULE_ENABLED
 | 
			
		||||
#include "stm32h7xx_hal_ltdc.h"
 | 
			
		||||
#endif /* HAL_LTDC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_OPAMP_MODULE_ENABLED
 | 
			
		||||
#include "stm32h7xx_hal_opamp.h"
 | 
			
		||||
#endif /* HAL_OPAMP_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_OSPI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_ospi.h"
 | 
			
		||||
#endif /* HAL_OSPI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_OTFDEC_MODULE_ENABLED
 | 
			
		||||
#include "stm32h7xx_hal_otfdec.h"
 | 
			
		||||
#endif /* HAL_OTFDEC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PSSI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_pssi.h"
 | 
			
		||||
#endif /* HAL_PSSI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PWR_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_pwr.h"
 | 
			
		||||
#endif /* HAL_PWR_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_QSPI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_qspi.h"
 | 
			
		||||
#endif /* HAL_QSPI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_RAMECC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_ramecc.h"
 | 
			
		||||
#endif /* HAL_RAMECC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_RNG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_rng.h"
 | 
			
		||||
#endif /* HAL_RNG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_RTC_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_rtc.h"
 | 
			
		||||
#endif /* HAL_RTC_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SAI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_sai.h"
 | 
			
		||||
#endif /* HAL_SAI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_sd.h"
 | 
			
		||||
#endif /* HAL_SD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SDRAM_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_sdram.h"
 | 
			
		||||
#endif /* HAL_SDRAM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SPI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_spi.h"
 | 
			
		||||
#endif /* HAL_SPI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SPDIFRX_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_spdifrx.h"
 | 
			
		||||
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SWPMI_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_swpmi.h"
 | 
			
		||||
#endif /* HAL_SWPMI_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_TIM_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_tim.h"
 | 
			
		||||
#endif /* HAL_TIM_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_UART_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_uart.h"
 | 
			
		||||
#endif /* HAL_UART_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_USART_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_usart.h"
 | 
			
		||||
#endif /* HAL_USART_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_IRDA_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_irda.h"
 | 
			
		||||
#endif /* HAL_IRDA_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_smartcard.h"
 | 
			
		||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_SMBUS_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_smbus.h"
 | 
			
		||||
#endif /* HAL_SMBUS_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_WWDG_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_wwdg.h"
 | 
			
		||||
#endif /* HAL_WWDG_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_PCD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_pcd.h"
 | 
			
		||||
#endif /* HAL_PCD_MODULE_ENABLED */
 | 
			
		||||
 | 
			
		||||
#ifdef HAL_HCD_MODULE_ENABLED
 | 
			
		||||
 #include "stm32h7xx_hal_hcd.h"
 | 
			
		||||
#endif /* HAL_HCD_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 /* STM32H7xx_HAL_CONF_H */
 | 
			
		||||
							
								
								
									
										68
									
								
								Core/Inc/stm32h7xx_it.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								Core/Inc/stm32h7xx_it.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32h7xx_it.h
 | 
			
		||||
  * @brief   This file contains the headers of the interrupt handlers.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2023 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 __STM32H7xx_IT_H
 | 
			
		||||
#define __STM32H7xx_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);
 | 
			
		||||
void LTDC_IRQHandler(void);
 | 
			
		||||
void LTDC_ER_IRQHandler(void);
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32H7xx_IT_H */
 | 
			
		||||
							
								
								
									
										549
									
								
								Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										549
									
								
								Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,549 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @file           : main.c
 | 
			
		||||
 * @brief          : Main program body
 | 
			
		||||
 ******************************************************************************
 | 
			
		||||
 * @attention
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2023 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 ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
LTDC_HandleTypeDef hltdc;
 | 
			
		||||
 | 
			
		||||
UART_HandleTypeDef huart3;
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN PV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PV */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
void SystemClock_Config(void);
 | 
			
		||||
static void MPU_Config(void);
 | 
			
		||||
static void MX_GPIO_Init(void);
 | 
			
		||||
static void MX_LTDC_Init(void);
 | 
			
		||||
static void MX_USART3_UART_Init(void);
 | 
			
		||||
static void MX_USB_OTG_HS_USB_Init(void);
 | 
			
		||||
/* USER CODE BEGIN PFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PFP */
 | 
			
		||||
 | 
			
		||||
/* Private user code ---------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN 0 */
 | 
			
		||||
void DISP_WriteData(uint8_t *data, size_t data_len) {
 | 
			
		||||
  for (size_t byte = 0; byte < data_len; byte++) {
 | 
			
		||||
    for (size_t bit = 0; bit < 8; bit++) {
 | 
			
		||||
      GPIO_PinState state =
 | 
			
		||||
          ((data[byte] >> (7 - bit)) & 1) ? GPIO_PIN_SET : GPIO_PIN_RESET;
 | 
			
		||||
      HAL_GPIO_WritePin(SPI1_SCL_GPIO_Port, SPI1_SCL_Pin, GPIO_PIN_RESET);
 | 
			
		||||
      HAL_GPIO_WritePin(SPI1_SDA_GPIO_Port, SPI1_SDA_Pin, state);
 | 
			
		||||
      HAL_Delay(1);
 | 
			
		||||
      HAL_GPIO_WritePin(SPI1_SCL_GPIO_Port, SPI1_SCL_Pin, GPIO_PIN_SET);
 | 
			
		||||
      HAL_Delay(1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DISP_WriteReg(uint8_t addr, uint8_t *data, size_t data_len) {
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_CSX_GPIO_Port, SPI1_CSX_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_DCX_GPIO_Port, SPI1_DCX_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_Delay(1);
 | 
			
		||||
 | 
			
		||||
  DISP_WriteData(&addr, 1);
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_DCX_GPIO_Port, SPI1_DCX_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_Delay(1);
 | 
			
		||||
 | 
			
		||||
  if (data_len > 0) {
 | 
			
		||||
    DISP_WriteData(data, data_len);
 | 
			
		||||
  }
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_CSX_GPIO_Port, SPI1_CSX_Pin, GPIO_PIN_SET);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DISP_Init() {
 | 
			
		||||
  // SET password
 | 
			
		||||
  uint8_t data0[] = {0xFF, 0x83, 0x57};
 | 
			
		||||
  DISP_WriteReg(0xB9, data0, sizeof(data0));
 | 
			
		||||
  // SET power
 | 
			
		||||
  uint8_t data1[] = {0x00, 0x16, 0x1C, 0x1C, 0xC3, 0x5C};
 | 
			
		||||
  DISP_WriteReg(0xB1, data1, sizeof(data1));
 | 
			
		||||
  // ?
 | 
			
		||||
  uint8_t data2[] = {0x53, 0x00, 0x05, 0x05};
 | 
			
		||||
  DISP_WriteReg(0xB3, data2, sizeof(data2));
 | 
			
		||||
  // SET cyc
 | 
			
		||||
  uint8_t data3[] = {0x32, 0x40, 0x00, 0x2A, 0x2A, 0x0D, 0x78};
 | 
			
		||||
  DISP_WriteReg(0xB4, data3, sizeof(data3));
 | 
			
		||||
  // VCOMDC
 | 
			
		||||
  uint8_t data4[] = {0x3C};
 | 
			
		||||
  DISP_WriteReg(0xB6, data4, sizeof(data4));
 | 
			
		||||
  // SET STBA
 | 
			
		||||
  uint8_t data5[] = {0x70, 0x50, 0x01, 0x3C, 0xC8, 0x08};
 | 
			
		||||
  DISP_WriteReg(0xC0, data5, sizeof(data5));
 | 
			
		||||
  // SET panel
 | 
			
		||||
  uint8_t data6[] = {0x0B};
 | 
			
		||||
  DISP_WriteReg(0xCC, data6, sizeof(data6));
 | 
			
		||||
  // VCOMDC
 | 
			
		||||
  uint8_t data7[] = {0x40};
 | 
			
		||||
  DISP_WriteReg(0xB6, data7, sizeof(data7));
 | 
			
		||||
  // Gamma
 | 
			
		||||
  uint8_t data8[] = {0x02, 0x0A, 0x10, 0x1A, 0x22, 0x34, 0x41, 0x4A, 0x4D,
 | 
			
		||||
                     0x44, 0x3A, 0x23, 0x19, 0x08, 0x09, 0x03, 0x02, 0x0A,
 | 
			
		||||
                     0x10, 0x1A, 0x22, 0x34, 0x41, 0x4A, 0x4D, 0x44, 0x3A,
 | 
			
		||||
                     0x23, 0x19, 0x08, 0x09, 0x03, 0x00, 0x01};
 | 
			
		||||
  DISP_WriteReg(0xE0, data8, sizeof(data8));
 | 
			
		||||
  // Display cycle register
 | 
			
		||||
  uint8_t data9[] = {0x00};
 | 
			
		||||
  DISP_WriteReg(0xB4, data9, sizeof(data9));
 | 
			
		||||
  // SET BGP
 | 
			
		||||
  uint8_t data10[] = {0x03, 0x03, 0x03};
 | 
			
		||||
  DISP_WriteReg(0xB5, data10, sizeof(data10));
 | 
			
		||||
  // ?
 | 
			
		||||
  uint8_t data11[] = {0xB0, 0x22, 0x3B};
 | 
			
		||||
  DISP_WriteReg(0xB6, data11, sizeof(data11));
 | 
			
		||||
  // COLMOD
 | 
			
		||||
  uint8_t data12[] = {0x66};
 | 
			
		||||
  DISP_WriteReg(0x3A, data12, sizeof(data12));
 | 
			
		||||
  // Sleep out
 | 
			
		||||
  DISP_WriteReg(0x11, NULL, 0);
 | 
			
		||||
  // Normal display mode
 | 
			
		||||
  DISP_WriteReg(0x13, NULL, 0);
 | 
			
		||||
  // Display on
 | 
			
		||||
}
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief  The application entry point.
 | 
			
		||||
 * @retval int
 | 
			
		||||
 */
 | 
			
		||||
int main(void) {
 | 
			
		||||
  /* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END 1 */
 | 
			
		||||
 | 
			
		||||
  /* MPU Configuration--------------------------------------------------------*/
 | 
			
		||||
  MPU_Config();
 | 
			
		||||
 | 
			
		||||
  /* 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_LTDC_Init();
 | 
			
		||||
  MX_USART3_UART_Init();
 | 
			
		||||
  MX_USB_OTG_HS_USB_Init();
 | 
			
		||||
  /* USER CODE BEGIN 2 */
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_CSX_GPIO_Port, SPI1_CSX_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_SCL_GPIO_Port, SPI1_SCL_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_GPIO_WritePin(DISP_RESET_GPIO_Port, DISP_RESET_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_Delay(1000);
 | 
			
		||||
  HAL_GPIO_WritePin(DISP_RESET_GPIO_Port, DISP_RESET_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_Delay(1000);
 | 
			
		||||
  DISP_Init();
 | 
			
		||||
  /* USER CODE END 2 */
 | 
			
		||||
 | 
			
		||||
  /* Infinite loop */
 | 
			
		||||
  /* USER CODE BEGIN WHILE */
 | 
			
		||||
  while (1) {
 | 
			
		||||
    /* USER CODE END WHILE */
 | 
			
		||||
 | 
			
		||||
    /* USER CODE BEGIN 3 */
 | 
			
		||||
    GPIO_PinState led =
 | 
			
		||||
        ((HAL_GetTick() / 500) % 2 == 0) ? GPIO_PIN_SET : GPIO_PIN_RESET;
 | 
			
		||||
    HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, led);
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END 3 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief System Clock Configuration
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
void SystemClock_Config(void) {
 | 
			
		||||
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 | 
			
		||||
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 | 
			
		||||
 | 
			
		||||
  /*AXI clock gating */
 | 
			
		||||
  RCC->CKGAENR = 0xFFFFFFFF;
 | 
			
		||||
 | 
			
		||||
  /** Supply configuration update enable
 | 
			
		||||
   */
 | 
			
		||||
  HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
 | 
			
		||||
 | 
			
		||||
  /** Configure the main internal regulator output voltage
 | 
			
		||||
   */
 | 
			
		||||
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
 | 
			
		||||
 | 
			
		||||
  while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Macro to configure the PLL clock source
 | 
			
		||||
   */
 | 
			
		||||
  __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);
 | 
			
		||||
 | 
			
		||||
  /** Initializes the RCC Oscillators according to the specified parameters
 | 
			
		||||
   * in the RCC_OscInitTypeDef structure.
 | 
			
		||||
   */
 | 
			
		||||
  RCC_OscInitStruct.OscillatorType =
 | 
			
		||||
      RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE;
 | 
			
		||||
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
 | 
			
		||||
  RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLM = 1;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLN = 24;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLP = 2;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLQ = 4;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLR = 2;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
 | 
			
		||||
  RCC_OscInitStruct.PLL.PLLFRACN = 0;
 | 
			
		||||
  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_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1;
 | 
			
		||||
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
 | 
			
		||||
  RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV1;
 | 
			
		||||
  RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1;
 | 
			
		||||
 | 
			
		||||
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief LTDC Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
static void MX_LTDC_Init(void) {
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN LTDC_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_Init 0 */
 | 
			
		||||
 | 
			
		||||
  LTDC_LayerCfgTypeDef pLayerCfg = {0};
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN LTDC_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_Init 1 */
 | 
			
		||||
  hltdc.Instance = LTDC;
 | 
			
		||||
  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
 | 
			
		||||
  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
 | 
			
		||||
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AH;
 | 
			
		||||
  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
 | 
			
		||||
  hltdc.Init.HorizontalSync = 5;
 | 
			
		||||
  hltdc.Init.VerticalSync = 2;
 | 
			
		||||
  hltdc.Init.AccumulatedHBP = 10;
 | 
			
		||||
  hltdc.Init.AccumulatedVBP = 4;
 | 
			
		||||
  hltdc.Init.AccumulatedActiveW = 330;
 | 
			
		||||
  hltdc.Init.AccumulatedActiveH = 484;
 | 
			
		||||
  hltdc.Init.TotalWidth = 335;
 | 
			
		||||
  hltdc.Init.TotalHeigh = 486;
 | 
			
		||||
  hltdc.Init.Backcolor.Blue = 0;
 | 
			
		||||
  hltdc.Init.Backcolor.Green = 0;
 | 
			
		||||
  hltdc.Init.Backcolor.Red = 255;
 | 
			
		||||
  if (HAL_LTDC_Init(&hltdc) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  pLayerCfg.WindowX0 = 0;
 | 
			
		||||
  pLayerCfg.WindowX1 = 0;
 | 
			
		||||
  pLayerCfg.WindowY0 = 0;
 | 
			
		||||
  pLayerCfg.WindowY1 = 0;
 | 
			
		||||
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB888;
 | 
			
		||||
  pLayerCfg.Alpha = 0;
 | 
			
		||||
  pLayerCfg.Alpha0 = 0;
 | 
			
		||||
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
 | 
			
		||||
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
 | 
			
		||||
  pLayerCfg.FBStartAdress = 0;
 | 
			
		||||
  pLayerCfg.ImageWidth = 0;
 | 
			
		||||
  pLayerCfg.ImageHeight = 0;
 | 
			
		||||
  pLayerCfg.Backcolor.Blue = 0;
 | 
			
		||||
  pLayerCfg.Backcolor.Green = 0;
 | 
			
		||||
  pLayerCfg.Backcolor.Red = 0;
 | 
			
		||||
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN LTDC_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_Init 2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief USART3 Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
static void MX_USART3_UART_Init(void) {
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART3_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART3_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_Init 1 */
 | 
			
		||||
  huart3.Instance = USART3;
 | 
			
		||||
  huart3.Init.BaudRate = 115200;
 | 
			
		||||
  huart3.Init.WordLength = UART_WORDLENGTH_8B;
 | 
			
		||||
  huart3.Init.StopBits = UART_STOPBITS_1;
 | 
			
		||||
  huart3.Init.Parity = UART_PARITY_NONE;
 | 
			
		||||
  huart3.Init.Mode = UART_MODE_TX_RX;
 | 
			
		||||
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 | 
			
		||||
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
 | 
			
		||||
  huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
 | 
			
		||||
  huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
 | 
			
		||||
  huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
 | 
			
		||||
  if (HAL_UART_Init(&huart3) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) !=
 | 
			
		||||
      HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) !=
 | 
			
		||||
      HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN USART3_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_Init 2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief USB_OTG_HS Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
static void MX_USB_OTG_HS_USB_Init(void) {
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USB_OTG_HS_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USB_OTG_HS_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USB_OTG_HS_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USB_OTG_HS_Init 1 */
 | 
			
		||||
  /* USER CODE BEGIN USB_OTG_HS_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USB_OTG_HS_Init 2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief GPIO Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
static void MX_GPIO_Init(void) {
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
 | 
			
		||||
  /* GPIO Ports Clock Enable */
 | 
			
		||||
  __HAL_RCC_GPIOC_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOF_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOH_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOE_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOD_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOG_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOF, DISP_RESET_Pin | USB_FS_PWR_EN_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(SPI1_SDA_GPIO_Port, SPI1_SDA_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOB, LD1_Pin | LD3_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOG, SPI1_CSX_Pin | SPI1_SCL_Pin | SPI1_DCX_Pin,
 | 
			
		||||
                    GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : B1_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = B1_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : DISP_RESET_Pin USB_FS_PWR_EN_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = DISP_RESET_Pin | USB_FS_PWR_EN_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : SPI1_SDA_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = SPI1_SDA_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(SPI1_SDA_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : LD1_Pin LD3_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = LD1_Pin | LD3_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 pin : USB_FS_OVCR_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = USB_FS_OVCR_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(USB_FS_OVCR_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : USB_FS_VBUS_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = USB_FS_VBUS_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(USB_FS_VBUS_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : USB_FS_ID_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = USB_FS_ID_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_HS;
 | 
			
		||||
  HAL_GPIO_Init(USB_FS_ID_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : USB_FS_N_Pin USB_FS_P_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = USB_FS_N_Pin | USB_FS_P_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : SPI1_CSX_Pin SPI1_SCL_Pin SPI1_DCX_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = SPI1_CSX_Pin | SPI1_SCL_Pin | SPI1_DCX_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : LD2_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = LD2_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 4 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 4 */
 | 
			
		||||
 | 
			
		||||
/* MPU Configuration */
 | 
			
		||||
 | 
			
		||||
void MPU_Config(void) {
 | 
			
		||||
  MPU_Region_InitTypeDef MPU_InitStruct = {0};
 | 
			
		||||
 | 
			
		||||
  /* Disables the MPU */
 | 
			
		||||
  HAL_MPU_Disable();
 | 
			
		||||
 | 
			
		||||
  /** Initializes and configures the Region and the memory to be protected
 | 
			
		||||
   */
 | 
			
		||||
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
 | 
			
		||||
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
 | 
			
		||||
  MPU_InitStruct.BaseAddress = 0x0;
 | 
			
		||||
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
 | 
			
		||||
  MPU_InitStruct.SubRegionDisable = 0x87;
 | 
			
		||||
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
 | 
			
		||||
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
 | 
			
		||||
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
 | 
			
		||||
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
 | 
			
		||||
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
 | 
			
		||||
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
 | 
			
		||||
 | 
			
		||||
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
 | 
			
		||||
  /* Enables the MPU */
 | 
			
		||||
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @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 */
 | 
			
		||||
							
								
								
									
										352
									
								
								Core/Src/stm32h7xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										352
									
								
								Core/Src/stm32h7xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,352 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file         stm32h7xx_hal_msp.c
 | 
			
		||||
  * @brief        This file provides code for the MSP Initialization
 | 
			
		||||
  *               and de-Initialization codes.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2023 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 */
 | 
			
		||||
/**
 | 
			
		||||
  * Initializes the Global MSP.
 | 
			
		||||
  */
 | 
			
		||||
void HAL_MspInit(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  __HAL_RCC_SYSCFG_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
  /* System interrupt init*/
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END MspInit 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @brief LTDC MSP Initialization
 | 
			
		||||
* This function configures the hardware resources used in this example
 | 
			
		||||
* @param hltdc: LTDC handle pointer
 | 
			
		||||
* @retval None
 | 
			
		||||
*/
 | 
			
		||||
void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
 | 
			
		||||
{
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
 | 
			
		||||
  if(hltdc->Instance==LTDC)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN LTDC_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /** Initializes the peripherals clock
 | 
			
		||||
  */
 | 
			
		||||
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3M = 1;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3N = 18;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3P = 2;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3Q = 2;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3R = 16;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_3;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE;
 | 
			
		||||
    PeriphClkInitStruct.PLL3.PLL3FRACN = 0.0;
 | 
			
		||||
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
 | 
			
		||||
    {
 | 
			
		||||
      Error_Handler();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_LTDC_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOC_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOE_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOD_CLK_ENABLE();
 | 
			
		||||
    /**LTDC GPIO Configuration
 | 
			
		||||
    PC0     ------> LTDC_R5
 | 
			
		||||
    PC1     ------> LTDC_G5
 | 
			
		||||
    PA1     ------> LTDC_R2
 | 
			
		||||
    PA3     ------> LTDC_B5
 | 
			
		||||
    PA4     ------> LTDC_VSYNC
 | 
			
		||||
    PA5     ------> LTDC_R4
 | 
			
		||||
    PA6     ------> LTDC_G2
 | 
			
		||||
    PC4     ------> LTDC_R7
 | 
			
		||||
    PC5     ------> LTDC_DE
 | 
			
		||||
    PB1     ------> LTDC_R6
 | 
			
		||||
    PE11     ------> LTDC_G3
 | 
			
		||||
    PE12     ------> LTDC_B4
 | 
			
		||||
    PE14     ------> LTDC_CLK
 | 
			
		||||
    PB10     ------> LTDC_G4
 | 
			
		||||
    PB15     ------> LTDC_G7
 | 
			
		||||
    PD10     ------> LTDC_B3
 | 
			
		||||
    PC6     ------> LTDC_HSYNC
 | 
			
		||||
    PC7     ------> LTDC_G6
 | 
			
		||||
    PC9     ------> LTDC_B2
 | 
			
		||||
    PA15     ------> LTDC_R3
 | 
			
		||||
    PD2     ------> LTDC_B7
 | 
			
		||||
    PB8     ------> LTDC_B6
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
 | 
			
		||||
                          |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
 | 
			
		||||
                          |GPIO_PIN_6;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_1;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF9_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_14;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_15|GPIO_PIN_8;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_10;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_15;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF9_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_2;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF9_LTDC;
 | 
			
		||||
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    /* LTDC interrupt Init */
 | 
			
		||||
    HAL_NVIC_SetPriority(LTDC_IRQn, 0, 0);
 | 
			
		||||
    HAL_NVIC_EnableIRQ(LTDC_IRQn);
 | 
			
		||||
    HAL_NVIC_SetPriority(LTDC_ER_IRQn, 0, 0);
 | 
			
		||||
    HAL_NVIC_EnableIRQ(LTDC_ER_IRQn);
 | 
			
		||||
  /* USER CODE BEGIN LTDC_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @brief LTDC MSP De-Initialization
 | 
			
		||||
* This function freeze the hardware resources used in this example
 | 
			
		||||
* @param hltdc: LTDC handle pointer
 | 
			
		||||
* @retval None
 | 
			
		||||
*/
 | 
			
		||||
void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
 | 
			
		||||
{
 | 
			
		||||
  if(hltdc->Instance==LTDC)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN LTDC_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_LTDC_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**LTDC GPIO Configuration
 | 
			
		||||
    PC0     ------> LTDC_R5
 | 
			
		||||
    PC1     ------> LTDC_G5
 | 
			
		||||
    PA1     ------> LTDC_R2
 | 
			
		||||
    PA3     ------> LTDC_B5
 | 
			
		||||
    PA4     ------> LTDC_VSYNC
 | 
			
		||||
    PA5     ------> LTDC_R4
 | 
			
		||||
    PA6     ------> LTDC_G2
 | 
			
		||||
    PC4     ------> LTDC_R7
 | 
			
		||||
    PC5     ------> LTDC_DE
 | 
			
		||||
    PB1     ------> LTDC_R6
 | 
			
		||||
    PE11     ------> LTDC_G3
 | 
			
		||||
    PE12     ------> LTDC_B4
 | 
			
		||||
    PE14     ------> LTDC_CLK
 | 
			
		||||
    PB10     ------> LTDC_G4
 | 
			
		||||
    PB15     ------> LTDC_G7
 | 
			
		||||
    PD10     ------> LTDC_B3
 | 
			
		||||
    PC6     ------> LTDC_HSYNC
 | 
			
		||||
    PC7     ------> LTDC_G6
 | 
			
		||||
    PC9     ------> LTDC_B2
 | 
			
		||||
    PA15     ------> LTDC_R3
 | 
			
		||||
    PD2     ------> LTDC_B7
 | 
			
		||||
    PB8     ------> LTDC_B6
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
 | 
			
		||||
                          |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
 | 
			
		||||
                          |GPIO_PIN_6|GPIO_PIN_15);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_15|GPIO_PIN_8);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOE, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_14);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOD, GPIO_PIN_10|GPIO_PIN_2);
 | 
			
		||||
 | 
			
		||||
    /* LTDC interrupt DeInit */
 | 
			
		||||
    HAL_NVIC_DisableIRQ(LTDC_IRQn);
 | 
			
		||||
    HAL_NVIC_DisableIRQ(LTDC_ER_IRQn);
 | 
			
		||||
  /* USER CODE BEGIN LTDC_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_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};
 | 
			
		||||
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
 | 
			
		||||
  if(huart->Instance==USART3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN USART3_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /** Initializes the peripherals clock
 | 
			
		||||
  */
 | 
			
		||||
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART3;
 | 
			
		||||
    PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
 | 
			
		||||
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
 | 
			
		||||
    {
 | 
			
		||||
      Error_Handler();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_USART3_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOD_CLK_ENABLE();
 | 
			
		||||
    /**USART3 GPIO Configuration
 | 
			
		||||
    PD8     ------> USART3_TX
 | 
			
		||||
    PD9     ------> USART3_RX
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = STLINK_RX_Pin|STLINK_TX_Pin;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
 | 
			
		||||
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART3_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @brief UART MSP De-Initialization
 | 
			
		||||
* This function freeze the hardware resources used in this example
 | 
			
		||||
* @param huart: UART handle pointer
 | 
			
		||||
* @retval None
 | 
			
		||||
*/
 | 
			
		||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
 | 
			
		||||
{
 | 
			
		||||
  if(huart->Instance==USART3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN USART3_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_USART3_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**USART3 GPIO Configuration
 | 
			
		||||
    PD8     ------> USART3_TX
 | 
			
		||||
    PD9     ------> USART3_RX
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOD, STLINK_RX_Pin|STLINK_TX_Pin);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN USART3_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END USART3_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
							
								
								
									
										231
									
								
								Core/Src/stm32h7xx_it.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								Core/Src/stm32h7xx_it.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,231 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32h7xx_it.c
 | 
			
		||||
  * @brief   Interrupt Service Routines.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2023 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 "stm32h7xx_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 --------------------------------------------------------*/
 | 
			
		||||
extern LTDC_HandleTypeDef hltdc;
 | 
			
		||||
/* USER CODE BEGIN EV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EV */
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/*           Cortex 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 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/* STM32H7xx 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_stm32h7xx.s).                    */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles LTDC global interrupt.
 | 
			
		||||
  */
 | 
			
		||||
void LTDC_IRQHandler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN LTDC_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_IRQn 0 */
 | 
			
		||||
  HAL_LTDC_IRQHandler(&hltdc);
 | 
			
		||||
  /* USER CODE BEGIN LTDC_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles LTDC Error global Interrupt.
 | 
			
		||||
  */
 | 
			
		||||
void LTDC_ER_IRQHandler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN LTDC_ER_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_ER_IRQn 0 */
 | 
			
		||||
  HAL_LTDC_IRQHandler(&hltdc);
 | 
			
		||||
  /* USER CODE BEGIN LTDC_ER_IRQn 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_ER_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
							
								
								
									
										450
									
								
								Core/Src/system_stm32h7xx.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										450
									
								
								Core/Src/system_stm32h7xx.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,450 @@
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    system_stm32h7xx.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @brief   CMSIS Cortex-Mx Device Peripheral Access Layer System Source File.
 | 
			
		||||
  *
 | 
			
		||||
  *   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_stm32h7xx.s" file.
 | 
			
		||||
  *
 | 
			
		||||
  *      - SystemCoreClock variable: Contains the core clock, 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.
 | 
			
		||||
  *
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2017 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 stm32h7xx_system
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_Includes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#include "stm32h7xx.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
#if !defined  (HSE_VALUE)
 | 
			
		||||
#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
 | 
			
		||||
#endif /* HSE_VALUE */
 | 
			
		||||
 | 
			
		||||
#if !defined  (CSI_VALUE)
 | 
			
		||||
  #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
 | 
			
		||||
#endif /* CSI_VALUE */
 | 
			
		||||
 | 
			
		||||
#if !defined  (HSI_VALUE)
 | 
			
		||||
  #define HSI_VALUE    ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
 | 
			
		||||
#endif /* HSI_VALUE */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_TypesDefinitions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_Defines
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/************************* Miscellaneous Configuration ************************/
 | 
			
		||||
/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */
 | 
			
		||||
/* #define DATA_IN_D2_SRAM */
 | 
			
		||||
 | 
			
		||||
/* 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 BANK1 or AXI 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)
 | 
			
		||||
#if defined(DUAL_CORE) && defined(CORE_CM4)
 | 
			
		||||
/*!< Uncomment the following line if you need to relocate your vector Table
 | 
			
		||||
     in D2 AXI SRAM else user remap will be done in FLASH BANK2. */
 | 
			
		||||
/* #define VECT_TAB_SRAM */
 | 
			
		||||
#if defined(VECT_TAB_SRAM)
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   D2_AXISRAM_BASE   /*!< Vector Table base address field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#else
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   FLASH_BANK2_BASE  /*!< Vector Table base address field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#endif /* VECT_TAB_SRAM */
 | 
			
		||||
#else
 | 
			
		||||
/*!< Uncomment the following line if you need to relocate your vector Table
 | 
			
		||||
     in D1 AXI SRAM else user remap will be done in FLASH BANK1. */
 | 
			
		||||
/* #define VECT_TAB_SRAM */
 | 
			
		||||
#if defined(VECT_TAB_SRAM)
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   D1_AXISRAM_BASE   /*!< Vector Table base address field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#else
 | 
			
		||||
#define VECT_TAB_BASE_ADDRESS   FLASH_BANK1_BASE  /*!< Vector Table base address field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
 | 
			
		||||
                                                       This value must be a multiple of 0x300. */
 | 
			
		||||
#endif /* VECT_TAB_SRAM */
 | 
			
		||||
#endif /* DUAL_CORE && CORE_CM4 */
 | 
			
		||||
#endif /* USER_VECT_TAB_ADDRESS */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_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; then there
 | 
			
		||||
               is no need to call the 2 first functions listed above, since SystemCoreClock
 | 
			
		||||
               variable is updated automatically.
 | 
			
		||||
  */
 | 
			
		||||
  uint32_t SystemCoreClock = 64000000;
 | 
			
		||||
  uint32_t SystemD2Clock = 64000000;
 | 
			
		||||
  const  uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32H7xx_System_Private_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Setup the microcontroller system
 | 
			
		||||
  *         Initialize the FPU setting and  vector table location
 | 
			
		||||
  *         configuration.
 | 
			
		||||
  * @param  None
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void SystemInit (void)
 | 
			
		||||
{
 | 
			
		||||
#if defined (DATA_IN_D2_SRAM)
 | 
			
		||||
 __IO uint32_t tmpreg;
 | 
			
		||||
#endif /* DATA_IN_D2_SRAM */
 | 
			
		||||
 | 
			
		||||
  /* FPU settings ------------------------------------------------------------*/
 | 
			
		||||
  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
 | 
			
		||||
    SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2)));  /* set CP10 and CP11 Full Access */
 | 
			
		||||
  #endif
 | 
			
		||||
  /* Reset the RCC clock configuration to the default reset state ------------*/
 | 
			
		||||
 | 
			
		||||
   /* Increasing the CPU frequency */
 | 
			
		||||
  if(FLASH_LATENCY_DEFAULT  > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
 | 
			
		||||
  {
 | 
			
		||||
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
 | 
			
		||||
    MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Set HSION bit */
 | 
			
		||||
  RCC->CR |= RCC_CR_HSION;
 | 
			
		||||
 | 
			
		||||
  /* Reset CFGR register */
 | 
			
		||||
  RCC->CFGR = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
 | 
			
		||||
  RCC->CR &= 0xEAF6ED7FU;
 | 
			
		||||
 | 
			
		||||
   /* Decreasing the number of wait states because of lower CPU frequency */
 | 
			
		||||
  if(FLASH_LATENCY_DEFAULT  < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
 | 
			
		||||
  {
 | 
			
		||||
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
 | 
			
		||||
    MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#if defined(D3_SRAM_BASE)
 | 
			
		||||
  /* Reset D1CFGR register */
 | 
			
		||||
  RCC->D1CFGR = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset D2CFGR register */
 | 
			
		||||
  RCC->D2CFGR = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset D3CFGR register */
 | 
			
		||||
  RCC->D3CFGR = 0x00000000;
 | 
			
		||||
#else
 | 
			
		||||
  /* Reset CDCFGR1 register */
 | 
			
		||||
  RCC->CDCFGR1 = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset CDCFGR2 register */
 | 
			
		||||
  RCC->CDCFGR2 = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset SRDCFGR register */
 | 
			
		||||
  RCC->SRDCFGR = 0x00000000;
 | 
			
		||||
#endif
 | 
			
		||||
  /* Reset PLLCKSELR register */
 | 
			
		||||
  RCC->PLLCKSELR = 0x02020200;
 | 
			
		||||
 | 
			
		||||
  /* Reset PLLCFGR register */
 | 
			
		||||
  RCC->PLLCFGR = 0x01FF0000;
 | 
			
		||||
  /* Reset PLL1DIVR register */
 | 
			
		||||
  RCC->PLL1DIVR = 0x01010280;
 | 
			
		||||
  /* Reset PLL1FRACR register */
 | 
			
		||||
  RCC->PLL1FRACR = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset PLL2DIVR register */
 | 
			
		||||
  RCC->PLL2DIVR = 0x01010280;
 | 
			
		||||
 | 
			
		||||
  /* Reset PLL2FRACR register */
 | 
			
		||||
 | 
			
		||||
  RCC->PLL2FRACR = 0x00000000;
 | 
			
		||||
  /* Reset PLL3DIVR register */
 | 
			
		||||
  RCC->PLL3DIVR = 0x01010280;
 | 
			
		||||
 | 
			
		||||
  /* Reset PLL3FRACR register */
 | 
			
		||||
  RCC->PLL3FRACR = 0x00000000;
 | 
			
		||||
 | 
			
		||||
  /* Reset HSEBYP bit */
 | 
			
		||||
  RCC->CR &= 0xFFFBFFFFU;
 | 
			
		||||
 | 
			
		||||
  /* Disable all interrupts */
 | 
			
		||||
  RCC->CIER = 0x00000000;
 | 
			
		||||
 | 
			
		||||
#if (STM32H7_DEV_ID == 0x450UL)
 | 
			
		||||
  /* dual core CM7 or single core line */
 | 
			
		||||
  if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U)
 | 
			
		||||
  {
 | 
			
		||||
    /* if stm32h7 revY*/
 | 
			
		||||
    /* Change  the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
 | 
			
		||||
    *((__IO uint32_t*)0x51008108) = 0x000000001U;
 | 
			
		||||
  }
 | 
			
		||||
#endif /* STM32H7_DEV_ID */
 | 
			
		||||
 | 
			
		||||
#if defined(DATA_IN_D2_SRAM)
 | 
			
		||||
  /* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */
 | 
			
		||||
#if defined(RCC_AHB2ENR_D2SRAM3EN)
 | 
			
		||||
  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);
 | 
			
		||||
#elif defined(RCC_AHB2ENR_D2SRAM2EN)
 | 
			
		||||
  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN);
 | 
			
		||||
#else
 | 
			
		||||
  RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN);
 | 
			
		||||
#endif /* RCC_AHB2ENR_D2SRAM3EN */
 | 
			
		||||
 | 
			
		||||
  tmpreg = RCC->AHB2ENR;
 | 
			
		||||
  (void) tmpreg;
 | 
			
		||||
#endif /* DATA_IN_D2_SRAM */
 | 
			
		||||
 | 
			
		||||
#if defined(DUAL_CORE) && defined(CORE_CM4)
 | 
			
		||||
  /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
 | 
			
		||||
#if defined(USER_VECT_TAB_ADDRESS)
 | 
			
		||||
  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D2 AXI-RAM or in Internal FLASH */
 | 
			
		||||
#endif /* USER_VECT_TAB_ADDRESS */
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
  /*
 | 
			
		||||
   * Disable the FMC bank1 (enabled after reset).
 | 
			
		||||
   * This, prevents CPU speculation access on this bank which blocks the use of FMC during
 | 
			
		||||
   * 24us. During this time the others FMC master (such as LTDC) cannot use it!
 | 
			
		||||
   */
 | 
			
		||||
  FMC_Bank1_R->BTCR[0] = 0x000030D2;
 | 
			
		||||
 | 
			
		||||
  /* 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 D1 AXI-RAM or in Internal FLASH */
 | 
			
		||||
#endif /* USER_VECT_TAB_ADDRESS */
 | 
			
		||||
 | 
			
		||||
#endif /*DUAL_CORE && CORE_CM4*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
   * @brief  Update SystemCoreClock variable according to Clock Register Values.
 | 
			
		||||
  *         The SystemCoreClock variable contains the core clock , it can
 | 
			
		||||
  *         be used by the user application to setup the SysTick timer or configure
 | 
			
		||||
  *         other parameters.
 | 
			
		||||
  *
 | 
			
		||||
  * @note   Each time the core clock 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 CSI, SystemCoreClock will contain the CSI_VALUE(*)
 | 
			
		||||
  *           - 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 CSI_VALUE(*),
 | 
			
		||||
  *             HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
 | 
			
		||||
  *             4 MHz) but the real value may vary depending on the variations
 | 
			
		||||
  *             in voltage and temperature.
 | 
			
		||||
  *         (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
 | 
			
		||||
  *             64 MHz) but the real value may vary depending on the variations
 | 
			
		||||
  *             in voltage and temperature.
 | 
			
		||||
  *
 | 
			
		||||
  *         (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value
 | 
			
		||||
  *              25 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 pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
 | 
			
		||||
  uint32_t common_system_clock;
 | 
			
		||||
  float_t fracn1, pllvco;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  /* Get SYSCLK source -------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
  switch (RCC->CFGR & RCC_CFGR_SWS)
 | 
			
		||||
  {
 | 
			
		||||
  case RCC_CFGR_SWS_HSI:  /* HSI used as system clock source */
 | 
			
		||||
    common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
  case RCC_CFGR_SWS_CSI:  /* CSI used as system clock  source */
 | 
			
		||||
    common_system_clock = CSI_VALUE;
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
  case RCC_CFGR_SWS_HSE:  /* HSE used as system clock  source */
 | 
			
		||||
    common_system_clock = HSE_VALUE;
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
  case RCC_CFGR_SWS_PLL1:  /* PLL1 used as system clock  source */
 | 
			
		||||
 | 
			
		||||
    /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN
 | 
			
		||||
    SYSCLK = PLL_VCO / PLLR
 | 
			
		||||
    */
 | 
			
		||||
    pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
 | 
			
		||||
    pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4)  ;
 | 
			
		||||
    pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
 | 
			
		||||
    fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3));
 | 
			
		||||
 | 
			
		||||
    if (pllm != 0U)
 | 
			
		||||
    {
 | 
			
		||||
      switch (pllsource)
 | 
			
		||||
      {
 | 
			
		||||
        case RCC_PLLCKSELR_PLLSRC_HSI:  /* HSI used as PLL clock source */
 | 
			
		||||
 | 
			
		||||
        hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
 | 
			
		||||
        pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case RCC_PLLCKSELR_PLLSRC_CSI:  /* CSI used as PLL clock source */
 | 
			
		||||
          pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case RCC_PLLCKSELR_PLLSRC_HSE:  /* HSE used as PLL clock source */
 | 
			
		||||
          pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      default:
 | 
			
		||||
          hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
 | 
			
		||||
          pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
 | 
			
		||||
      common_system_clock =  (uint32_t)(float_t)(pllvco/(float_t)pllp);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      common_system_clock = 0U;
 | 
			
		||||
    }
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
  default:
 | 
			
		||||
    common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
 | 
			
		||||
    break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Compute SystemClock frequency --------------------------------------------------*/
 | 
			
		||||
#if defined (RCC_D1CFGR_D1CPRE)
 | 
			
		||||
  tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos];
 | 
			
		||||
 | 
			
		||||
  /* common_system_clock frequency : CM7 CPU frequency  */
 | 
			
		||||
  common_system_clock >>= tmp;
 | 
			
		||||
 | 
			
		||||
  /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency  */
 | 
			
		||||
  SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
  tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos];
 | 
			
		||||
 | 
			
		||||
  /* common_system_clock frequency : CM7 CPU frequency  */
 | 
			
		||||
  common_system_clock >>= tmp;
 | 
			
		||||
 | 
			
		||||
  /* SystemD2Clock frequency : AXI and AHBs Clock frequency  */
 | 
			
		||||
  SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(DUAL_CORE) && defined(CORE_CM4)
 | 
			
		||||
  SystemCoreClock = SystemD2Clock;
 | 
			
		||||
#else
 | 
			
		||||
  SystemCoreClock = common_system_clock;
 | 
			
		||||
#endif /* DUAL_CORE && CORE_CM4 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
		Reference in New Issue
	
	Block a user