add screen library
This commit is contained in:
		
							
								
								
									
										80
									
								
								ide-touchgfx-gen/Core/Src/freertos.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								ide-touchgfx-gen/Core/Src/freertos.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| /* USER CODE BEGIN Header */ | ||||
| /** | ||||
|   ****************************************************************************** | ||||
|   * File Name          : freertos.c | ||||
|   * Description        : Code for freertos applications | ||||
|   ****************************************************************************** | ||||
|   * @attention | ||||
|   * | ||||
|   * <h2><center>© Copyright (c) 2020 STMicroelectronics. | ||||
|   * All rights reserved.</center></h2> | ||||
|   * | ||||
|   * This software component is licensed by ST under Ultimate Liberty license | ||||
|   * SLA0044, the "License"; You may not use this file except in compliance with | ||||
|   * the License. You may obtain a copy of the License at: | ||||
|   *                             www.st.com/SLA0044 | ||||
|   * | ||||
|   ****************************************************************************** | ||||
|   */ | ||||
| /* USER CODE END Header */ | ||||
|  | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| #include "FreeRTOS.h" | ||||
| #include "task.h" | ||||
| #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 ---------------------------------------------------------*/ | ||||
| /* USER CODE BEGIN Variables */ | ||||
|  | ||||
| /* USER CODE END Variables */ | ||||
|  | ||||
| /* Private function prototypes -----------------------------------------------*/ | ||||
| /* USER CODE BEGIN FunctionPrototypes */ | ||||
| extern portBASE_TYPE IdleTaskHook(void* p);   | ||||
| /* USER CODE END FunctionPrototypes */ | ||||
|  | ||||
| /* Hook prototypes */ | ||||
| void vApplicationIdleHook(void); | ||||
|  | ||||
| /* USER CODE BEGIN 2 */ | ||||
| void vApplicationIdleHook( void ) | ||||
| { | ||||
|    /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set | ||||
|    to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle | ||||
|    task. It is essential that code added to this hook function never attempts | ||||
|    to block in any way (for example, call xQueueReceive() with a block time | ||||
|    specified, or call vTaskDelay()). If the application makes use of the | ||||
|    vTaskDelete() API function (as this demo application does) then it is also | ||||
|    important that vApplicationIdleHook() is permitted to return to its calling | ||||
|    function, because it is the responsibility of the idle task to clean up | ||||
|    memory allocated by the kernel to any task that has since been deleted. */ | ||||
|    vTaskSetApplicationTaskTag(NULL, IdleTaskHook); | ||||
| } | ||||
| /* USER CODE END 2 */ | ||||
|  | ||||
| /* Private application code --------------------------------------------------*/ | ||||
| /* USER CODE BEGIN Application */ | ||||
|  | ||||
| /* USER CODE END Application */ | ||||
|  | ||||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||
							
								
								
									
										1127
									
								
								ide-touchgfx-gen/Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1127
									
								
								ide-touchgfx-gen/Core/Src/main.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1006
									
								
								ide-touchgfx-gen/Core/Src/stm32f7xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1006
									
								
								ide-touchgfx-gen/Core/Src/stm32f7xx_hal_msp.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										246
									
								
								ide-touchgfx-gen/Core/Src/stm32f7xx_it.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										246
									
								
								ide-touchgfx-gen/Core/Src/stm32f7xx_it.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,246 @@ | ||||
