Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
cfg_clock_default.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018-2020 Inria
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_L0L1_CFG_CLOCK_DEFAULT_H
20
#define CLK_L0L1_CFG_CLOCK_DEFAULT_H
21
22
#include "
cfg_clock_common_lx_u5_wx.h
"
23
#include "
kernel_defines.h
"
24
#include "
macros/units.h
"
25
#include "periph_cpu.h"
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
35
#if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CONFIG_CLOCK_HSE < MHZ(1) || CONFIG_CLOCK_HSE > MHZ(24))
36
#error "HSE clock frequency must be between 1MHz and 24MHz"
37
#endif
38
39
/* The following parameters configure a 32MHz system clock with HSI as input clock */
40
#ifndef CONFIG_CLOCK_PLL_DIV
41
#define CONFIG_CLOCK_PLL_DIV (2)
42
#endif
43
#ifndef CONFIG_CLOCK_PLL_MUL
44
#define CONFIG_CLOCK_PLL_MUL (4)
45
#endif
46
47
#if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
48
#define CLOCK_CORECLOCK (CONFIG_CLOCK_HSI)
49
50
#elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
51
#if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
52
#error "The board doesn't provide an HSE oscillator"
53
#endif
54
#define CLOCK_CORECLOCK (CONFIG_CLOCK_HSE)
55
56
#elif IS_ACTIVE(CONFIG_USE_CLOCK_MSI)
57
#define CLOCK_CORECLOCK (CONFIG_CLOCK_MSI)
58
59
#elif IS_ACTIVE(CONFIG_USE_CLOCK_PLL)
60
#if IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
61
#if CONFIG_CLOCK_HSE < MHZ(2)
62
#error "HSE must be greater than 2MHz when used as PLL input clock"
63
#endif
64
#define CLOCK_PLL_SRC (CONFIG_CLOCK_HSE)
65
#else
/* CONFIG_CLOCK_HSI */
66
#define CLOCK_PLL_SRC (CONFIG_CLOCK_HSI)
67
#endif
/* CONFIG_BOARD_HAS_HSE */
68
/* PLL configuration: make sure your values are legit!
69
*
70
* compute by: CORECLOCK = ((PLL_IN / PLL_PREDIV) * PLL_MUL)
71
* with:
72
* PLL_IN: input clock is HSE if available or HSI otherwise
73
* PLL_DIV : divider, allowed values: 2, 3, 4. Default is 2.
74
* PLL_MUL: multiplier, allowed values: 3, 4, 6, 8, 12, 16, 24, 32, 48. Default is 4.
75
* CORECLOCK -> 32MHz MAX!
76
*/
77
#define CLOCK_CORECLOCK ((CLOCK_PLL_SRC * CONFIG_CLOCK_PLL_MUL) / CONFIG_CLOCK_PLL_DIV)
78
#if CLOCK_CORECLOCK > MHZ(32)
79
#error "SYSCLK cannot exceed 32MHz"
80
#endif
81
#endif
/* CONFIG_USE_CLOCK_PLL */
82
83
#define CLOCK_AHB CLOCK_CORECLOCK
/* max: 32MHz */
84
85
#ifndef CONFIG_CLOCK_APB1_DIV
86
#define CONFIG_CLOCK_APB1_DIV (1)
87
#endif
88
#define CLOCK_APB1 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB1_DIV)
/* max: 32MHz */
89
#ifndef CONFIG_CLOCK_APB2_DIV
90
#define CONFIG_CLOCK_APB2_DIV (1)
91
#endif
92
#define CLOCK_APB2 (CLOCK_CORECLOCK / CONFIG_CLOCK_APB2_DIV)
/* max: 32MHz */
95
#ifdef __cplusplus
96
}
97
#endif
98
99
#endif
/* CLK_L0L1_CFG_CLOCK_DEFAULT_H */
cfg_clock_common_lx_u5_wx.h
Base STM32Lx/U5/Wx clock configuration.
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
units.h
Unit helper macros.
Generated on Sat Dec 21 2024 20:58:02 by
1.9.8