cfg_clock_common_lx_u5_wx.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 
23 #ifndef CLK_CFG_CLOCK_COMMON_LX_U5_WX_H
24 #define CLK_CFG_CLOCK_COMMON_LX_U5_WX_H
25 
26 #include "kernel_defines.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 /* Select the desired system clock source between PLL, HSE or HSI */
37 #ifndef CONFIG_USE_CLOCK_PLL
38 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI) || \
39  IS_ACTIVE(CONFIG_USE_CLOCK_MSI)
40 #define CONFIG_USE_CLOCK_PLL 0
41 #else
42 #define CONFIG_USE_CLOCK_PLL 1 /* Use PLL by default */
43 #endif
44 #endif /* CONFIG_USE_CLOCK_PLL */
47 #if IS_ACTIVE(CONFIG_USE_CLOCK_PLL) && \
48  (IS_ACTIVE(CONFIG_USE_CLOCK_MSI) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || \
49  IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
50 #error "Cannot use PLL as clock source with other clock configurations"
51 #endif
52 
53 #if IS_ACTIVE(CONFIG_USE_CLOCK_MSI) && \
54  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || \
55  IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
56 #error "Cannot use MSI as clock source with other clock configurations"
57 #endif
58 
59 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) && \
60  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_MSI) || \
61  IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
62 #error "Cannot use HSE as clock source with other clock configurations"
63 #endif
64 
65 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI) && \
66  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_MSI) || \
67  IS_ACTIVE(CONFIG_USE_CLOCK_HSE))
68 #error "Cannot use HSI as clock source with other clock configurations"
69 #endif
70 
71 #ifndef CONFIG_CLOCK_HSE
72 #if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
73 #define CONFIG_CLOCK_HSE MHZ(24)
74 #else
75 #define CONFIG_CLOCK_HSE MHZ(8)
76 #endif
77 #endif
78 
79 #ifndef CONFIG_CLOCK_HSI
80 #define CONFIG_CLOCK_HSI MHZ(16)
81 #endif
82 
83 #ifndef CONFIG_CLOCK_MSI
84 #if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
85 #define CONFIG_CLOCK_MSI KHZ(4194)
86 #else
87 #define CONFIG_CLOCK_MSI MHZ(48)
88 #endif
89 #endif
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif /* CLK_CFG_CLOCK_COMMON_LX_U5_WX_H */
Common macros and compiler attributes/pragmas configuration.