| /* USER CODE BEGIN Header */ | ||||
| /** | ||||
|   ****************************************************************************** | ||||
|   * @file    stm32f7xx_it.c | ||||
|   * @brief   Interrupt Service Routines. | ||||
|   ****************************************************************************** | ||||
|   * @attention | ||||
|   * | ||||
|   * <h2><center>© Copyright (c) 2020 STMicroelectronics. | ||||
|   * All rights reserved.</center></h2> | ||||
|   * | ||||
|   * This software component is licensed by ST under Ultimate Liberty license | ||||
|   * SLA0044, the "License"; You may not use this file except in compliance with | ||||
|   * the License. You may obtain a copy of the License at: | ||||
|   *                             www.st.com/SLA0044 | ||||
|   * | ||||
|   ****************************************************************************** | ||||
|   */ | ||||
| /* USER CODE END Header */ | ||||
|  | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| #include "main.h" | ||||
| #include "stm32f7xx_it.h" | ||||
| #include "FreeRTOS.h" | ||||
| #include "task.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 ADC_HandleTypeDef hadc3; | ||||
| extern DMA2D_HandleTypeDef hdma2d; | ||||
| extern LTDC_HandleTypeDef hltdc; | ||||
| extern TIM_HandleTypeDef htim1; | ||||
| /* USER CODE BEGIN EV */ | ||||
|  | ||||
| /* USER CODE END EV */ | ||||
|  | ||||
| /******************************************************************************/ | ||||
| /*           Cortex-M7 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 */ | ||||
|  | ||||
|   /* 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 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 System tick timer. | ||||
|   */ | ||||
| void SysTick_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||
|  | ||||
|   /* USER CODE END SysTick_IRQn 0 */ | ||||
|   HAL_IncTick(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) | ||||
|   { | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   xPortSysTickHandler(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   } | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
|  | ||||
|   /* USER CODE END SysTick_IRQn 1 */ | ||||
| } | ||||
|  | ||||
| /******************************************************************************/ | ||||
| /* STM32F7xx 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_stm32f7xx.s).                    */ | ||||
| /******************************************************************************/ | ||||
|  | ||||
| /** | ||||
|   * @brief This function handles ADC1, ADC2 and ADC3 global interrupts. | ||||
|   */ | ||||
| void ADC_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN ADC_IRQn 0 */ | ||||
|  | ||||
|   /* USER CODE END ADC_IRQn 0 */ | ||||
|   HAL_ADC_IRQHandler(&hadc3); | ||||
|   /* USER CODE BEGIN ADC_IRQn 1 */ | ||||
|  | ||||
|   /* USER CODE END ADC_IRQn 1 */ | ||||
| } | ||||
|  | ||||
| /** | ||||
|   * @brief This function handles TIM1 capture compare interrupt. | ||||
|   */ | ||||
| void TIM1_CC_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN TIM1_CC_IRQn 0 */ | ||||
|  | ||||
|   /* USER CODE END TIM1_CC_IRQn 0 */ | ||||
|   HAL_TIM_IRQHandler(&htim1); | ||||
|   /* USER CODE BEGIN TIM1_CC_IRQn 1 */ | ||||
|  | ||||
|   /* USER CODE END TIM1_CC_IRQn 1 */ | ||||
| } | ||||
|  | ||||
| /** | ||||
|   * @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 DMA2D global interrupt. | ||||
|   */ | ||||
| void DMA2D_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN DMA2D_IRQn 0 */ | ||||
|  | ||||
|   /* USER CODE END DMA2D_IRQn 0 */ | ||||
|   HAL_DMA2D_IRQHandler(&hdma2d); | ||||
|   /* USER CODE BEGIN DMA2D_IRQn 1 */ | ||||
|  | ||||
|   /* USER CODE END DMA2D_IRQn 1 */ | ||||
| } | ||||
|  | ||||
| /* USER CODE BEGIN 1 */ | ||||
|  | ||||
| /* USER CODE END 1 */ | ||||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||
							
								
								
									
										262
									
								
								ide-touchgfx-gen/Core/Src/system_stm32f7xx.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										262
									
								
								ide-touchgfx-gen/Core/Src/system_stm32f7xx.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,262 @@ | ||||
