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