Loading...
Searching...
No Matches
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
19#ifndef CLK_C0_CFG_CLOCK_DEFAULT_H
20#define CLK_C0_CFG_CLOCK_DEFAULT_H
21
23#include "kernel_defines.h"
24#include "macros/units.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
35#if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE < MHZ(4) || CONFIG_CLOCK_HSE > MHZ(48))
36#error "HSE clock frequency must be between 4MHz and 48MHz"
37#endif
38
39#ifdef CPU_FAM_STM32C0
40#ifndef CONFIG_CLOCK_HSISYS_DIV
41#define CONFIG_CLOCK_HSISYS_DIV (1)
42#endif
43#endif
44
45#if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
46#define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI / CONFIG_CLOCK_HSISYS_DIV)
47
48#elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
49#if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
50#error "The board doesn't provide an HSE oscillator"
51#endif
52#define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
53
54#endif
55
56#define CLOCK_AHB CLOCK_CORECLOCK /* max: 64MHz (G0), 170MHZ (G4) */
57
58#ifndef CONFIG_CLOCK_APB1_DIV
59#define CONFIG_CLOCK_APB1_DIV (1)
60#endif
61#define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV) \
62 /* max: 64MHz (G0), 170MHZ (G4) */
65#ifdef __cplusplus
66}
67#endif
68
69#endif /* CLK_C0_CFG_CLOCK_DEFAULT_H */
Base STM32Fx/Gx/MP1/C0 clock configuration.
Common macros and compiler attributes/pragmas configuration.
Unit helper macros.