| /** | ||||
|   ****************************************************************************** | ||||
|   * @file    system_stm32f7xx.c | ||||
|   * @author  MCD Application Team | ||||
|   * @brief   CMSIS Cortex-M7 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_stm32f7xx.s" file. | ||||
|   * | ||||
|   *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used | ||||
|   *                                  by the user application to setup the SysTick  | ||||
|   *                                  timer or configure other parameters. | ||||
|   *                                      | ||||
|   *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must | ||||
|   *                                 be called whenever the core clock is changed | ||||
|   *                                 during program execution. | ||||
|   * | ||||
|   * | ||||
|   ****************************************************************************** | ||||
|   * @attention | ||||
|   * | ||||
|   * <h2><center>© Copyright (c) 2016 STMicroelectronics. | ||||
|   * All rights reserved.</center></h2> | ||||
|   * | ||||
|   * This software component is licensed by ST under BSD 3-Clause license, | ||||
|   * the "License"; You may not use this file except in compliance with the | ||||
|   * License. You may obtain a copy of the License at: | ||||
|   *                        opensource.org/licenses/BSD-3-Clause | ||||
|   * | ||||
|   ****************************************************************************** | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup CMSIS | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup stm32f7xx_system | ||||
|   * @{ | ||||
|   */   | ||||
|    | ||||
| /** @addtogroup STM32F7xx_System_Private_Includes | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| #include "stm32f7xx.h" | ||||
|  | ||||
| #if !defined  (HSE_VALUE)  | ||||
|   #define HSE_VALUE    ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ | ||||
| #endif /* HSE_VALUE */ | ||||
|  | ||||
| #if !defined  (HSI_VALUE) | ||||
|   #define HSI_VALUE    ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* HSI_VALUE */ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_System_Private_TypesDefinitions | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_System_Private_Defines | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /************************* Miscellaneous Configuration ************************/ | ||||
|  | ||||
| /*!< Uncomment the following line if you need to relocate your vector Table in | ||||
|      Internal SRAM. */ | ||||
| /* #define VECT_TAB_SRAM */ | ||||
| #define VECT_TAB_OFFSET  0x00 /*!< Vector Table base offset field.  | ||||
|                                    This value must be a multiple of 0x200. */ | ||||
| /******************************************************************************/ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_System_Private_Macros | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_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 = 16000000; | ||||
|   const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; | ||||
|   const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_System_Private_FunctionPrototypes | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** @addtogroup STM32F7xx_System_Private_Functions | ||||
|   * @{ | ||||
|   */ | ||||
|  | ||||
| /** | ||||
|   * @brief  Setup the microcontroller system | ||||
|   *         Initialize the Embedded Flash Interface, the PLL and update the  | ||||
|   *         SystemFrequency variable. | ||||
|   * @param  None | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemInit(void) | ||||
| { | ||||
|   /* FPU settings ------------------------------------------------------------*/ | ||||
| #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||
|   SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */ | ||||
| #endif | ||||
|   /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||
|   /* Set HSION bit */ | ||||
|   RCC->CR |= (uint32_t)0x00000001; | ||||
|  | ||||
|   /* Reset CFGR register */ | ||||
|   RCC->CFGR = 0x00000000; | ||||
|  | ||||
|   /* Reset HSEON, CSSON and PLLON bits */ | ||||
|   RCC->CR &= (uint32_t)0xFEF6FFFF; | ||||
|  | ||||
|   /* Reset PLLCFGR register */ | ||||
|   RCC->PLLCFGR = 0x24003010; | ||||
|  | ||||
|   /* Reset HSEBYP bit */ | ||||
|   RCC->CR &= (uint32_t)0xFFFBFFFF; | ||||
|  | ||||
|   /* Disable all interrupts */ | ||||
|   RCC->CIR = 0x00000000; | ||||
|  | ||||
|   /* Configure the Vector Table location add offset address ------------------*/ | ||||
| #ifdef VECT_TAB_SRAM | ||||
|   SCB->VTOR = RAMDTCM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||
| #else | ||||
|   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||
| #endif | ||||
| } | ||||
|  | ||||
| /** | ||||
|    * @brief  Update SystemCoreClock variable according to Clock Register Values. | ||||
|   *         The SystemCoreClock variable contains the core clock (HCLK), it can | ||||
|   *         be used by the user application to setup the SysTick timer or configure | ||||
|   *         other parameters. | ||||
|   *            | ||||
|   * @note   Each time the core clock (HCLK) changes, this function must be called | ||||
|   *         to update SystemCoreClock variable value. Otherwise, any configuration | ||||
|   *         based on this variable will be incorrect.          | ||||
|   *      | ||||
|   * @note   - The system frequency computed by this function is not the real  | ||||
|   *           frequency in the chip. It is calculated based on the predefined  | ||||
|   *           constant and the selected clock source: | ||||
|   *              | ||||
|   *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) | ||||
|   *                                               | ||||
|   *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) | ||||
|   *                           | ||||
|   *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)  | ||||
|   *             or HSI_VALUE(*) multiplied/divided by the PLL factors. | ||||
|   *          | ||||
|   *         (*) HSI_VALUE is a constant defined in stm32f7xx_hal_conf.h file (default value | ||||
|   *             16 MHz) but the real value may vary depending on the variations | ||||
|   *             in voltage and temperature.    | ||||
|   *     | ||||
|   *         (**) HSE_VALUE is a constant defined in stm32f7xx_hal_conf.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 tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; | ||||
|    | ||||
|   /* Get SYSCLK source -------------------------------------------------------*/ | ||||
|   tmp = RCC->CFGR & RCC_CFGR_SWS; | ||||
|  | ||||
|   switch (tmp) | ||||
|   { | ||||
|     case 0x00:  /* HSI used as system clock source */ | ||||
|       SystemCoreClock = HSI_VALUE; | ||||
|       break; | ||||
|     case 0x04:  /* HSE used as system clock source */ | ||||
|       SystemCoreClock = HSE_VALUE; | ||||
|       break; | ||||
|     case 0x08:  /* PLL used as system clock source */ | ||||
|  | ||||
|       /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N | ||||
|          SYSCLK = PLL_VCO / PLL_P | ||||
|          */     | ||||
|       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; | ||||
|       pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; | ||||
|        | ||||
|       if (pllsource != 0) | ||||
|       { | ||||
|         /* HSE used as PLL clock source */ | ||||
|         pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|         /* HSI used as PLL clock source */ | ||||
|         pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);       | ||||
|       } | ||||
|  | ||||
|       pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; | ||||
|       SystemCoreClock = pllvco/pllp; | ||||
|       break; | ||||
|     default: | ||||
|       SystemCoreClock = HSI_VALUE; | ||||
|       break; | ||||
|   } | ||||
|   /* Compute HCLK frequency --------------------------------------------------*/ | ||||
|   /* Get HCLK prescaler */ | ||||
|   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; | ||||
|   /* HCLK frequency */ | ||||
|   SystemCoreClock >>= tmp; | ||||
| } | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| /** | ||||
|   * @} | ||||
|   */ | ||||
|    | ||||
| /** | ||||
|   * @} | ||||
|   */     | ||||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||
		Reference in New Issue
	
	Block a user