2 ******************************************************************************
4 * Description : Main program body
5 ******************************************************************************
7 * COPYRIGHT(c) 2016 STMicroelectronics
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * 3. Neither the name of STMicroelectronics nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ******************************************************************************
33 /* Includes ------------------------------------------------------------------*/
34 #include "stm32f7xx_hal.h"
39 /* USER CODE BEGIN Includes */
41 /* USER CODE END Includes */
43 /* Private variables ---------------------------------------------------------*/
45 /* USER CODE BEGIN PV */
46 /* Private variables ---------------------------------------------------------*/
48 /* USER CODE END PV */
50 /* Private function prototypes -----------------------------------------------*/
51 void SystemClock_Config(void);
52 void Error_Handler(void);
54 /* USER CODE BEGIN PFP */
55 /* Private function prototypes -----------------------------------------------*/
58 /* USER CODE END PFP */
60 /* USER CODE BEGIN 0 */
68 /* USER CODE BEGIN 1 */
72 /* MCU Configuration----------------------------------------------------------*/
74 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
77 /* Configure the system clock */
80 /* Initialize all configured peripherals */
83 MX_USART3_UART_Init();
85 /* USER CODE BEGIN 2 */
91 /* USER CODE BEGIN WHILE */
94 /* USER CODE END WHILE */
96 /* USER CODE BEGIN 3 */
103 /** System Clock Configuration
105 void SystemClock_Config(void)
108 RCC_OscInitTypeDef RCC_OscInitStruct
;
109 RCC_ClkInitTypeDef RCC_ClkInitStruct
;
110 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct
;
112 __HAL_RCC_PWR_CLK_ENABLE();
114 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1
);
116 RCC_OscInitStruct
.OscillatorType
= RCC_OSCILLATORTYPE_HSE
;
117 RCC_OscInitStruct
.HSEState
= RCC_HSE_ON
;
118 RCC_OscInitStruct
.PLL
.PLLState
= RCC_PLL_ON
;
119 RCC_OscInitStruct
.PLL
.PLLSource
= RCC_PLLSOURCE_HSE
;
120 RCC_OscInitStruct
.PLL
.PLLM
= 4;
121 RCC_OscInitStruct
.PLL
.PLLN
= 200;
122 RCC_OscInitStruct
.PLL
.PLLP
= RCC_PLLP_DIV2
;
123 RCC_OscInitStruct
.PLL
.PLLQ
= 2;
124 if (HAL_RCC_OscConfig(&RCC_OscInitStruct
) != HAL_OK
)
129 if (HAL_PWREx_EnableOverDrive() != HAL_OK
)
134 RCC_ClkInitStruct
.ClockType
= RCC_CLOCKTYPE_HCLK
|RCC_CLOCKTYPE_SYSCLK
135 |RCC_CLOCKTYPE_PCLK1
|RCC_CLOCKTYPE_PCLK2
;
136 RCC_ClkInitStruct
.SYSCLKSource
= RCC_SYSCLKSOURCE_PLLCLK
;
137 RCC_ClkInitStruct
.AHBCLKDivider
= RCC_SYSCLK_DIV1
;
138 RCC_ClkInitStruct
.APB1CLKDivider
= RCC_HCLK_DIV4
;
139 RCC_ClkInitStruct
.APB2CLKDivider
= RCC_HCLK_DIV2
;
140 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct
, FLASH_LATENCY_6
) != HAL_OK
)
145 PeriphClkInitStruct
.PeriphClockSelection
= RCC_PERIPHCLK_USART3
;
146 PeriphClkInitStruct
.Usart3ClockSelection
= RCC_USART3CLKSOURCE_PCLK1
;
147 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct
) != HAL_OK
)
152 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
154 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK
);
156 /* SysTick_IRQn interrupt configuration */
157 HAL_NVIC_SetPriority(SysTick_IRQn
, 0, 0);
160 /* USER CODE BEGIN 4 */
162 /* USER CODE END 4 */
165 * @brief This function is executed in case of error occurrence.
169 void Error_Handler(void)
171 /* USER CODE BEGIN Error_Handler */
172 /* User can add his own implementation to report the HAL error return state */
176 /* USER CODE END Error_Handler */
179 #ifdef USE_FULL_ASSERT
182 * @brief Reports the name of the source file and the source line number
183 * where the assert_param error has occurred.
184 * @param file: pointer to the source file name
185 * @param line: assert_param error line source number
188 void assert_failed(uint8_t* file
, uint32_t line
)
190 /* USER CODE BEGIN 6 */
191 /* User can add his own implementation to report the file name and line number,
192 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
193 /* USER CODE END 6 */
207 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/