libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
f1/rcc.h
Go to the documentation of this file.
1/** @defgroup rcc_defines RCC Defines
2 *
3 * @brief <b>Defined Constants and Types for the STM32F1xx Reset and Clock
4 * Control</b>
5 *
6 * @ingroup STM32F1xx_defines
7 *
8 * @version 1.0.0
9 *
10 * @author @htmlonly &copy; @endhtmlonly 2009
11 * Federico Ruiz-Ugalde <memeruiz at gmail dot com>
12 * @author @htmlonly &copy; @endhtmlonly 2009
13 * Uwe Hermann <uwe@hermann-uwe.de>
14 *
15 * @date 18 August 2012
16 *
17 * LGPL License Terms @ref lgpl_license
18 * */
19/*
20 * This file is part of the libopencm3 project.
21 *
22 * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
23 * Copyright (C) 2009 Federico Ruiz-Ugalde <memeruiz at gmail dot com>
24 *
25 * This library is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU Lesser General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
29 *
30 * This library is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public License
36 * along with this library. If not, see <http://www.gnu.org/licenses/>.
37 */
38/**@{*/
39
40#ifndef LIBOPENCM3_RCC_H
41#define LIBOPENCM3_RCC_H
42
43/* Note: Regs/bits marked (**) only exist in "connectivity line" STM32s. */
44/* Note: Regs/bits marked (XX) do NOT exist in "connectivity line" STM32s. */
45
46/* --- RCC registers ------------------------------------------------------- */
47
48#define RCC_CR MMIO32(RCC_BASE + 0x00)
49#define RCC_CFGR MMIO32(RCC_BASE + 0x04)
50#define RCC_CIR MMIO32(RCC_BASE + 0x08)
51#define RCC_APB2RSTR MMIO32(RCC_BASE + 0x0c)
52#define RCC_APB1RSTR MMIO32(RCC_BASE + 0x10)
53#define RCC_AHBENR MMIO32(RCC_BASE + 0x14)
54#define RCC_APB2ENR MMIO32(RCC_BASE + 0x18)
55#define RCC_APB1ENR MMIO32(RCC_BASE + 0x1c)
56#define RCC_BDCR MMIO32(RCC_BASE + 0x20)
57#define RCC_CSR MMIO32(RCC_BASE + 0x24)
58#define RCC_AHBRSTR MMIO32(RCC_BASE + 0x28) /*(**)*/
59#define RCC_CFGR2 MMIO32(RCC_BASE + 0x2c) /*(**)*/
60
61/* --- RCC_CR values ------------------------------------------------------- */
62
63#define RCC_CR_PLL3RDY (1 << 29) /* (**) */
64#define RCC_CR_PLL3ON (1 << 28) /* (**) */
65#define RCC_CR_PLL2RDY (1 << 27) /* (**) */
66#define RCC_CR_PLL2ON (1 << 26) /* (**) */
67#define RCC_CR_PLLRDY (1 << 25)
68#define RCC_CR_PLLON (1 << 24)
69#define RCC_CR_CSSON (1 << 19)
70#define RCC_CR_HSEBYP (1 << 18)
71#define RCC_CR_HSERDY (1 << 17)
72#define RCC_CR_HSEON (1 << 16)
73/* HSICAL: [15:8] */
74/* HSITRIM: [7:3] */
75#define RCC_CR_HSIRDY (1 << 1)
76#define RCC_CR_HSION (1 << 0)
77
78/* --- RCC_CFGR values ----------------------------------------------------- */
79
80#define RCC_CFGR_OTGFSPRE (1 << 22) /* Connectivity line */
81#define RCC_CFGR_USBPRE (1 << 22) /* LD,MD, HD, XL */
82
83#define RCC_CFGR_PLLMUL_SHIFT 18
84#define RCC_CFGR_PLLMUL (0xF << RCC_CFGR_PLLMUL_SHIFT)
85
86#define RCC_CFGR_PLLXTPRE (1 << 17)
87#define RCC_CFGR_PLLSRC (1 << 16)
88
89#define RCC_CFGR_ADCPRE_SHIFT 14
90#define RCC_CFGR_ADCPRE (3 << RCC_CFGR_ADCPRE_SHIFT)
91
92#define RCC_CFGR_PPRE2_SHIFT 11
93#define RCC_CFGR_PPRE2 (7 << RCC_CFGR_PPRE2_SHIFT)
94
95#define RCC_CFGR_PPRE1_SHIFT 8
96#define RCC_CFGR_PPRE1 (7 << RCC_CFGR_PPRE1_SHIFT)
97
98#define RCC_CFGR_HPRE_SHIFT 4
99#define RCC_CFGR_HPRE (0xF << RCC_CFGR_HPRE_SHIFT)
100
101#define RCC_CFGR_SWS_SHIFT 2
102#define RCC_CFGR_SWS (3 << RCC_CFGR_SWS_SHIFT)
103
104#define RCC_CFGR_SW_SHIFT 0
105#define RCC_CFGR_SW (3 << RCC_CFGR_SW_SHIFT)
106
107/* MCO: Microcontroller clock output */
108/** @defgroup rcc_cfgr_co RCC_CFGR Microcontroller Clock Output Source
109@ingroup STM32F1xx_rcc_defines
110
111@{*/
112#define RCC_CFGR_MCO_SHIFT 24
113#define RCC_CFGR_MCO_MASK 0xf
114#define RCC_CFGR_MCO_NOCLK 0x0
115#define RCC_CFGR_MCO_SYSCLK 0x4
116#define RCC_CFGR_MCO_HSI 0x5
117#define RCC_CFGR_MCO_HSE 0x6
118#define RCC_CFGR_MCO_PLL_DIV2 0x7
119#define RCC_CFGR_MCO_PLL2 0x8 /* (**) */
120#define RCC_CFGR_MCO_PLL3_DIV2 0x9 /* (**) */
121#define RCC_CFGR_MCO_XT1 0xa /* (**) */
122#define RCC_CFGR_MCO_PLL3 0xb /* (**) */
123/**@}*/
124
125/* USBPRE: USB prescaler (RCC_CFGR[22]) */
126/** @defgroup rcc_cfgr_usbpre RCC_CFGR USB prescale Factors
127@ingroup STM32F1xx_rcc_defines
128
129@{*/
130#define RCC_CFGR_USBPRE_PLL_CLK_DIV1_5 0x0
131#define RCC_CFGR_USBPRE_PLL_CLK_NODIV 0x1
132/**@}*/
133
134/* OTGFSPRE: USB OTG FS prescaler (RCC_CFGR[22]; only in conn. line STM32s) */
135#define RCC_CFGR_USBPRE_PLL_VCO_CLK_DIV3 0x0
136#define RCC_CFGR_USBPRE_PLL_VCO_CLK_DIV2 0x1
137
138/* PLLMUL: PLL multiplication factor */
139/** @defgroup rcc_cfgr_pmf RCC_CFGR PLL Multiplication Factor
140@ingroup STM32F1xx_rcc_defines
141
142@{*/
143#define RCC_CFGR_PLLMUL_PLL_CLK_MUL2 0x0 /* (XX) */
144#define RCC_CFGR_PLLMUL_PLL_CLK_MUL3 0x1 /* (XX) */
145#define RCC_CFGR_PLLMUL_PLL_CLK_MUL4 0x2
146#define RCC_CFGR_PLLMUL_PLL_CLK_MUL5 0x3
147#define RCC_CFGR_PLLMUL_PLL_CLK_MUL6 0x4
148#define RCC_CFGR_PLLMUL_PLL_CLK_MUL7 0x5
149#define RCC_CFGR_PLLMUL_PLL_CLK_MUL8 0x6
150#define RCC_CFGR_PLLMUL_PLL_CLK_MUL9 0x7
151#define RCC_CFGR_PLLMUL_PLL_CLK_MUL10 0x8 /* (XX) */
152#define RCC_CFGR_PLLMUL_PLL_CLK_MUL11 0x9 /* (XX) */
153#define RCC_CFGR_PLLMUL_PLL_CLK_MUL12 0xa /* (XX) */
154#define RCC_CFGR_PLLMUL_PLL_CLK_MUL13 0xb /* (XX) */
155#define RCC_CFGR_PLLMUL_PLL_CLK_MUL14 0xc /* (XX) */
156#define RCC_CFGR_PLLMUL_PLL_CLK_MUL15 0xd /* 0xd: PLL x 15 */
157#define RCC_CFGR_PLLMUL_PLL_CLK_MUL6_5 0xd /* 0xd: PLL x 6.5 for conn.
158 line */
159#define RCC_CFGR_PLLMUL_PLL_CLK_MUL16 0xe /* (XX) */
160/* #define PLLMUL_PLL_CLK_MUL16 0xf */ /* (XX) */ /* Errata? 17? */
161/**@}*/
162
163/* TODO: conn. line differs. */
164/* PLLXTPRE: HSE divider for PLL entry */
165/** @defgroup rcc_cfgr_hsepre RCC_CFGR HSE Divider for PLL
166@ingroup STM32F1xx_rcc_defines
167
168@{*/
169#define RCC_CFGR_PLLXTPRE_HSE_CLK 0x0
170#define RCC_CFGR_PLLXTPRE_HSE_CLK_DIV2 0x1
171/**@}*/
172
173/* PLLSRC: PLL entry clock source */
174/** @defgroup rcc_cfgr_pcs RCC_CFGR PLL Clock Source
175@ingroup STM32F1xx_rcc_defines
176
177@{*/
178#define RCC_CFGR_PLLSRC_HSI_CLK_DIV2 0x0
179#define RCC_CFGR_PLLSRC_HSE_CLK 0x1
180#define RCC_CFGR_PLLSRC_PREDIV1_CLK 0x1 /* On conn. line */
181/**@}*/
182
183/* ADCPRE: ADC prescaler */
184/****************************************************************************/
185/** @defgroup rcc_cfgr_adcpre RCC ADC clock prescaler enable values
186@ingroup STM32F1xx_rcc_defines
187
188@{*/
189#define RCC_CFGR_ADCPRE_DIV2 0x0
190#define RCC_CFGR_ADCPRE_DIV4 0x1
191#define RCC_CFGR_ADCPRE_DIV6 0x2
192#define RCC_CFGR_ADCPRE_DIV8 0x3
193/**@}*/
195#define RCC_CFGR_PPRE2_SHIFT 11
196#define RCC_CFGR_PPRE2_MASK 0x7
197#define RCC_CFGR_PPRE1_SHIFT 8
198#define RCC_CFGR_PPRE1_MASK 0x7
199/** @defgroup rcc_cfgr_apbxpre RCC_CFGR APBx prescale factors
200 * These can be used for both APB1 and APB2 prescaling
201 * @{
202 */
203#define RCC_CFGR_PPRE_NODIV 0x0
204#define RCC_CFGR_PPRE_DIV2 0x4
205#define RCC_CFGR_PPRE_DIV4 0x5
206#define RCC_CFGR_PPRE_DIV8 0x6
207#define RCC_CFGR_PPRE_DIV16 0x7
208/**@}*/
209
210/* HPRE: AHB prescaler */
211/** @defgroup rcc_cfgr_ahbpre RCC_CFGR AHB prescale Factors
212@ingroup STM32F1xx_rcc_defines
213
214@{*/
215#define RCC_CFGR_HPRE_NODIV 0x0
216#define RCC_CFGR_HPRE_DIV2 0x8
217#define RCC_CFGR_HPRE_DIV4 0x9
218#define RCC_CFGR_HPRE_DIV8 0xa
219#define RCC_CFGR_HPRE_DIV16 0xb
220#define RCC_CFGR_HPRE_DIV64 0xc
221#define RCC_CFGR_HPRE_DIV128 0xd
222#define RCC_CFGR_HPRE_DIV256 0xe
223#define RCC_CFGR_HPRE_DIV512 0xf
224/**@}*/
225
226/* SWS: System clock switch status */
227#define RCC_CFGR_SWS_SYSCLKSEL_HSICLK 0x0
228#define RCC_CFGR_SWS_SYSCLKSEL_HSECLK 0x1
229#define RCC_CFGR_SWS_SYSCLKSEL_PLLCLK 0x2
230
231/* SW: System clock switch */
232/** @defgroup rcc_cfgr_scs RCC_CFGR System Clock Selection
233@ingroup STM32F1xx_rcc_defines
234
235@{*/
236#define RCC_CFGR_SW_SYSCLKSEL_HSICLK 0x0
237#define RCC_CFGR_SW_SYSCLKSEL_HSECLK 0x1
238#define RCC_CFGR_SW_SYSCLKSEL_PLLCLK 0x2
239/**@}*/
240
241/** Older compatible definitions to ease migration
242 * @defgroup rcc_cfgr_deprecated RCC_CFGR Deprecated dividers
243 * @deprecated Use _CFGR_xPRE_DIVn form instead, across all families
244 * @{
245 */
246#define RCC_CFGR_ADCPRE_PCLK2_DIV2 0x0
247#define RCC_CFGR_ADCPRE_PCLK2_DIV4 0x1
248#define RCC_CFGR_ADCPRE_PCLK2_DIV6 0x2
249#define RCC_CFGR_ADCPRE_PCLK2_DIV8 0x3
251#define RCC_CFGR_PPRE2_HCLK_NODIV 0x0
252#define RCC_CFGR_PPRE2_HCLK_DIV2 0x4
253#define RCC_CFGR_PPRE2_HCLK_DIV4 0x5
254#define RCC_CFGR_PPRE2_HCLK_DIV8 0x6
255#define RCC_CFGR_PPRE2_HCLK_DIV16 0x7
257#define RCC_CFGR_PPRE1_HCLK_NODIV 0x0
258#define RCC_CFGR_PPRE1_HCLK_DIV2 0x4
259#define RCC_CFGR_PPRE1_HCLK_DIV4 0x5
260#define RCC_CFGR_PPRE1_HCLK_DIV8 0x6
261#define RCC_CFGR_PPRE1_HCLK_DIV16 0x7
263#define RCC_CFGR_HPRE_SYSCLK_NODIV 0x0
264#define RCC_CFGR_HPRE_SYSCLK_DIV2 0x8
265#define RCC_CFGR_HPRE_SYSCLK_DIV4 0x9
266#define RCC_CFGR_HPRE_SYSCLK_DIV8 0xa
267#define RCC_CFGR_HPRE_SYSCLK_DIV16 0xb
268#define RCC_CFGR_HPRE_SYSCLK_DIV64 0xc
269#define RCC_CFGR_HPRE_SYSCLK_DIV128 0xd
270#define RCC_CFGR_HPRE_SYSCLK_DIV256 0xe
271#define RCC_CFGR_HPRE_SYSCLK_DIV512 0xf
272
273/** @}*/
274
275/* --- RCC_CIR values ------------------------------------------------------ */
276
277/* Clock security system interrupt clear bit */
278#define RCC_CIR_CSSC (1 << 23)
279
280/* OSC ready interrupt clear bits */
281#define RCC_CIR_PLL3RDYC (1 << 22) /* (**) */
282#define RCC_CIR_PLL2RDYC (1 << 21) /* (**) */
283#define RCC_CIR_PLLRDYC (1 << 20)
284#define RCC_CIR_HSERDYC (1 << 19)
285#define RCC_CIR_HSIRDYC (1 << 18)
286#define RCC_CIR_LSERDYC (1 << 17)
287#define RCC_CIR_LSIRDYC (1 << 16)
288
289/* OSC ready interrupt enable bits */
290#define RCC_CIR_PLL3RDYIE (1 << 14) /* (**) */
291#define RCC_CIR_PLL2RDYIE (1 << 13) /* (**) */
292#define RCC_CIR_PLLRDYIE (1 << 12)
293#define RCC_CIR_HSERDYIE (1 << 11)
294#define RCC_CIR_HSIRDYIE (1 << 10)
295#define RCC_CIR_LSERDYIE (1 << 9)
296#define RCC_CIR_LSIRDYIE (1 << 8)
297
298/* Clock security system interrupt flag bit */
299#define RCC_CIR_CSSF (1 << 7)
300
301/* OSC ready interrupt flag bits */
302#define RCC_CIR_PLL3RDYF (1 << 6) /* (**) */
303#define RCC_CIR_PLL2RDYF (1 << 5) /* (**) */
304#define RCC_CIR_PLLRDYF (1 << 4)
305#define RCC_CIR_HSERDYF (1 << 3)
306#define RCC_CIR_HSIRDYF (1 << 2)
307#define RCC_CIR_LSERDYF (1 << 1)
308#define RCC_CIR_LSIRDYF (1 << 0)
309
310/* --- RCC_APB2RSTR values ------------------------------------------------- */
311
312/** @defgroup rcc_apb2rstr_rst RCC_APB2RSTR reset values
313@ingroup STM32F1xx_rcc_defines
314
315@{*/
316#define RCC_APB2RSTR_TIM17RST (1 << 18)
317#define RCC_APB2RSTR_TIM16RST (1 << 17)
318#define RCC_APB2RSTR_TIM15RST (1 << 16)
319#define RCC_APB2RSTR_ADC3RST (1 << 15) /* (XX) */
320#define RCC_APB2RSTR_USART1RST (1 << 14)
321#define RCC_APB2RSTR_TIM8RST (1 << 13) /* (XX) */
322#define RCC_APB2RSTR_SPI1RST (1 << 12)
323#define RCC_APB2RSTR_TIM1RST (1 << 11)
324#define RCC_APB2RSTR_ADC2RST (1 << 10)
325#define RCC_APB2RSTR_ADC1RST (1 << 9)
326#define RCC_APB2RSTR_IOPGRST (1 << 8) /* (XX) */
327#define RCC_APB2RSTR_IOPFRST (1 << 7) /* (XX) */
328#define RCC_APB2RSTR_IOPERST (1 << 6)
329#define RCC_APB2RSTR_IOPDRST (1 << 5)
330#define RCC_APB2RSTR_IOPCRST (1 << 4)
331#define RCC_APB2RSTR_IOPBRST (1 << 3)
332#define RCC_APB2RSTR_IOPARST (1 << 2)
333#define RCC_APB2RSTR_AFIORST (1 << 0)
334/**@}*/
335
336/* --- RCC_APB1RSTR values ------------------------------------------------- */
337
338/** @defgroup rcc_apb1rstr_rst RCC_APB1RSTR reset values
339@ingroup STM32F1xx_rcc_defines
340
341@{*/
342#define RCC_APB1RSTR_DACRST (1 << 29)
343#define RCC_APB1RSTR_PWRRST (1 << 28)
344#define RCC_APB1RSTR_BKPRST (1 << 27)
345#define RCC_APB1RSTR_CAN2RST (1 << 26) /* (**) */
346#define RCC_APB1RSTR_CAN1RST (1 << 25) /* (**) */
347#define RCC_APB1RSTR_CANRST (1 << 25) /* (XX) Alias for
348 CAN1RST */
349#define RCC_APB1RSTR_USBRST (1 << 23) /* (XX) */
350#define RCC_APB1RSTR_I2C2RST (1 << 22)
351#define RCC_APB1RSTR_I2C1RST (1 << 21)
352#define RCC_APB1RSTR_UART5RST (1 << 20)
353#define RCC_APB1RSTR_UART4RST (1 << 19)
354#define RCC_APB1RSTR_USART3RST (1 << 18)
355#define RCC_APB1RSTR_USART2RST (1 << 17)
356#define RCC_APB1RSTR_SPI3RST (1 << 15)
357#define RCC_APB1RSTR_SPI2RST (1 << 14)
358#define RCC_APB1RSTR_WWDGRST (1 << 11)
359#define RCC_APB1RSTR_TIM7RST (1 << 5)
360#define RCC_APB1RSTR_TIM6RST (1 << 4)
361#define RCC_APB1RSTR_TIM5RST (1 << 3)
362#define RCC_APB1RSTR_TIM4RST (1 << 2)
363#define RCC_APB1RSTR_TIM3RST (1 << 1)
364#define RCC_APB1RSTR_TIM2RST (1 << 0)
365/**@}*/
366
367/* --- RCC_AHBENR values --------------------------------------------------- */
368
369/** @defgroup rcc_ahbenr_en RCC_AHBENR enable values
370@ingroup STM32F1xx_rcc_defines
372@{*/
373#define RCC_AHBENR_ETHMACENRX (1 << 16)
374#define RCC_AHBENR_ETHMACENTX (1 << 15)
375#define RCC_AHBENR_ETHMACEN (1 << 14)
376#define RCC_AHBENR_OTGFSEN (1 << 12)
377#define RCC_AHBENR_SDIOEN (1 << 10)
378#define RCC_AHBENR_FSMCEN (1 << 8)
379#define RCC_AHBENR_CRCEN (1 << 6)
380#define RCC_AHBENR_FLITFEN (1 << 4)
381#define RCC_AHBENR_SRAMEN (1 << 2)
382#define RCC_AHBENR_DMA2EN (1 << 1)
383#define RCC_AHBENR_DMA1EN (1 << 0)
384/**@}*/
385
386/* --- RCC_APB2ENR values -------------------------------------------------- */
387
388/** @defgroup rcc_apb2enr_en RCC_APB2ENR enable values
389@ingroup STM32F1xx_rcc_defines
391@{*/
392#define RCC_APB2ENR_TIM17EN (1 << 18)
393#define RCC_APB2ENR_TIM16EN (1 << 17)
394#define RCC_APB2ENR_TIM15EN (1 << 16)
395#define RCC_APB2ENR_ADC3EN (1 << 15) /* (XX) */
396#define RCC_APB2ENR_USART1EN (1 << 14)
397#define RCC_APB2ENR_TIM8EN (1 << 13) /* (XX) */
398#define RCC_APB2ENR_SPI1EN (1 << 12)
399#define RCC_APB2ENR_TIM1EN (1 << 11)
400#define RCC_APB2ENR_ADC2EN (1 << 10)
401#define RCC_APB2ENR_ADC1EN (1 << 9)
402#define RCC_APB2ENR_IOPGEN (1 << 8) /* (XX) */
403#define RCC_APB2ENR_IOPFEN (1 << 7) /* (XX) */
404#define RCC_APB2ENR_IOPEEN (1 << 6)
405#define RCC_APB2ENR_IOPDEN (1 << 5)
406#define RCC_APB2ENR_IOPCEN (1 << 4)
407#define RCC_APB2ENR_IOPBEN (1 << 3)
408#define RCC_APB2ENR_IOPAEN (1 << 2)
409#define RCC_APB2ENR_AFIOEN (1 << 0)
410/**@}*/
411
412/* --- RCC_APB1ENR values -------------------------------------------------- */
413
414/** @defgroup rcc_apb1enr_en RCC_APB1ENR enable values
415@ingroup STM32F1xx_rcc_defines
417@{*/
418#define RCC_APB1ENR_DACEN (1 << 29)
419#define RCC_APB1ENR_PWREN (1 << 28)
420#define RCC_APB1ENR_BKPEN (1 << 27)
421#define RCC_APB1ENR_CAN2EN (1 << 26) /* (**) */
422#define RCC_APB1ENR_CAN1EN (1 << 25) /* (**) */
423#define RCC_APB1ENR_CANEN (1 << 25) /* (XX) Alias for
424 CAN1EN */
425#define RCC_APB1ENR_USBEN (1 << 23) /* (XX) */
426#define RCC_APB1ENR_I2C2EN (1 << 22)
427#define RCC_APB1ENR_I2C1EN (1 << 21)
428#define RCC_APB1ENR_UART5EN (1 << 20)
429#define RCC_APB1ENR_UART4EN (1 << 19)
430#define RCC_APB1ENR_USART3EN (1 << 18)
431#define RCC_APB1ENR_USART2EN (1 << 17)
432#define RCC_APB1ENR_SPI3EN (1 << 15)
433#define RCC_APB1ENR_SPI2EN (1 << 14)
434#define RCC_APB1ENR_WWDGEN (1 << 11)
435#define RCC_APB1ENR_TIM7EN (1 << 5)
436#define RCC_APB1ENR_TIM6EN (1 << 4)
437#define RCC_APB1ENR_TIM5EN (1 << 3)
438#define RCC_APB1ENR_TIM4EN (1 << 2)
439#define RCC_APB1ENR_TIM3EN (1 << 1)
440#define RCC_APB1ENR_TIM2EN (1 << 0)
441/**@}*/
443/* --- RCC_BDCR values ----------------------------------------------------- */
444
445#define RCC_BDCR_BDRST (1 << 16)
446#define RCC_BDCR_RTCEN (1 << 15)
447/* RCC_BDCR[9:8]: RTCSEL */
448#define RCC_BDCR_LSEBYP (1 << 2)
449#define RCC_BDCR_LSERDY (1 << 1)
450#define RCC_BDCR_LSEON (1 << 0)
452/* --- RCC_CSR values ------------------------------------------------------ */
454#define RCC_CSR_LPWRRSTF (1 << 31)
455#define RCC_CSR_WWDGRSTF (1 << 30)
456#define RCC_CSR_IWDGRSTF (1 << 29)
457#define RCC_CSR_SFTRSTF (1 << 28)
458#define RCC_CSR_PORRSTF (1 << 27)
459#define RCC_CSR_PINRSTF (1 << 26)
460#define RCC_CSR_RMVF (1 << 24)
461#define RCC_CSR_RESET_FLAGS (RCC_CSR_LPWRRSTF | RCC_CSR_WWDGRSTF |\
462 RCC_CSR_IWDGRSTF | RCC_CSR_SFTRSTF | RCC_CSR_PORRSTF |\
463 RCC_CSR_PINRSTF)
464#define RCC_CSR_LSIRDY (1 << 1)
465#define RCC_CSR_LSION (1 << 0)
466
467/* --- RCC_AHBRSTR values -------------------------------------------------- */
468
469/** @defgroup rcc_ahbrstr_rst RCC_AHBRSTR reset values
470@ingroup STM32F1xx_rcc_defines
472@{*/
473#define RCC_AHBRSTR_ETHMACRST (1 << 14)
474#define RCC_AHBRSTR_OTGFSRST (1 << 12)
475/**@}*/
476
477/* --- RCC_CFGR2 values ---------------------------------------------------- */
479/* I2S3SRC: I2S3 clock source */
480#define RCC_CFGR2_I2S3SRC_SYSCLK 0x0
481#define RCC_CFGR2_I2S3SRC_PLL3_VCO_CLK 0x1
483/* I2S2SRC: I2S2 clock source */
484#define RCC_CFGR2_I2S2SRC_SYSCLK 0x0
485#define RCC_CFGR2_I2S2SRC_PLL3_VCO_CLK 0x1
486#define RCC_CFGR2_I2S2SRC (1 << 17)
488/* PREDIV1SRC: PREDIV1 entry clock source */
489#define RCC_CFGR2_PREDIV1SRC_HSE_CLK 0x0
490#define RCC_CFGR2_PREDIV1SRC_PLL2_CLK 0x1
491#define RCC_CFGR2_PREDIV1SRC (1 << 16)
492
493#define RCC_CFGR2_PLL3MUL_SHIFT 12
494#define RCC_CFGR2_PLL3MUL (0xF << RCC_CFGR2_PLL3MUL_SHIFT)
495
496#define RCC_CFGR2_PLL2MUL_SHIFT 8
497#define RCC_CFGR2_PLL2MUL (0xF << RCC_CFGR2_PLL2MUL_SHIFT)
498
499#define RCC_CFGR2_PREDIV2_SHIFT 4
500#define RCC_CFGR2_PREDIV2 (0xF << RCC_CFGR2_PREDIV2_SHIFT)
501
502#define RCC_CFGR2_PREDIV1_SHIFT 0
503#define RCC_CFGR2_PREDIV1 (0xF << RCC_CFGR2_PREDIV1_SHIFT)
505/* PLL3MUL: PLL3 multiplication factor */
506#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL8 0x6
507#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL9 0x7
508#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL10 0x8
509#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL11 0x9
510#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL12 0xa
511#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL13 0xb
512#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL14 0xc
513#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL16 0xe
514#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL20 0xf
516/* PLL2MUL: PLL2 multiplication factor */
517#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL8 0x6
518#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL9 0x7
519#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL10 0x8
520#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL11 0x9
521#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL12 0xa
522#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL13 0xb
523#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL14 0xc
524#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL16 0xe
525#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL20 0xf
527/* PREDIV: PREDIV division factor */
528#define RCC_CFGR2_PREDIV_NODIV 0x0
529#define RCC_CFGR2_PREDIV_DIV2 0x1
530#define RCC_CFGR2_PREDIV_DIV3 0x2
531#define RCC_CFGR2_PREDIV_DIV4 0x3
532#define RCC_CFGR2_PREDIV_DIV5 0x4
533#define RCC_CFGR2_PREDIV_DIV6 0x5
534#define RCC_CFGR2_PREDIV_DIV7 0x6
535#define RCC_CFGR2_PREDIV_DIV8 0x7
536#define RCC_CFGR2_PREDIV_DIV9 0x8
537#define RCC_CFGR2_PREDIV_DIV10 0x9
538#define RCC_CFGR2_PREDIV_DIV11 0xa
539#define RCC_CFGR2_PREDIV_DIV12 0xb
540#define RCC_CFGR2_PREDIV_DIV13 0xc
541#define RCC_CFGR2_PREDIV_DIV14 0xd
542#define RCC_CFGR2_PREDIV_DIV15 0xe
543#define RCC_CFGR2_PREDIV_DIV16 0xf
545/* PREDIV2: PREDIV2 division factor */
546#define RCC_CFGR2_PREDIV2_NODIV 0x0
547#define RCC_CFGR2_PREDIV2_DIV2 0x1
548#define RCC_CFGR2_PREDIV2_DIV3 0x2
549#define RCC_CFGR2_PREDIV2_DIV4 0x3
550#define RCC_CFGR2_PREDIV2_DIV5 0x4
551#define RCC_CFGR2_PREDIV2_DIV6 0x5
552#define RCC_CFGR2_PREDIV2_DIV7 0x6
553#define RCC_CFGR2_PREDIV2_DIV8 0x7
554#define RCC_CFGR2_PREDIV2_DIV9 0x8
555#define RCC_CFGR2_PREDIV2_DIV10 0x9
556#define RCC_CFGR2_PREDIV2_DIV11 0xa
557#define RCC_CFGR2_PREDIV2_DIV12 0xb
558#define RCC_CFGR2_PREDIV2_DIV13 0xc
559#define RCC_CFGR2_PREDIV2_DIV14 0xd
560#define RCC_CFGR2_PREDIV2_DIV15 0xe
561#define RCC_CFGR2_PREDIV2_DIV16 0xf
562
563/* --- Variable definitions ------------------------------------------------ */
564extern uint32_t rcc_ahb_frequency;
565extern uint32_t rcc_apb1_frequency;
566extern uint32_t rcc_apb2_frequency;
568/* --- Function prototypes ------------------------------------------------- */
570enum rcc_osc {
572};
573
574#define _REG_BIT(base, bit) (((base) << 5) + (bit))
575
576/* V = value line F100
577 * N = standard line F101, F102, F103
578 * C = communication line F105, F107
579 */
582 /* AHB peripherals */
583 RCC_DMA1 = _REG_BIT(0x14, 0),/*VNC*/
584 RCC_DMA2 = _REG_BIT(0x14, 1),/*VNC*/
585 RCC_SRAM = _REG_BIT(0x14, 2),/*VNC*/
586 RCC_FLTF = _REG_BIT(0x14, 4),/*VNC*/
587 RCC_CRC = _REG_BIT(0x14, 6),/*VNC*/
588 RCC_FSMC = _REG_BIT(0x14, 8),/*VN-*/
589 RCC_SDIO = _REG_BIT(0x14, 10),/*-N-*/
590 RCC_OTGFS = _REG_BIT(0x14, 12),/*--C*/
591 RCC_ETHMAC = _REG_BIT(0x14, 14),/*--C*/
592 RCC_ETHMACTX = _REG_BIT(0x14, 15),/*--C*/
593 RCC_ETHMACRX = _REG_BIT(0x14, 16),/*--C*/
595 /* APB2 peripherals */
596 RCC_AFIO = _REG_BIT(0x18, 0),/*VNC*/
597 RCC_GPIOA = _REG_BIT(0x18, 2),/*VNC*/
598 RCC_GPIOB = _REG_BIT(0x18, 3),/*VNC*/
599 RCC_GPIOC = _REG_BIT(0x18, 4),/*VNC*/
600 RCC_GPIOD = _REG_BIT(0x18, 5),/*VNC*/
601 RCC_GPIOE = _REG_BIT(0x18, 6),/*VNC*/
602 RCC_GPIOF = _REG_BIT(0x18, 7),/*VN-*/
603 RCC_GPIOG = _REG_BIT(0x18, 8),/*VN-*/
604 RCC_ADC1 = _REG_BIT(0x18, 9),/*VNC*/
605 RCC_ADC2 = _REG_BIT(0x18, 10),/*-NC*/
606 RCC_TIM1 = _REG_BIT(0x18, 11),/*VNC*/
607 RCC_SPI1 = _REG_BIT(0x18, 12),/*VNC*/
608 RCC_TIM8 = _REG_BIT(0x18, 13),/*-N-*/
609 RCC_USART1 = _REG_BIT(0x18, 14),/*VNC*/
610 RCC_ADC3 = _REG_BIT(0x18, 15),/*-N-*/
611 RCC_TIM15 = _REG_BIT(0x18, 16),/*V--*/
612 RCC_TIM16 = _REG_BIT(0x18, 17),/*V--*/
613 RCC_TIM17 = _REG_BIT(0x18, 18),/*V--*/
614 RCC_TIM9 = _REG_BIT(0x18, 19),/*-N-*/
615 RCC_TIM10 = _REG_BIT(0x18, 20),/*-N-*/
616 RCC_TIM11 = _REG_BIT(0x18, 21),/*-N-*/
618 /* APB1 peripherals */
619 RCC_TIM2 = _REG_BIT(0x1C, 0),/*VNC*/
620 RCC_TIM3 = _REG_BIT(0x1C, 1),/*VNC*/
621 RCC_TIM4 = _REG_BIT(0x1C, 2),/*VNC*/
622 RCC_TIM5 = _REG_BIT(0x1C, 3),/*VNC*/
623 RCC_TIM6 = _REG_BIT(0x1C, 4),/*VNC*/
624 RCC_TIM7 = _REG_BIT(0x1C, 5),/*VNC*/
625 RCC_TIM12 = _REG_BIT(0x1C, 6),/*VN-*/
626 RCC_TIM13 = _REG_BIT(0x1C, 7),/*VN-*/
627 RCC_TIM14 = _REG_BIT(0x1C, 8),/*VN-*/
628 RCC_WWDG = _REG_BIT(0x1C, 11),/*VNC*/
629 RCC_SPI2 = _REG_BIT(0x1C, 14),/*VNC*/
630 RCC_SPI3 = _REG_BIT(0x1C, 15),/*VNC*/
631 RCC_USART2 = _REG_BIT(0x1C, 17),/*VNC*/
632 RCC_USART3 = _REG_BIT(0x1C, 18),/*VNC*/
633 RCC_UART4 = _REG_BIT(0x1C, 19),/*VNC*/
634 RCC_UART5 = _REG_BIT(0x1C, 20),/*VNC*/
635 RCC_I2C1 = _REG_BIT(0x1C, 21),/*VNC*/
636 RCC_I2C2 = _REG_BIT(0x1C, 22),/*VNC*/
637 RCC_USB = _REG_BIT(0x1C, 23),/*-N-*/
638 RCC_CAN = _REG_BIT(0x1C, 25),/*-N-*/
639 RCC_CAN1 = _REG_BIT(0x1C, 25),/*--C*/
640 RCC_CAN2 = _REG_BIT(0x1C, 26),/*--C*/
641 RCC_BKP = _REG_BIT(0x1C, 27),/*VNC*/
642 RCC_PWR = _REG_BIT(0x1C, 28),/*VNC*/
643 RCC_DAC = _REG_BIT(0x1C, 29),/*VNC*/
644 RCC_CEC = _REG_BIT(0x1C, 30),/*V--*/
645};
646
649 /* AHB peripherals */
650 RST_OTGFS = _REG_BIT(0x28, 12),/*--C*/
651 RST_ETHMAC = _REG_BIT(0x28, 14),/*--C*/
653 /* APB2 peripherals */
654 RST_AFIO = _REG_BIT(0x0c, 0),/*VNC*/
655 RST_GPIOA = _REG_BIT(0x0c, 2),/*VNC*/
656 RST_GPIOB = _REG_BIT(0x0c, 3),/*VNC*/
657 RST_GPIOC = _REG_BIT(0x0c, 4),/*VNC*/
658 RST_GPIOD = _REG_BIT(0x0c, 5),/*VNC*/
659 RST_GPIOE = _REG_BIT(0x0c, 6),/*VNC*/
660 RST_GPIOF = _REG_BIT(0x0c, 7),/*VN-*/
661 RST_GPIOG = _REG_BIT(0x0c, 8),/*VN-*/
662 RST_ADC1 = _REG_BIT(0x0c, 9),/*VNC*/
663 RST_ADC2 = _REG_BIT(0x0c, 10),/*-NC*/
664 RST_TIM1 = _REG_BIT(0x0c, 11),/*VNC*/
665 RST_SPI1 = _REG_BIT(0x0c, 12),/*VNC*/
666 RST_TIM8 = _REG_BIT(0x0c, 13),/*-N-*/
667 RST_USART1 = _REG_BIT(0x0c, 14),/*VNC*/
668 RST_ADC3 = _REG_BIT(0x0c, 15),/*-N-*/
669 RST_TIM15 = _REG_BIT(0x0c, 16),/*V--*/
670 RST_TIM16 = _REG_BIT(0x0c, 17),/*V--*/
671 RST_TIM17 = _REG_BIT(0x0c, 18),/*V--*/
672 RST_TIM9 = _REG_BIT(0x0c, 19),/*-N-*/
673 RST_TIM10 = _REG_BIT(0x0c, 20),/*-N-*/
674 RST_TIM11 = _REG_BIT(0x0c, 21),/*-N-*/
676 /* APB1 peripherals */
677 RST_TIM2 = _REG_BIT(0x10, 0),/*VNC*/
678 RST_TIM3 = _REG_BIT(0x10, 1),/*VNC*/
679 RST_TIM4 = _REG_BIT(0x10, 2),/*VNC*/
680 RST_TIM5 = _REG_BIT(0x10, 3),/*VNC*/
681 RST_TIM6 = _REG_BIT(0x10, 4),/*VNC*/
682 RST_TIM7 = _REG_BIT(0x10, 5),/*VNC*/
683 RST_TIM12 = _REG_BIT(0x10, 6),/*VN-*/
684 RST_TIM13 = _REG_BIT(0x10, 7),/*VN-*/
685 RST_TIM14 = _REG_BIT(0x10, 8),/*VN-*/
686 RST_WWDG = _REG_BIT(0x10, 11),/*VNC*/
687 RST_SPI2 = _REG_BIT(0x10, 14),/*VNC*/
688 RST_SPI3 = _REG_BIT(0x10, 15),/*VNC*/
689 RST_USART2 = _REG_BIT(0x10, 17),/*VNC*/
690 RST_USART3 = _REG_BIT(0x10, 18),/*VNC*/
691 RST_UART4 = _REG_BIT(0x10, 19),/*VNC*/
692 RST_UART5 = _REG_BIT(0x10, 20),/*VNC*/
693 RST_I2C1 = _REG_BIT(0x10, 21),/*VNC*/
694 RST_I2C2 = _REG_BIT(0x10, 22),/*VNC*/
695 RST_USB = _REG_BIT(0x10, 23),/*-N-*/
696 RST_CAN = _REG_BIT(0x10, 25),/*-N-*/
697 RST_CAN1 = _REG_BIT(0x10, 25),/*--C*/
698 RST_CAN2 = _REG_BIT(0x10, 26),/*--C*/
699 RST_BKP = _REG_BIT(0x10, 27),/*VNC*/
700 RST_PWR = _REG_BIT(0x10, 28),/*VNC*/
701 RST_DAC = _REG_BIT(0x10, 29),/*VNC*/
702 RST_CEC = _REG_BIT(0x10, 30),/*V--*/
703};
723/* Union of all options for f100 through to f107 */
725 uint8_t pll_mul;
726 uint8_t pll_source;
727 uint8_t hpre;
728 uint8_t ppre1;
729 uint8_t ppre2;
730 uint8_t adcpre;
732 uint8_t prediv1; /* aka xtpre, only one bit on smaller parts */
734 uint8_t prediv2;
735 uint8_t pll2_mul;
736 uint8_t pll3_mul;
737 uint8_t usbpre;
738 uint32_t ahb_frequency;
739 uint32_t apb1_frequency;
740 uint32_t apb2_frequency;
741};
742
745
747
748void rcc_osc_ready_int_clear(enum rcc_osc osc);
749void rcc_osc_ready_int_enable(enum rcc_osc osc);
751int rcc_osc_ready_int_flag(enum rcc_osc osc);
752void rcc_css_int_clear(void);
753int rcc_css_int_flag(void);
754void rcc_osc_on(enum rcc_osc osc);
755void rcc_osc_off(enum rcc_osc osc);
756void rcc_css_enable(void);
757void rcc_css_disable(void);
758void rcc_set_sysclk_source(uint32_t clk);
759void rcc_set_pll_multiplication_factor(uint32_t mul);
760void rcc_set_pll2_multiplication_factor(uint32_t mul);
761void rcc_set_pll3_multiplication_factor(uint32_t mul);
762void rcc_set_pll_source(uint32_t pllsrc);
763void rcc_set_pllxtpre(uint32_t pllxtpre);
764uint32_t rcc_rtc_clock_enabled_flag(void);
765void rcc_enable_rtc_clock(void);
766void rcc_set_rtc_clock_source(enum rcc_osc clock_source);
767void rcc_set_adcpre(uint32_t adcpre);
768void rcc_set_ppre2(uint32_t ppre2);
769void rcc_set_ppre1(uint32_t ppre1);
770void rcc_set_hpre(uint32_t hpre);
771void rcc_set_usbpre(uint32_t usbpre);
772void rcc_set_prediv1(uint32_t prediv);
773void rcc_set_prediv2(uint32_t prediv);
774void rcc_set_prediv1_source(uint32_t rccsrc);
776void rcc_clock_setup_in_hsi_out_64mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_configs[RCC_CLOCK_HSI_64MHZ])");
777void rcc_clock_setup_in_hsi_out_48mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_configs[RCC_CLOCK_HSI_48MHZ])");
778void rcc_clock_setup_in_hsi_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_configs[RCC_CLOCK_HSI_24MHZ])");
779void rcc_clock_setup_in_hse_8mhz_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_24MHZ])");
780void rcc_clock_setup_in_hse_8mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ])");
781void rcc_clock_setup_in_hse_12mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE12_72MHZ])");
782void rcc_clock_setup_in_hse_16mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE16_72MHZ])");
783void rcc_clock_setup_in_hse_25mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE25_72MHZ])");
784
785/**
786 * Switch sysclock to PLL with the given parameters.
787 * This should be usable from any point in time, but only if you have used
788 * library functions to manage clocks.
789 * @param clock full struct with desired parameters
790 */
791void rcc_clock_setup_pll(const struct rcc_clock_scale *clock);
792void rcc_backupdomain_reset(void);
793uint32_t rcc_get_usart_clk_freq(uint32_t usart);
794uint32_t rcc_get_timer_clk_freq(uint32_t timer);
795uint32_t rcc_get_i2c_clk_freq(uint32_t i2c);
796uint32_t rcc_get_spi_clk_freq(uint32_t spi);
798
799#endif
800/**@}*/
801
#define END_DECLS
Definition: common.h:34
#define LIBOPENCM3_DEPRECATED(x)
Definition: common.h:46
#define BEGIN_DECLS
Definition: common.h:33
int rcc_osc_ready_int_flag(enum rcc_osc osc)
RCC Read the Oscillator Ready Interrupt Flag.
Definition: rcc.c:293
void rcc_clock_setup_in_hse_8mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ])")
void rcc_clock_setup_in_hsi_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hsi_configs[RCC_CLOCK_HSI_24MHZ])")
int rcc_css_int_flag(void)
RCC Read the Clock Security System Interrupt Flag.
Definition: rcc.c:338
void rcc_set_adcpre(uint32_t adcpre)
ADC Setup the A/D Clock.
Definition: rcc.c:632
void rcc_set_rtc_clock_source(enum rcc_osc clock_source)
RCC Set the Source for the RTC clock.
Definition: rcc.c:581
void rcc_osc_ready_int_clear(enum rcc_osc osc)
RCC Clear the Oscillator Ready Interrupt Flag.
Definition: rcc.c:193
void rcc_css_disable(void)
RCC Disable the Clock Security System.
Definition: rcc.c:467
uint32_t rcc_get_spi_clk_freq(uint32_t spi)
void rcc_set_sysclk_source(uint32_t clk)
RCC Set the Source for the System Clock.
Definition: rcc.c:478
void rcc_set_prediv1_source(uint32_t rccsrc)
Definition: rcc.c:710
uint32_t rcc_apb2_frequency
Definition: rcc.c:58
void rcc_set_pll_source(uint32_t pllsrc)
RCC Set the PLL Clock Source.
Definition: rcc.c:534
void rcc_set_prediv1(uint32_t prediv)
Definition: rcc.c:698
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
Get the peripheral clock speed for the Timer at base specified.
Definition: rcc.c:1309
uint32_t rcc_system_clock_source(void)
RCC Get the System Clock Source.
Definition: rcc.c:728
rcc_clock_hse
Definition: f1/rcc.h:711
void rcc_set_prediv2(uint32_t prediv)
Definition: rcc.c:704
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
Get the peripheral clock speed for the USART at base specified.
Definition: rcc.c:1296
void rcc_clock_setup_pll(const struct rcc_clock_scale *clock)
Switch sysclock to PLL with the given parameters.
Definition: rcc.c:1213
rcc_periph_rst
Definition: f1/rcc.h:644
const struct rcc_clock_scale rcc_hsi_configs[RCC_CLOCK_HSI_END]
Definition: rcc.c:138
void rcc_set_pll3_multiplication_factor(uint32_t mul)
RCC Set the PLL3 Multiplication Factor.
Definition: rcc.c:520
rcc_periph_clken
Definition: f1/rcc.h:577
void rcc_set_pll2_multiplication_factor(uint32_t mul)
RCC Set the PLL2 Multiplication Factor.
Definition: rcc.c:506
void rcc_osc_ready_int_enable(enum rcc_osc osc)
RCC Enable the Oscillator Ready Interrupt.
Definition: rcc.c:226
rcc_osc
Definition: f1/rcc.h:567
void rcc_clock_setup_in_hse_8mhz_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hse_configs[RCC_CLOCK_HSE8_24MHZ])")
rcc_clock_hsi
Definition: f1/rcc.h:704
void rcc_osc_ready_int_disable(enum rcc_osc osc)
RCC Disable the Oscillator Ready Interrupt.
Definition: rcc.c:259
void rcc_osc_on(enum rcc_osc osc)
RCC Turn on an Oscillator.
Definition: rcc.c:384
#define _REG_BIT(base, bit)
Definition: f1/rcc.h:571
uint32_t rcc_ahb_frequency
Definition: rcc.c:59
void rcc_osc_off(enum rcc_osc osc)
RCC Turn off an Oscillator.
Definition: rcc.c:425
void rcc_clock_setup_in_hsi_out_48mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hsi_configs[RCC_CLOCK_HSI_48MHZ])")
uint32_t rcc_get_i2c_clk_freq(uint32_t i2c)
Get the peripheral clock speed for the I2C device at base specified.
Definition: rcc.c:1328
void rcc_set_pll_multiplication_factor(uint32_t mul)
RCC Set the PLL Multiplication Factor.
Definition: rcc.c:492
const struct rcc_clock_scale rcc_hse_configs[RCC_CLOCK_HSE_END]
Definition: rcc.c:61
void rcc_backupdomain_reset(void)
RCC Reset the Backup Domain.
Definition: rcc.c:1283
uint32_t rcc_apb1_frequency
Set the default clock frequencies.
Definition: rcc.c:57
void rcc_clock_setup_in_hse_25mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hse_configs[RCC_CLOCK_HSE25_72MHZ])")
void rcc_set_ppre1(uint32_t ppre1)
RCC Set the APB1 Prescale Factor.
Definition: rcc.c:658
void rcc_css_int_clear(void)
RCC Clear the Clock Security System Interrupt Flag.
Definition: rcc.c:327
void rcc_clock_setup_in_hsi_out_64mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hsi_configs[RCC_CLOCK_HSI_64MHZ])")
void rcc_clock_setup_in_hse_12mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hse_configs[RCC_CLOCK_HSE12_72MHZ])")
void rcc_enable_rtc_clock(void)
RCC Enable the RTC clock.
Definition: rcc.c:570
void rcc_set_ppre2(uint32_t ppre2)
RCC Set the APB2 Prescale Factor.
Definition: rcc.c:644
void rcc_set_usbpre(uint32_t usbpre)
RCC Set the USB Prescale Factor.
Definition: rcc.c:689
void rcc_css_enable(void)
RCC Enable the Clock Security System.
Definition: rcc.c:457
void rcc_set_hpre(uint32_t hpre)
RCC Set the AHB Prescale Factor.
Definition: rcc.c:671
void rcc_set_pllxtpre(uint32_t pllxtpre)
RCC Set the HSE Frequency Divider used as PLL Clock Source.
Definition: rcc.c:548
void rcc_clock_setup_in_hse_16mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll( &rcc_hse_configs[RCC_CLOCK_HSE16_72MHZ])")
uint32_t rcc_rtc_clock_enabled_flag(void)
RCC RTC Clock Enabled Flag.
Definition: rcc.c:560
@ RCC_CLOCK_HSE16_72MHZ
Definition: f1/rcc.h:713
@ RCC_CLOCK_HSE_END
Definition: f1/rcc.h:717
@ RCC_CLOCK_HSE8_72MHZ
Definition: f1/rcc.h:716
@ RCC_CLOCK_HSE8_24MHZ
Definition: f1/rcc.h:715
@ RCC_CLOCK_HSE25_72MHZ
Definition: f1/rcc.h:714
@ RCC_CLOCK_HSE12_72MHZ
Definition: f1/rcc.h:712
@ RST_ADC2
Definition: f1/rcc.h:660
@ RST_SPI1
Definition: f1/rcc.h:662
@ RST_CEC
Definition: f1/rcc.h:699
@ RST_GPIOG
Definition: f1/rcc.h:658
@ RST_ADC3
Definition: f1/rcc.h:665
@ RST_ADC1
Definition: f1/rcc.h:659
@ RST_TIM16
Definition: f1/rcc.h:667
@ RST_TIM14
Definition: f1/rcc.h:682
@ RST_GPIOF
Definition: f1/rcc.h:657
@ RST_SPI2
Definition: f1/rcc.h:684
@ RST_TIM9
Definition: f1/rcc.h:669
@ RST_UART4
Definition: f1/rcc.h:688
@ RST_TIM8
Definition: f1/rcc.h:663
@ RST_TIM15
Definition: f1/rcc.h:666
@ RST_TIM3
Definition: f1/rcc.h:675
@ RST_TIM17
Definition: f1/rcc.h:668
@ RST_TIM12
Definition: f1/rcc.h:680
@ RST_TIM10
Definition: f1/rcc.h:670
@ RST_GPIOA
Definition: f1/rcc.h:652
@ RST_ETHMAC
Definition: f1/rcc.h:648
@ RST_GPIOC
Definition: f1/rcc.h:654
@ RST_TIM6
Definition: f1/rcc.h:678
@ RST_GPIOB
Definition: f1/rcc.h:653
@ RST_TIM1
Definition: f1/rcc.h:661
@ RST_SPI3
Definition: f1/rcc.h:685
@ RST_USART3
Definition: f1/rcc.h:687
@ RST_DAC
Definition: f1/rcc.h:698
@ RST_AFIO
Definition: f1/rcc.h:651
@ RST_BKP
Definition: f1/rcc.h:696
@ RST_TIM13
Definition: f1/rcc.h:681
@ RST_TIM7
Definition: f1/rcc.h:679
@ RST_TIM2
Definition: f1/rcc.h:674
@ RST_CAN2
Definition: f1/rcc.h:695
@ RST_GPIOD
Definition: f1/rcc.h:655
@ RST_USB
Definition: f1/rcc.h:692
@ RST_CAN
Definition: f1/rcc.h:693
@ RST_TIM4
Definition: f1/rcc.h:676
@ RST_TIM5
Definition: f1/rcc.h:677
@ RST_UART5
Definition: f1/rcc.h:689
@ RST_GPIOE
Definition: f1/rcc.h:656
@ RST_I2C2
Definition: f1/rcc.h:691
@ RST_CAN1
Definition: f1/rcc.h:694
@ RST_PWR
Definition: f1/rcc.h:697
@ RST_USART1
Definition: f1/rcc.h:664
@ RST_WWDG
Definition: f1/rcc.h:683
@ RST_I2C1
Definition: f1/rcc.h:690
@ RST_USART2
Definition: f1/rcc.h:686
@ RST_OTGFS
Definition: f1/rcc.h:647
@ RST_TIM11
Definition: f1/rcc.h:671
@ RCC_TIM8
Definition: f1/rcc.h:605
@ RCC_UART5
Definition: f1/rcc.h:631
@ RCC_CAN
Definition: f1/rcc.h:635
@ RCC_TIM9
Definition: f1/rcc.h:611
@ RCC_FSMC
Definition: f1/rcc.h:585
@ RCC_SPI2
Definition: f1/rcc.h:626
@ RCC_WWDG
Definition: f1/rcc.h:625
@ RCC_TIM3
Definition: f1/rcc.h:617
@ RCC_SDIO
Definition: f1/rcc.h:586
@ RCC_TIM1
Definition: f1/rcc.h:603
@ RCC_CAN2
Definition: f1/rcc.h:637
@ RCC_GPIOA
Definition: f1/rcc.h:594
@ RCC_CEC
Definition: f1/rcc.h:641
@ RCC_TIM17
Definition: f1/rcc.h:610
@ RCC_TIM2
Definition: f1/rcc.h:616
@ RCC_GPIOG
Definition: f1/rcc.h:600
@ RCC_TIM10
Definition: f1/rcc.h:612
@ RCC_CAN1
Definition: f1/rcc.h:636
@ RCC_PWR
Definition: f1/rcc.h:639
@ RCC_CRC
Definition: f1/rcc.h:584
@ RCC_AFIO
Definition: f1/rcc.h:593
@ RCC_ETHMACRX
Definition: f1/rcc.h:590
@ RCC_TIM14
Definition: f1/rcc.h:624
@ RCC_USART1
Definition: f1/rcc.h:606
@ RCC_TIM4
Definition: f1/rcc.h:618
@ RCC_I2C1
Definition: f1/rcc.h:632
@ RCC_ADC2
Definition: f1/rcc.h:602
@ RCC_SRAM
Definition: f1/rcc.h:582
@ RCC_TIM13
Definition: f1/rcc.h:623
@ RCC_ADC1
Definition: f1/rcc.h:601
@ RCC_FLTF
Definition: f1/rcc.h:583
@ RCC_USB
Definition: f1/rcc.h:634
@ RCC_ETHMACTX
Definition: f1/rcc.h:589
@ RCC_USART2
Definition: f1/rcc.h:628
@ RCC_TIM16
Definition: f1/rcc.h:609
@ RCC_ADC3
Definition: f1/rcc.h:607
@ RCC_TIM12
Definition: f1/rcc.h:622
@ RCC_USART3
Definition: f1/rcc.h:629
@ RCC_TIM5
Definition: f1/rcc.h:619
@ RCC_SPI1
Definition: f1/rcc.h:604
@ RCC_ETHMAC
Definition: f1/rcc.h:588
@ RCC_I2C2
Definition: f1/rcc.h:633
@ RCC_GPIOB
Definition: f1/rcc.h:595
@ RCC_TIM7
Definition: f1/rcc.h:621
@ RCC_GPIOF
Definition: f1/rcc.h:599
@ RCC_GPIOC
Definition: f1/rcc.h:596
@ RCC_TIM6
Definition: f1/rcc.h:620
@ RCC_UART4
Definition: f1/rcc.h:630
@ RCC_DMA1
Definition: f1/rcc.h:580
@ RCC_SPI3
Definition: f1/rcc.h:627
@ RCC_DAC
Definition: f1/rcc.h:640
@ RCC_GPIOD
Definition: f1/rcc.h:597
@ RCC_TIM15
Definition: f1/rcc.h:608
@ RCC_GPIOE
Definition: f1/rcc.h:598
@ RCC_OTGFS
Definition: f1/rcc.h:587
@ RCC_BKP
Definition: f1/rcc.h:638
@ RCC_DMA2
Definition: f1/rcc.h:581
@ RCC_TIM11
Definition: f1/rcc.h:613
@ RCC_HSI
Definition: f1/rcc.h:568
@ RCC_PLL2
Definition: f1/rcc.h:568
@ RCC_LSI
Definition: f1/rcc.h:568
@ RCC_PLL
Definition: f1/rcc.h:568
@ RCC_LSE
Definition: f1/rcc.h:568
@ RCC_HSE
Definition: f1/rcc.h:568
@ RCC_PLL3
Definition: f1/rcc.h:568
@ RCC_CLOCK_HSI_48MHZ
Definition: f1/rcc.h:706
@ RCC_CLOCK_HSI_END
Definition: f1/rcc.h:708
@ RCC_CLOCK_HSI_24MHZ
Definition: f1/rcc.h:705
@ RCC_CLOCK_HSI_64MHZ
Definition: f1/rcc.h:707
uint8_t ppre1
Definition: f1/rcc.h:725
uint8_t flash_waitstates
Definition: f1/rcc.h:728
uint8_t prediv1
Definition: f1/rcc.h:729
uint8_t prediv2
Definition: f1/rcc.h:731
uint8_t ppre2
Definition: f1/rcc.h:726
uint8_t pll3_mul
Definition: f1/rcc.h:733
uint8_t adcpre
Definition: f1/rcc.h:727
uint32_t apb1_frequency
Definition: f1/rcc.h:736
uint8_t pll_mul
Definition: f1/rcc.h:722
uint32_t ahb_frequency
Definition: f1/rcc.h:735
uint8_t usbpre
Definition: f1/rcc.h:734
uint8_t prediv1_source
Definition: f1/rcc.h:730
uint8_t hpre
Definition: f1/rcc.h:724
uint32_t apb2_frequency
Definition: f1/rcc.h:737
uint8_t pll_source
Definition: f1/rcc.h:723
uint8_t pll2_mul
Definition: f1/rcc.h:732