Zephyr API Documentation
4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stm32f0_clock.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Linaro Limited
3
* Copyright (c) 2026 Witekio
4
*
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F0_CLOCK_H_
8
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F0_CLOCK_H_
9
10
#include <
zephyr/dt-bindings/clock/stm32_common_clocks.h
>
11
13
15
#define STM32_CLOCK_BUS_AHB1 0x014
16
#define STM32_CLOCK_BUS_APB2 0x018
17
#define STM32_CLOCK_BUS_APB1 0x01c
18
19
#define STM32_PERIPH_BUS_MIN STM32_CLOCK_BUS_AHB1
20
#define STM32_PERIPH_BUS_MAX STM32_CLOCK_BUS_APB1
21
23
25
/* defined in stm32_common_clocks.h */
27
/* Low speed clocks defined in stm32_common_clocks.h */
28
#define STM32_SRC_HSI (STM32_SRC_LSI + 1)
29
#define STM32_SRC_HSI14 (STM32_SRC_HSI + 1)
30
#define STM32_SRC_HSI48 (STM32_SRC_HSI14 + 1)
32
#define STM32_SRC_PCLK (STM32_SRC_HSI48 + 1)
33
#define STM32_SRC_TIMPCLK1 (STM32_SRC_PCLK + 1)
35
#define STM32_SRC_PLLCLK (STM32_SRC_TIMPCLK1 + 1)
36
38
#define CFGR1_REG 0x04
39
#define CFGR3_REG 0x30
40
42
#define BDCR_REG 0x20
43
46
#define USART1_SEL(val) STM32_DT_CLOCK_SELECT((val), 1, 0, CFGR3_REG)
47
#define I2C1_SEL(val) STM32_DT_CLOCK_SELECT((val), 4, 4, CFGR3_REG)
48
#define CEC_SEL(val) STM32_DT_CLOCK_SELECT((val), 6, 6, CFGR3_REG)
49
#define USB_SEL(val) STM32_DT_CLOCK_SELECT((val), 7, 7, CFGR3_REG)
50
#define USART2_SEL(val) STM32_DT_CLOCK_SELECT((val), 17, 16, CFGR3_REG)
51
#define USART3_SEL(val) STM32_DT_CLOCK_SELECT((val), 19, 18, CFGR3_REG)
53
#define RTC_SEL(val) STM32_DT_CLOCK_SELECT((val), 9, 8, BDCR_REG)
54
56
#define MCO1_SEL(val) STM32_DT_CLOCK_SELECT((val), 27, 24, CFGR1_REG)
57
#define MCO1_PRE(val) STM32_DT_CLOCK_SELECT((val), 30, 28, CFGR1_REG)
58
#define MCO1_PRE_PLLDIV(pre_val, div_val) \
59
STM32_DT_CLOCK_SELECT((div_val << 3) | (pre_val), 31, 28, CFGR1_REG)
60
61
/* MCO source clock selector */
62
#define MCO_SEL_HSI14 (1)
63
#define MCO_SEL_LSI (2)
64
#define MCO_SEL_LSE (3)
65
#define MCO_SEL_SYSCLK (4)
66
#define MCO_SEL_HSI (5)
67
#define MCO_SEL_HSE (6)
68
#define MCO_SEL_PLL (7)
/* PLL/2 or PLL, see below */
69
#define MCO_SEL_HSI48 (8)
70
71
/* MCO prescaler : division factor */
72
#define MCO_PRE_DIV_1 (0)
73
#define MCO_PRE_DIV_2 (1)
74
#define MCO_PRE_DIV_4 (2)
75
#define MCO_PRE_DIV_8 (3)
76
#define MCO_PRE_DIV_16 (4)
77
#define MCO_PRE_DIV_32 (5)
78
#define MCO_PRE_DIV_64 (6)
79
#define MCO_PRE_DIV_128 (7)
80
81
/*
82
* MCO PLL source divider
83
*
84
* By default, the MCO_SEL_PLL source goes through a divide-by-2
85
* prescaler and outputs "PLL / 2". It is possible to output the
86
* undivided PLL clock by disabling the prescaler on some SoCs
87
* by using MCO_PLL_DIV_1.
88
*
89
* Refer to RM00091 Rev 10 §6.2.12 (or RM0360 Rev 5 §7.2.11) to
90
* determine if disabling the prescaler is possible on your SoC.
91
*
92
* Here is an example of how to declare the PLL as source with no division using
93
* the MCO1_PRE_PLLDIV macro:
94
* &clk_hsi {
95
* status = "okay";
96
* };
97
*
98
* &pll {
99
* clocks = <&clk_hsi>;
100
* prediv = <1>;
101
* mul = <2>;
102
* status = "okay";
103
* };
104
*
105
* &mco1 {
106
* clocks = <&rcc STM32_SRC_PLLCLK (MCO1_SEL(MCO_SEL_PLL))>;
107
* prescaler = <MCO1_PRE_PLLDIV(MCO_PRE_DIV_128, MCO_PLL_DIV_1)>;
108
* pinctrl-0 = <&rcc_mco_pa8>;
109
* pinctrl-names = "default";
110
* status = "okay";
111
* };
112
*/
113
#define MCO_PLL_DIV_2 (0)
/* default value */
114
#define MCO_PLL_DIV_1 (1)
115
117
118
#endif
/* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F0_CLOCK_H_ */
stm32_common_clocks.h
zephyr
dt-bindings
clock
stm32f0_clock.h
Generated on
for Zephyr API Documentation by
1.16.1