cfg_clock_default.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 BISSELL Homecare, Inc.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #include "kernel_defines.h"
23 #include "macros/units.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
34 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE < MHZ(4) || CONFIG_CLOCK_HSE > MHZ(48))
35 #error "HSE clock frequency must be between 4MHz and 48MHz"
36 #endif
37 
38 #ifdef CPU_FAM_STM32C0
39 #ifndef CONFIG_CLOCK_HSISYS_DIV
40 #define CONFIG_CLOCK_HSISYS_DIV (1)
41 #endif
42 #endif
43 
44 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
45 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI / CONFIG_CLOCK_HSISYS_DIV)
46 
47 #elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
48 #if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
49 #error "The board doesn't provide an HSE oscillator"
50 #endif
51 #define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
52 
53 #endif
54 
55 #define CLOCK_AHB CLOCK_CORECLOCK /* max: 64MHz (G0), 170MHZ (G4) */
56 
57 #ifndef CONFIG_CLOCK_APB1_DIV
58 #define CONFIG_CLOCK_APB1_DIV (1)
59 #endif
60 #define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV) \
61  /* max: 64MHz (G0), 170MHZ (G4) */
64 #ifdef __cplusplus
65 }
66 #endif
67 
Base STM32Fx/Gx/MP1/C0 clock configuration.
Common macros and compiler attributes/pragmas configuration.
Unit helper macros.