cfg_clock_default.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2024 BISSELL Homecare, Inc.
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "kernel_defines.h"
20 #include "macros/units.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
31 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE < MHZ(4) || CONFIG_CLOCK_HSE > MHZ(48))
32 #error "HSE clock frequency must be between 4MHz and 48MHz"
33 #endif
34 
35 #ifdef CPU_FAM_STM32C0
36 #ifndef CONFIG_CLOCK_HSISYS_DIV
37 #define CONFIG_CLOCK_HSISYS_DIV (1)
38 #endif
39 #endif
40 
41 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
42 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI / CONFIG_CLOCK_HSISYS_DIV)
43 
44 #elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
45 #if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
46 #error "The board doesn't provide an HSE oscillator"
47 #endif
48 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
49 
50 #endif
51 
52 #define CLOCK_AHB CLOCK_CORECLOCK /* max: 64MHz (G0), 170MHZ (G4) */
53 
54 #ifndef CONFIG_CLOCK_APB1_DIV
55 #define CONFIG_CLOCK_APB1_DIV (1)
56 #endif
57 #define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV) \
58  /* max: 64MHz (G0), 170MHZ (G4) */
61 #ifdef __cplusplus
62 }
63 #endif
64 
Base STM32Fx/Gx/MP1/C0 clock configuration.
Common macros and compiler attributes/pragmas configuration.
Unit helper macros.