Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
clk_conf.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2019-2020 Inria
3
* SPDX-License-Identifier: LGPL-2.1-only
4
*/
5
6
#pragma once
7
18
#include "
macros/units.h
"
19
#include "
kernel_defines.h
"
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
29
#ifndef CONFIG_USE_CLOCK_HFXOSC_PLL
30
#if IS_ACTIVE(CONFIG_USE_CLOCK_HFXOSC) || \
31
IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC_PLL) || \
32
IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC)
33
#define CONFIG_USE_CLOCK_HFXOSC_PLL 0
34
#else
35
#define CONFIG_USE_CLOCK_HFXOSC_PLL 1
/* Use PLL clocked by HFXOSC by default */
36
#endif
37
#endif
/* CONFIG_USE_CLOCK_HFXOSC_PLL */
38
39
#ifndef CONFIG_USE_CLOCK_HFXOSC
40
#define CONFIG_USE_CLOCK_HFXOSC 0
41
#endif
/* CONFIG_USE_CLOCK_HFXOSC */
42
43
#ifndef CONFIG_USE_CLOCK_HFROSC_PLL
44
#define CONFIG_USE_CLOCK_HFROSC_PLL 0
45
#endif
/* CONFIG_USE_CLOCK_HFROSC_PLL */
46
47
#ifndef CONFIG_USE_CLOCK_HFROSC
48
#define CONFIG_USE_CLOCK_HFROSC 0
49
#endif
/* CONFIG_USE_CLOCK_HFROSC */
50
51
#if CONFIG_USE_CLOCK_HFXOSC_PLL && \
52
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || \
53
CONFIG_USE_CLOCK_HFXOSC)
54
#error "Cannot use HFXOSC_PLL with other clock configurations"
55
#endif
56
57
#if CONFIG_USE_CLOCK_HFXOSC && \
58
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || \
59
CONFIG_USE_CLOCK_HFXOSC_PLL)
60
#error "Cannot use HFXOSC with other clock configurations"
61
#endif
62
63
#if CONFIG_USE_CLOCK_HFROSC_PLL && \
64
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || \
65
CONFIG_USE_CLOCK_HFROSC)
66
#error "Cannot use HFROSC_PLL with other clock configurations"
67
#endif
68
69
#if CONFIG_USE_CLOCK_HFROSC && \
70
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || \
71
CONFIG_USE_CLOCK_HFROSC_PLL)
72
#error "Cannot use HFROSC with other clock configurations"
73
#endif
74
75
#define CONFIG_CLOCK_PLL_R (1)
/* Divide input clock by 2, mandatory with HFXOSC */
76
#ifndef CONFIG_CLOCK_PLL_F
77
#define CONFIG_CLOCK_PLL_F (39)
/* Multiply REFR by 80, e.g 2 * (39 + 1) */
78
#endif
79
#ifndef CONFIG_CLOCK_PLL_Q
80
#define CONFIG_CLOCK_PLL_Q (1)
/* Divide VCO by 2, e.g 2^1 */
81
#endif
82
83
#if CONFIG_USE_CLOCK_HFXOSC_PLL
84
#define CLOCK_PLL_INPUT_CLOCK MHZ(16)
85
#define CLOCK_PLL_REFR (CLOCK_PLL_INPUT_CLOCK / \
86
(CONFIG_CLOCK_PLL_R + 1))
87
#define CLOCK_PLL_VCO (CLOCK_PLL_REFR * \
88
(2 * (CONFIG_CLOCK_PLL_F + 1)))
89
#define CLOCK_PLL_OUT (CLOCK_PLL_VCO / \
90
(1 << CONFIG_CLOCK_PLL_Q))
91
#define CLOCK_CORECLOCK (CLOCK_PLL_OUT)
/* 320000000Hz with the values used above */
92
93
/* Check PLL settings */
94
#if CLOCK_PLL_REFR != MHZ(8)
95
#error "Only R=2 can be used when using HFXOSC"
96
#endif
97
#if (CLOCK_PLL_VCO < MHZ(384)) || (CLOCK_PLL_VCO > MHZ(768))
98
#error \
99
"VCO frequency must be in the range [384MHz - 768MHz], check the CLOCK_PLL_F value"
100
#endif
101
#if (CLOCK_PLL_OUT < MHZ(48)) || (CLOCK_PLL_OUT > MHZ(384))
102
#error \
103
"PLL output frequency must be in the range [48MHz - 384MHz], check the CLOCK_PLL_Q value"
104
#endif
105
106
#elif CONFIG_USE_CLOCK_HFXOSC
107
#define CLOCK_CORECLOCK MHZ(16)
108
#endif
109
110
/*
111
When using HFROSC input clock, the core clock cannot be computed from settings,
112
in this case, coreclk() returns the configured CPU frequency.
113
*/
114
#ifndef CONFIG_CLOCK_DESIRED_FREQUENCY
115
#define CONFIG_CLOCK_DESIRED_FREQUENCY MHZ(320)
116
#endif
117
118
#ifndef CONFIG_CLOCK_HFROSC_TRIM
119
#define CONFIG_CLOCK_HFROSC_TRIM (6)
/* ~72000000Hz input freq */
120
#endif
121
#ifndef CONFIG_CLOCK_HFROSC_DIV
122
#define CONFIG_CLOCK_HFROSC_DIV (1)
/* Divide by 2 */
123
#endif
126
#ifdef __cplusplus
127
}
128
#endif
129
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
units.h
Unit helper macros.
Generated on Mon Sep 22 2025 16:29:48 by
1.9.1