cfg_clock_common_fx_gx_mp1_c0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universität Berlin
3  * 2017 OTA keys S.A.
4  * 2018-2020 Inria
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
11 #pragma once
12 
25 #include "kernel_defines.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 /* Select the desired system clock source between PLL, HSE or HSI */
36 #ifndef CONFIG_USE_CLOCK_PLL
37 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
38 #define CONFIG_USE_CLOCK_PLL 0
39 #else
40 #if defined(CPU_FAM_STM32C0) /* PLL not supported in STM32C0 */
41 #define CONFIG_USE_CLOCK_PLL 0
42 #define CONFIG_USE_CLOCK_HSI 1
43 #else
44 #define CONFIG_USE_CLOCK_PLL 1 /* Use PLL by default */
45 #endif
46 #endif
47 #endif /* CONFIG_USE_CLOCK_PLL */
48 
49 #if IS_ACTIVE(CONFIG_USE_CLOCK_PLL) && \
50  (IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
51 #error "Cannot use PLL as clock source with other clock configurations"
52 #endif
53 
54 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) && \
55  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
56 #error "Cannot use HSE as clock source with other clock configurations"
57 #endif
58 
59 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI) && \
60  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE))
61 #error "Cannot use HSI as clock source with other clock configurations"
62 #endif
63 
64 #ifndef CONFIG_CLOCK_HSE
65 #if defined(CPU_FAM_STM32G0) || defined(CPU_FAM_STM32G4) || \
66  defined(CPU_FAM_STM32MP1) || defined(CPU_FAM_STM32C0)
67 #define CONFIG_CLOCK_HSE MHZ(24)
68 #else
69 #define CONFIG_CLOCK_HSE MHZ(8)
70 #endif
71 #endif
72 
73 #ifndef CONFIG_CLOCK_HSI
74 #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \
75  defined(CPU_FAM_STM32F3)
76 #define CONFIG_CLOCK_HSI MHZ(8)
77 #elif defined(CPU_FAM_STM32MP1)
78 #define CONFIG_CLOCK_HSI MHZ(64)
79 #elif defined(CPU_FAM_STM32C0)
80 #define CONFIG_CLOCK_HSI MHZ(48)
81 #else
82 #define CONFIG_CLOCK_HSI MHZ(16)
83 #endif
84 #endif
87 #ifdef __cplusplus
88 }
89 #endif
90 
Common macros and compiler attributes/pragmas configuration.