cfg_clock_default_100.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 
22 #include "kernel_defines.h"
23 #include "macros/units.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 /* The following parameters configure a 100MHz system clock with HSE (8MHz, 16MHz or
34  25MHz) or HSI (16MHz) as PLL input clock.
35  If USB is used and no alternative 48MHz is available, the clock frequency is
36  decreased to 96MHZ so the PLLQ can output 48MHz.
37  */
38 #ifndef CONFIG_CLOCK_PLL_M
39 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE == MHZ(25))
40 #define CONFIG_CLOCK_PLL_M (25)
41 #else
42 #define CONFIG_CLOCK_PLL_M (4)
43 #endif
44 #endif
45 #ifndef CONFIG_CLOCK_PLL_N
46 #if (IS_USED(MODULE_PERIPH_USBDEV_CLK) || IS_USED(MODULE_PERIPH_SDMMC_CLK)) && \
47  defined(CPU_LINE_STM32F411xE)
48 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE == MHZ(8))
49 #define CONFIG_CLOCK_PLL_N (96)
50 #elif IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE == MHZ(25))
51 #define CONFIG_CLOCK_PLL_N (192)
52 #else
53 #define CONFIG_CLOCK_PLL_N (48)
54 #endif
55 #else
56 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE == MHZ(8))
57 #define CONFIG_CLOCK_PLL_N (100)
58 #elif IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE == MHZ(25))
59 #define CONFIG_CLOCK_PLL_N (200)
60 #else
61 #define CONFIG_CLOCK_PLL_N (50)
62 #endif
63 #endif /* MODULE_PERIPH_USBDEV_CLK || MODULE_PERIPH_SDMMC_CLK */
64 #endif
65 #ifndef CONFIG_CLOCK_PLL_P
66 #define CONFIG_CLOCK_PLL_P (2)
67 #endif
68 #ifndef CONFIG_CLOCK_PLL_Q
69 #define CONFIG_CLOCK_PLL_Q (4)
70 #endif
71 #ifndef CONFIG_CLOCK_PLL_R
72 #define CONFIG_CLOCK_PLL_R (4)
73 #endif
80 #ifndef CONFIG_CLOCK_APB1_DIV
81 #define CONFIG_CLOCK_APB1_DIV (2) /* max 50MHz */
82 #endif
83 #ifndef CONFIG_CLOCK_APB2_DIV
84 #define CONFIG_CLOCK_APB2_DIV (1) /* max 100MHz */
85 #endif
88 #if CLOCK_CORECLOCK > MHZ(100)
89 #error "SYSCLK cannot exceed 100MHz"
90 #endif
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
Common macros and compiler attributes/pragmas configuration.
Unit helper macros.