Loading...
Searching...
No Matches
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
23#ifndef CLK_CFG_CLOCK_COMMON_FX_GX_MP1_C0_H
24#define CLK_CFG_CLOCK_COMMON_FX_GX_MP1_C0_H
25
26#include "kernel_defines.h"
27
28#ifdef __cplusplus
29extern "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#define CONFIG_USE_CLOCK_PLL 0
40#else
41#if defined(CPU_FAM_STM32C0) /* PLL not supported in STM32C0 */
42#define CONFIG_USE_CLOCK_PLL 0
43#define CONFIG_USE_CLOCK_HSI 1
44#else
45#define CONFIG_USE_CLOCK_PLL 1 /* Use PLL by default */
46#endif
47#endif
48#endif /* CONFIG_USE_CLOCK_PLL */
49
50#if IS_ACTIVE(CONFIG_USE_CLOCK_PLL) && \
51 (IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
52#error "Cannot use PLL as clock source with other clock configurations"
53#endif
54
55#if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) && \
56 (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
57#error "Cannot use HSE as clock source with other clock configurations"
58#endif
59
60#if IS_ACTIVE(CONFIG_USE_CLOCK_HSI) && \
61 (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE))
62#error "Cannot use HSI as clock source with other clock configurations"
63#endif
64
65#ifndef CONFIG_CLOCK_HSE
66#if defined(CPU_FAM_STM32G0) || defined(CPU_FAM_STM32G4) || \
67 defined(CPU_FAM_STM32MP1) || defined(CPU_FAM_STM32C0)
68#define CONFIG_CLOCK_HSE MHZ(24)
69#else
70#define CONFIG_CLOCK_HSE MHZ(8)
71#endif
72#endif
73
74#ifndef CONFIG_CLOCK_HSI
75#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \
76 defined(CPU_FAM_STM32F3)
77#define CONFIG_CLOCK_HSI MHZ(8)
78#elif defined(CPU_FAM_STM32MP1)
79#define CONFIG_CLOCK_HSI MHZ(64)
80#elif defined(CPU_FAM_STM32C0)
81#define CONFIG_CLOCK_HSI MHZ(48)
82#else
83#define CONFIG_CLOCK_HSI MHZ(16)
84#endif
85#endif
88#ifdef __cplusplus
89}
90#endif
91
92#endif /* CLK_CFG_CLOCK_COMMON_FX_GX_MP1_C0_H */
Common macros and compiler attributes/pragmas configuration.