Loading...
Searching...
No Matches
cfg_clock_common_fx_gx_mp1_c0.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
3 * SPDX-FileCopyrightText: 2017 OTA keys S.A.
4 * SPDX-FileCopyrightText: 2018-2020 Inria
5 * SPDX-License-Identifier: LGPL-2.1-only
6 */
7
8#pragma once
9
21
22#include "kernel_defines.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
32/* Select the desired system clock source between PLL, HSE or HSI */
33#ifndef CONFIG_USE_CLOCK_PLL
34#if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
35#define CONFIG_USE_CLOCK_PLL 0
36#else
37#if defined(CPU_FAM_STM32C0) /* PLL not supported in STM32C0 */
38#define CONFIG_USE_CLOCK_PLL 0
39#define CONFIG_USE_CLOCK_HSI 1
40#else
41#define CONFIG_USE_CLOCK_PLL 1 /* Use PLL by default */
42#endif
43#endif
44#endif /* CONFIG_USE_CLOCK_PLL */
45
46#if IS_ACTIVE(CONFIG_USE_CLOCK_PLL) && \
47 (IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
48#error "Cannot use PLL as clock source with other clock configurations"
49#endif
50
51#if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) && \
52 (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
53#error "Cannot use HSE as clock source with other clock configurations"
54#endif
55
56#if IS_ACTIVE(CONFIG_USE_CLOCK_HSI) && \
57 (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE))
58#error "Cannot use HSI as clock source with other clock configurations"
59#endif
60
61#ifndef CONFIG_CLOCK_HSE
62#if defined(CPU_FAM_STM32G0) || defined(CPU_FAM_STM32G4) || \
63 defined(CPU_FAM_STM32MP1) || defined(CPU_FAM_STM32C0)
64#define CONFIG_CLOCK_HSE MHZ(24)
65#else
66#define CONFIG_CLOCK_HSE MHZ(8)
67#endif
68#endif
69
70#ifndef CONFIG_CLOCK_HSI
71#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \
72 defined(CPU_FAM_STM32F3)
73#define CONFIG_CLOCK_HSI MHZ(8)
74#elif defined(CPU_FAM_STM32MP1)
75#define CONFIG_CLOCK_HSI MHZ(64)
76#elif defined(CPU_FAM_STM32C0)
77#define CONFIG_CLOCK_HSI MHZ(48)
78#else
79#define CONFIG_CLOCK_HSI MHZ(16)
80#endif
81#endif
83
84#ifdef __cplusplus
85}
86#endif
87
Common macros and compiler attributes/pragmas configuration.