cfg_clock_default.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
9 #pragma once
10 
22 #include "kernel_defines.h"
23 
24 #if defined(CPU_FAM_STM32F2)
26 #elif defined(CPU_FAM_STM32F4)
27 #if defined(CPU_LINE_STM32F401xC) || defined(CPU_LINE_STM32F401xE)
29 #elif defined(CPU_LINE_STM32F410Cx) || defined(CPU_LINE_STM32F410Rx) || \
30  defined(CPU_LINE_STM32F410Tx) || defined(CPU_LINE_STM32F411xE) || \
31  defined(CPU_LINE_STM32F412Cx) || defined(CPU_LINE_STM32F412Rx) || \
32  defined(CPU_LINE_STM32F412Vx) || defined(CPU_LINE_STM32F412Zx) || \
33  defined(CPU_LINE_STM32F413xx) || defined(CPU_LINE_STM32F423xx)
35 #elif defined(CPU_LINE_STM32F405xx) || defined(CPU_LINE_STM32F407xx) || \
36  defined(CPU_LINE_STM32F415xx) || defined(CPU_LINE_STM32F417xx) || \
37  defined(CPU_LINE_STM32F427xx) || defined(CPU_LINE_STM32F437xx) || \
38  defined(CPU_LINE_STM32F429xx) || defined(CPU_LINE_STM32F439xx) || \
39  defined(CPU_LINE_STM32F446xx) || defined(CPU_LINE_STM32F469xx) || \
40  defined(CPU_LINE_STM32F479xx)
42 #else
43 #error "No clock configuration available for this F4 line"
44 #endif
45 #elif defined(CPU_FAM_STM32F7)
47 #else
48 #error "No clock configuration available for this family"
49 #endif
50 
55 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
56 #define CLOCK_PLL_SRC (CONFIG_CLOCK_HSE)
57 #else /* CONFIG_CLOCK_HSI */
58 #define CLOCK_PLL_SRC (CONFIG_CLOCK_HSI)
59 #endif
60 
61 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
62 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI)
63 
64 #elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
65 #if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
66 #error "The board doesn't provide an HSE oscillator"
67 #endif
68 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
69 
70 #elif IS_ACTIVE(CONFIG_USE_CLOCK_PLL)
71 #define CLOCK_CORECLOCK (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_P)
72 #endif /* CONFIG_USE_CLOCK_PLL */
73 
74 #define CLOCK_PLLQ (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_Q)
75 
76 #define CLOCK_AHB CLOCK_CORECLOCK
77 #define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV)
78 #define CLOCK_APB2 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB2_DIV)
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
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.