software:firmware
MakAir Firmware
sysclock.cpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 // INCLUDES ===================================================================
11 
12 #include "../includes/config.h"
13 #include "Arduino.h"
14 
15 // FUNCTIONS ==================================================================
16 
21 // cppcheck-suppress unusedFunction
22 extern "C" void SystemClock_Config(void) {
23  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
24  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
25 
28  __HAL_RCC_PWR_CLK_ENABLE();
29  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
32  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
33  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
34  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
35  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
36  RCC_OscInitStruct.PLL.PLLM = 4;
37  RCC_OscInitStruct.PLL.PLLN = 100;
38  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
39  RCC_OscInitStruct.PLL.PLLQ = 4;
40  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
41  Error_Handler();
42  }
45  RCC_ClkInitStruct.ClockType =
46  RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
47  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
48  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
49  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
50  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
51 
52  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {
53  Error_Handler();
54  }
55 }
void SystemClock_Config(void)
System Clock Configuration, for hardware v3 and later on.
Definition: sysclock.cpp:22