cfg_clock_default.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2020 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "kernel_defines.h"
20 
21 #if defined(CPU_FAM_STM32F2)
23 #elif defined(CPU_FAM_STM32F4)
24 #if defined(CPU_LINE_STM32F401xC) || defined(CPU_LINE_STM32F401xE)
26 #elif defined(CPU_LINE_STM32F410Cx) || defined(CPU_LINE_STM32F410Rx) || \
27  defined(CPU_LINE_STM32F410Tx) || defined(CPU_LINE_STM32F411xE) || \
28  defined(CPU_LINE_STM32F412Cx) || defined(CPU_LINE_STM32F412Rx) || \
29  defined(CPU_LINE_STM32F412Vx) || defined(CPU_LINE_STM32F412Zx) || \
30  defined(CPU_LINE_STM32F413xx) || defined(CPU_LINE_STM32F423xx)
32 #elif defined(CPU_LINE_STM32F405xx) || defined(CPU_LINE_STM32F407xx) || \
33  defined(CPU_LINE_STM32F415xx) || defined(CPU_LINE_STM32F417xx) || \
34  defined(CPU_LINE_STM32F427xx) || defined(CPU_LINE_STM32F437xx) || \
35  defined(CPU_LINE_STM32F429xx) || defined(CPU_LINE_STM32F439xx) || \
36  defined(CPU_LINE_STM32F446xx) || defined(CPU_LINE_STM32F469xx) || \
37  defined(CPU_LINE_STM32F479xx)
39 #else
40 #error "No clock configuration available for this F4 line"
41 #endif
42 #elif defined(CPU_FAM_STM32F7)
44 #else
45 #error "No clock configuration available for this family"
46 #endif
47 
52 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
53 #define CLOCK_PLL_SRC (CONFIG_CLOCK_HSE)
54 #else /* CONFIG_CLOCK_HSI */
55 #define CLOCK_PLL_SRC (CONFIG_CLOCK_HSI)
56 #endif
57 
58 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
59 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI)
60 
61 #elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
62 #if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
63 #error "The board doesn't provide an HSE oscillator"
64 #endif
65 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
66 
67 #elif IS_ACTIVE(CONFIG_USE_CLOCK_PLL)
68 #define CLOCK_CORECLOCK (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_P)
69 #endif /* CONFIG_USE_CLOCK_PLL */
70 
71 #define CLOCK_PLLQ (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_Q)
72 
73 #define CLOCK_AHB CLOCK_CORECLOCK
74 #define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV)
75 #define CLOCK_APB2 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB2_DIV)
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
Base STM32Fx/Gx/MP1/C0 clock configuration.
Default STM32F4 clock configuration for 100MHz boards.
Default STM32F2/4/7 clock configuration for 120MHz boards.
Default STM32F4 clock configuration for 180MHz boards.
Default STM32F7 clock configuration for 216MHz boards.
Default STM32F4 clock configuration for 84MHz boards.
Common macros and compiler attributes/pragmas configuration.