libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
rcc.c
Go to the documentation of this file.
1/** @defgroup rcc_file RCC peripheral API
2 *
3 * @ingroup peripheral_apis
4 * This library supports the Reset and Clock Control System in the STM32 series
5 * of ARM Cortex Microcontrollers by ST Microelectronics.
6 *
7 * LGPL License Terms @ref lgpl_license
8 */
9
14
15/**@{*/
16
17uint32_t rcc_ahb_frequency = 16000000;
18uint32_t rcc_apb1_frequency = 16000000;
19uint32_t rcc_apb2_frequency = 16000000;
20
21// All PLL configurations without PLLM. PLLM should be set to the input clock
22// frequency in MHz.
24 { /* 216MHz */
25 .plln = 432,
26 .pllp = 2,
27 .pllq = 9,
28 .hpre = RCC_CFGR_HPRE_NODIV,
29 .ppre1 = RCC_CFGR_PPRE_DIV4,
30 .ppre2 = RCC_CFGR_PPRE_DIV2,
31 .vos_scale = PWR_SCALE1,
32 .overdrive = 1,
33 .flash_waitstates = 7,
34 .ahb_frequency = 216000000,
35 .apb1_frequency = 54000000,
36 .apb2_frequency = 108000000,
37 },
38 { /* 168MHz */
39 .plln = 336,
40 .pllp = 2,
41 .pllq = 7,
42 .hpre = RCC_CFGR_HPRE_NODIV,
43 .ppre1 = RCC_CFGR_PPRE_DIV4,
44 .ppre2 = RCC_CFGR_PPRE_DIV2,
45 .vos_scale = PWR_SCALE2,
46 .overdrive = 1,
47 .flash_waitstates = 5,
48 .ahb_frequency = 168000000,
49 .apb1_frequency = 42000000,
50 .apb2_frequency = 84000000,
51 },
52 { /* 120MHz */
53 .plln = 240,
54 .pllp = 2,
55 .pllq = 5,
56 .hpre = RCC_CFGR_HPRE_NODIV,
57 .ppre1 = RCC_CFGR_PPRE_DIV4,
58 .ppre2 = RCC_CFGR_PPRE_DIV2,
59 .vos_scale = PWR_SCALE3,
60 .overdrive = 0,
61 .flash_waitstates = 3,
62 .ahb_frequency = 120000000,
63 .apb1_frequency = 30000000,
64 .apb2_frequency = 60000000,
65 },
66 { /* 72MHz */
67 .plln = 144,
68 .pllp = 2,
69 .pllq = 3,
70 .hpre = RCC_CFGR_HPRE_NODIV,
71 .ppre1 = RCC_CFGR_PPRE_DIV4,
72 .ppre2 = RCC_CFGR_PPRE_DIV2,
73 .vos_scale = PWR_SCALE3,
74 .overdrive = 0,
75 .flash_waitstates = 2,
76 .ahb_frequency = 72000000,
77 .apb1_frequency = 18000000,
78 .apb2_frequency = 36000000,
79 },
80 { /* 48MHz */
81 .plln = 192,
82 .pllp = 4,
83 .pllq = 4,
84 .hpre = RCC_CFGR_HPRE_NODIV,
85 .ppre1 = RCC_CFGR_PPRE_DIV2,
86 .ppre2 = RCC_CFGR_PPRE_DIV2,
87 .vos_scale = PWR_SCALE3,
88 .overdrive = 0,
89 .flash_waitstates = 1,
90 .ahb_frequency = 48000000,
91 .apb1_frequency = 24000000,
92 .apb2_frequency = 24000000,
93 },
94 { /* 24MHz */
95 .plln = 192,
96 .pllp = 8,
97 .pllq = 4,
98 .hpre = RCC_CFGR_HPRE_NODIV,
99 .ppre1 = RCC_CFGR_PPRE_NODIV,
100 .ppre2 = RCC_CFGR_PPRE_NODIV,
101 .vos_scale = PWR_SCALE3,
102 .overdrive = 0,
103 .flash_waitstates = 0,
104 .ahb_frequency = 24000000,
105 .apb1_frequency = 24000000,
106 .apb2_frequency = 24000000,
107 }
108};
109
111{
112 switch (osc) {
113 case RCC_PLL:
115 break;
116 case RCC_HSE:
118 break;
119 case RCC_HSI:
121 break;
122 case RCC_LSE:
124 break;
125 case RCC_LSI:
127 break;
128 }
129}
130
132{
133 switch (osc) {
134 case RCC_PLL:
136 break;
137 case RCC_HSE:
139 break;
140 case RCC_HSI:
142 break;
143 case RCC_LSE:
145 break;
146 case RCC_LSI:
148 break;
149 }
150}
151
153{
154 switch (osc) {
155 case RCC_PLL:
156 RCC_CIR &= ~RCC_CIR_PLLRDYIE;
157 break;
158 case RCC_HSE:
159 RCC_CIR &= ~RCC_CIR_HSERDYIE;
160 break;
161 case RCC_HSI:
162 RCC_CIR &= ~RCC_CIR_HSIRDYIE;
163 break;
164 case RCC_LSE:
165 RCC_CIR &= ~RCC_CIR_LSERDYIE;
166 break;
167 case RCC_LSI:
168 RCC_CIR &= ~RCC_CIR_LSIRDYIE;
169 break;
170 }
171}
172
174{
175 switch (osc) {
176 case RCC_PLL:
177 return ((RCC_CIR & RCC_CIR_PLLRDYF) != 0);
178 break;
179 case RCC_HSE:
180 return ((RCC_CIR & RCC_CIR_HSERDYF) != 0);
181 break;
182 case RCC_HSI:
183 return ((RCC_CIR & RCC_CIR_HSIRDYF) != 0);
184 break;
185 case RCC_LSE:
186 return ((RCC_CIR & RCC_CIR_LSERDYF) != 0);
187 break;
188 case RCC_LSI:
189 return ((RCC_CIR & RCC_CIR_LSIRDYF) != 0);
190 break;
191 }
192
194}
195
197{
199}
200
202{
203 return ((RCC_CIR & RCC_CIR_CSSF) != 0);
204}
205
207{
208 switch (osc) {
209 case RCC_PLL:
210 while ((RCC_CR & RCC_CR_PLLRDY) == 0);
211 break;
212 case RCC_HSE:
213 while ((RCC_CR & RCC_CR_HSERDY) == 0);
214 break;
215 case RCC_HSI:
216 while ((RCC_CR & RCC_CR_HSIRDY) == 0);
217 break;
218 case RCC_LSE:
219 while ((RCC_BDCR & RCC_BDCR_LSERDY) == 0);
220 break;
221 case RCC_LSI:
222 while ((RCC_CSR & RCC_CSR_LSIRDY) == 0);
223 break;
224 }
225}
226
228{
229 switch (osc) {
230 case RCC_PLL:
231 while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_PLL);
232 break;
233 case RCC_HSE:
234 while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_HSE);
235 break;
236 case RCC_HSI:
237 while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_HSI);
238 break;
239 default:
240 /* Shouldn't be reached. */
241 break;
242 }
243}
244
245void rcc_osc_on(enum rcc_osc osc)
246{
247 switch (osc) {
248 case RCC_PLL:
250 break;
251 case RCC_HSE:
253 break;
254 case RCC_HSI:
256 break;
257 case RCC_LSE:
259 break;
260 case RCC_LSI:
262 break;
263 }
264}
265
266void rcc_osc_off(enum rcc_osc osc)
267{
268 switch (osc) {
269 case RCC_PLL:
270 RCC_CR &= ~RCC_CR_PLLON;
271 break;
272 case RCC_HSE:
273 RCC_CR &= ~RCC_CR_HSEON;
274 break;
275 case RCC_HSI:
276 RCC_CR &= ~RCC_CR_HSION;
277 break;
278 case RCC_LSE:
279 RCC_BDCR &= ~RCC_BDCR_LSEON;
280 break;
281 case RCC_LSI:
282 RCC_CSR &= ~RCC_CSR_LSION;
283 break;
284 }
285}
286
288{
290}
291
293{
294 RCC_CR &= ~RCC_CR_CSSON;
295}
296
297void rcc_set_sysclk_source(uint32_t clk)
298{
299 uint32_t reg32;
300
301 reg32 = RCC_CFGR;
302 reg32 &= ~(RCC_CFGR_SW_MASK << RCC_CFGR_SW_SHIFT);
303 RCC_CFGR = (reg32 | (clk << RCC_CFGR_SW_SHIFT));
304}
305
306void rcc_set_pll_source(uint32_t pllsrc)
307{
308 uint32_t reg32;
309
310 reg32 = RCC_PLLCFGR;
311 reg32 &= ~(1 << 22);
312 RCC_PLLCFGR = (reg32 | (pllsrc << 22));
313}
314
315void rcc_set_ppre2(uint32_t ppre2)
316{
317 uint32_t reg32;
318
319 reg32 = RCC_CFGR;
321 RCC_CFGR = (reg32 | (ppre2 << RCC_CFGR_PPRE2_SHIFT));
322}
323
324void rcc_set_ppre1(uint32_t ppre1)
325{
326 uint32_t reg32;
327
328 reg32 = RCC_CFGR;
330 RCC_CFGR = (reg32 | (ppre1 << RCC_CFGR_PPRE1_SHIFT));
331}
332
333void rcc_set_hpre(uint32_t hpre)
334{
335 uint32_t reg32;
336
337 reg32 = RCC_CFGR;
339 RCC_CFGR = (reg32 | (hpre << RCC_CFGR_HPRE_SHIFT));
340}
341
342void rcc_set_rtcpre(uint32_t rtcpre)
343{
344 uint32_t reg32;
345
346 reg32 = RCC_CFGR;
348 RCC_CFGR = (reg32 | (rtcpre << RCC_CFGR_RTCPRE_SHIFT));
349}
350
351void rcc_set_main_pll_hsi(uint32_t pllm, uint32_t plln, uint32_t pllp,
352 uint32_t pllq)
353{
356 (((pllp >> 1) - 1) << RCC_PLLCFGR_PLLP_SHIFT) |
358}
359
360void rcc_set_main_pll_hse(uint32_t pllm, uint32_t plln, uint32_t pllp,
361 uint32_t pllq)
362{
365 (((pllp >> 1) - 1) << RCC_PLLCFGR_PLLP_SHIFT) |
368}
369
371{
372 /* Return the clock source which is used as system clock. */
374}
375
376void rcc_clock_setup_hse(const struct rcc_clock_scale *clock, uint32_t hse_mhz)
377{
378 uint8_t pllm = hse_mhz;
379
380 /* Enable internal high-speed oscillator. */
383
384 /* Select HSI as SYSCLK source. */
386
387 /* Enable external high-speed oscillator. */
390
393
394 if (clock->overdrive) {
396 }
397
398 /*
399 * Set prescalers for AHB, ADC, APB1, APB2.
400 * Do this before touching the PLL (TODO: why?).
401 */
402 rcc_set_hpre(clock->hpre);
403 rcc_set_ppre1(clock->ppre1);
404 rcc_set_ppre2(clock->ppre2);
405
406 /* Disable PLL oscillator before changing its configuration. */
408
409 /* Configure the PLL oscillator. */
410 rcc_set_main_pll_hse(pllm, clock->plln,
411 clock->pllp, clock->pllq);
412
413 /* Enable PLL oscillator and wait for it to stabilize. */
416
417 /* Configure flash settings. */
421
422 /* Select PLL as SYSCLK source. */
424
425 /* Wait for PLL clock to be selected. */
427
428 /* Set the clock frequencies used. */
432
433 /* Disable internal high-speed oscillator. */
435}
436
437void rcc_clock_setup_hsi(const struct rcc_clock_scale *clock)
438{
439 uint8_t pllm = 16;
440
441 /* Enable internal high-speed oscillator. */
444
445 /* Select HSI as SYSCLK source. */
447
450
451 if (clock->overdrive) {
453 }
454
455 /*
456 * Set prescalers for AHB, ADC, APB1, APB2.
457 * Do this before touching the PLL (TODO: why?).
458 */
459 rcc_set_hpre(clock->hpre);
460 rcc_set_ppre1(clock->ppre1);
461 rcc_set_ppre2(clock->ppre2);
462
463 rcc_set_main_pll_hsi(pllm, clock->plln,
464 clock->pllp, clock->pllq);
465
466 /* Enable PLL oscillator and wait for it to stabilize. */
469
470 /* Configure flash settings. */
474
475 /* Select PLL as SYSCLK source. */
477
478 /* Wait for PLL clock to be selected. */
480
481 /* Set the clock frequencies used. */
485}
486
487static uint32_t rcc_usart_i2c_clksel_freq(uint32_t apb_clk, uint8_t shift) {
488 uint8_t clksel = (RCC_DCKCFGR2 >> shift) & RCC_DCKCFGR2_UARTxSEL_MASK;
490 switch (clksel) {
492 return apb_clk;
495 /* This case is only valid for uarts, not for i2c! */
497 return 32768;
499 return 16000000U;
500 }
502}
503
504/*---------------------------------------------------------------------------*/
505/** @brief Get the peripheral clock speed for the USART at base specified.
506 * @param usart Base address of USART to get clock frequency for.
507 */
508uint32_t rcc_get_usart_clk_freq(uint32_t usart)
509{
510 /* F7 is highly configurable, every USART can be configured in DCKCFGR2. */
511 if (usart == USART1_BASE) {
513 } else if (usart == USART2_BASE) {
515 } else if (usart == USART3_BASE) {
517 } else if (usart == UART4_BASE) {
519 } else if (usart == UART5_BASE) {
521 } else if (usart == USART6_BASE) {
523 } else if (usart == UART7_BASE) {
525 } else { /* UART8 */
527 }
528}
529
530/*---------------------------------------------------------------------------*/
531/** @brief Get the peripheral clock speed for the Timer at base specified.
532 * @param timer Base address of TIM to get clock frequency for.
533 */
534uint32_t rcc_get_timer_clk_freq(uint32_t timer)
535{
536 /* Handle APB1 timer clocks. */
537 if (timer >= TIM2_BASE && timer <= TIM14_BASE) {
540 : 2 * rcc_apb1_frequency;
541 } else {
544 : 2 * rcc_apb2_frequency;
545 }
546}
547
548/*---------------------------------------------------------------------------*/
549/** @brief Get the peripheral clock speed for the I2C device at base specified.
550 * @param i2c Base address of I2C to get clock frequency for.
551 */
552uint32_t rcc_get_i2c_clk_freq(uint32_t i2c __attribute__((unused)))
553{
554 if (i2c == I2C1_BASE) {
556 } else if (i2c == I2C2_BASE) {
558 } else if (i2c == I2C3_BASE) {
560 } else { /* I2C4 */
562 }
563}
564
565/*---------------------------------------------------------------------------*/
566/** @brief Get the peripheral clock speed for the SPI device at base specified.
567 * @param spi Base address of SPI device to get clock frequency for (e.g. SPI1_BASE).
568 */
569uint32_t rcc_get_spi_clk_freq(uint32_t spi) {
570 if (spi == SPI2_BASE || spi == SPI3_BASE) {
571 return rcc_apb1_frequency;
572 } else {
573 return rcc_apb2_frequency;
574 }
575}
576/**@}*/
#define cm3_assert_not_reached()
Check if unreachable code is reached.
Definition: assert.h:102
void flash_art_enable(void)
Enable the ART Cache.
Definition: flash.c:90
void flash_prefetch_enable(void)
This buffer is used for instruction fetches and may or may not be enabled by default,...
void flash_set_ws(uint32_t ws)
Set the Number of Wait States.
void pwr_enable_overdrive(void)
Definition: pwr.c:56
void pwr_set_vos_scale(enum pwr_vos_scale scale)
Definition: pwr.c:43
@ PWR_SCALE1
Definition: f7/pwr.h:282
@ PWR_SCALE2
<= 180MHz w/o overdrive, <= 216MHz w/ overdrive
Definition: f7/pwr.h:283
@ PWR_SCALE3
<= 168MHz w/o overdrive, <= 180MHz w/ overdrive
Definition: f7/pwr.h:284
#define RCC_CFGR_HPRE_NODIV
Definition: f7/rcc.h:159
#define RCC_CFGR_PPRE_DIV2
Definition: f7/rcc.h:149
#define RCC_CFGR_PPRE_NODIV
Definition: f7/rcc.h:148
#define RCC_CFGR_PPRE_DIV4
Definition: f7/rcc.h:150
#define RCC_CFGR_PPRE_DIV_NONE
Definition: f7/rcc.h:189
#define RCC_DCKCFGR2_UART4SEL_SHIFT
Definition: f7/rcc.h:640
#define RCC_DCKCFGR2_UART7SEL_SHIFT
Definition: f7/rcc.h:637
#define RCC_DCKCFGR2_UART1SEL_SHIFT
Definition: f7/rcc.h:643
#define RCC_DCKCFGR2_UART3SEL_SHIFT
Definition: f7/rcc.h:641
#define RCC_DCKCFGR2_UART5SEL_SHIFT
Definition: f7/rcc.h:639
#define RCC_DCKCFGR2_USART6SEL_SHIFT
Definition: f7/rcc.h:638
#define RCC_DCKCFGR2_UART2SEL_SHIFT
Definition: f7/rcc.h:642
#define RCC_DCKCFGR2_UART8SEL_SHIFT
Definition: f7/rcc.h:636
#define RCC_DCKCFGR2_UARTxSEL_PCLK
Definition: f7/rcc.h:649
#define RCC_DCKCFGR2_UARTxSEL_SYSCLK
Definition: f7/rcc.h:650
#define RCC_DCKCFGR2_UARTxSEL_LSE
Definition: f7/rcc.h:652
#define RCC_DCKCFGR2_UARTxSEL_HSI
Definition: f7/rcc.h:651
#define RCC_BDCR_LSEON
Definition: f7/rcc.h:550
#define RCC_PLLCFGR_PLLN_SHIFT
Definition: f7/rcc.h:99
#define RCC_CIR_PLLRDYF
Definition: f7/rcc.h:235
#define RCC_CIR
Definition: f7/rcc.h:48
#define RCC_CIR_HSERDYF
Definition: f7/rcc.h:236
#define RCC_CFGR_PPRE1_MASK
Definition: f7/rcc.h:143
#define RCC_CIR_LSERDYC
Definition: f7/rcc.h:217
#define RCC_CFGR_PPRE2_SHIFT
Definition: f7/rcc.h:140
#define RCC_CIR_PLLRDYIE
Definition: f7/rcc.h:223
#define RCC_DCKCFGR2
Definition: f7/rcc.h:70
#define RCC_CIR_PLLRDYC
Definition: f7/rcc.h:214
#define RCC_CFGR_SWS_PLL
Definition: f7/rcc.h:175
#define RCC_CR
Definition: f7/rcc.h:45
#define RCC_CFGR_PPRE2_MASK
Definition: f7/rcc.h:141
#define RCC_CFGR_HPRE_MASK
Definition: f7/rcc.h:156
#define RCC_CFGR_SWS_MASK
Definition: f7/rcc.h:172
#define RCC_CIR_CSSC
Definition: f7/rcc.h:209
#define RCC_DCKCFGR2_UARTxSEL_MASK
Definition: f7/rcc.h:631
#define RCC_CIR_HSERDYIE
Definition: f7/rcc.h:224
#define RCC_DCKCFGR2_I2C3SEL_SHIFT
Definition: f7/rcc.h:627
#define RCC_DCKCFGR2_I2C1SEL_SHIFT
Definition: f7/rcc.h:629
#define RCC_DCKCFGR2_I2C2SEL_SHIFT
Definition: f7/rcc.h:628
#define RCC_CFGR_SWS_HSI
Definition: f7/rcc.h:173
rcc_osc
Definition: f7/rcc.h:689
#define RCC_CIR_LSERDYIE
Definition: f7/rcc.h:226
#define RCC_CSR
Definition: f7/rcc.h:65
#define RCC_CFGR_SW_MASK
Definition: f7/rcc.h:179
#define RCC_CSR_LSION
Definition: f7/rcc.h:566
#define RCC_PLLCFGR
Definition: f7/rcc.h:46
#define RCC_CR_HSERDY
Definition: f7/rcc.h:82
#define RCC_CIR_LSIRDYIE
Definition: f7/rcc.h:227
#define RCC_CFGR_SW_PLL
Definition: f7/rcc.h:182
#define RCC_CFGR
Definition: f7/rcc.h:47
void rcc_periph_clock_enable(enum rcc_periph_clken clken)
Enable Peripheral Clock in running mode.
#define RCC_PLLCFGR_PLLSRC
Definition: f7/rcc.h:95
#define RCC_CIR_HSERDYC
Definition: f7/rcc.h:215
#define RCC_CIR_LSIRDYC
Definition: f7/rcc.h:218
#define RCC_CR_HSIRDY
Definition: f7/rcc.h:88
#define RCC_CFGR_SWS_SHIFT
Definition: f7/rcc.h:171
#define RCC_BDCR_LSERDY
Definition: f7/rcc.h:549
#define RCC_CSR_LSIRDY
Definition: f7/rcc.h:565
#define RCC_CFGR_RTCPRE_SHIFT
Definition: f7/rcc.h:137
#define RCC_BDCR
Definition: f7/rcc.h:64
#define RCC_CFGR_HPRE_SHIFT
Definition: f7/rcc.h:155
#define RCC_CIR_LSERDYF
Definition: f7/rcc.h:238
#define RCC_CFGR_SW_SHIFT
Definition: f7/rcc.h:178
#define RCC_PLLCFGR_PLLQ_SHIFT
Definition: f7/rcc.h:94
#define RCC_CIR_HSIRDYIE
Definition: f7/rcc.h:225
#define RCC_CIR_LSIRDYF
Definition: f7/rcc.h:239
#define RCC_CFGR_SW_HSI
Definition: f7/rcc.h:180
#define RCC_CR_CSSON
Definition: f7/rcc.h:80
#define RCC_CR_PLLON
Definition: f7/rcc.h:79
#define RCC_CIR_HSIRDYC
Definition: f7/rcc.h:216
#define RCC_CIR_HSIRDYF
Definition: f7/rcc.h:237
#define RCC_CIR_CSSF
Definition: f7/rcc.h:230
#define RCC_PLLCFGR_PLLM_SHIFT
Definition: f7/rcc.h:101
#define RCC_CR_HSEON
Definition: f7/rcc.h:83
#define RCC_CFGR_SWS_HSE
Definition: f7/rcc.h:174
#define RCC_DCKCFGR2_I2C4SEL_SHIFT
Definition: f7/rcc.h:626
#define RCC_PLLCFGR_PLLP_SHIFT
Definition: f7/rcc.h:97
#define RCC_CR_HSION
Definition: f7/rcc.h:89
#define RCC_CR_PLLRDY
Definition: f7/rcc.h:78
#define RCC_CFGR_PPRE1_SHIFT
Definition: f7/rcc.h:142
uint16_t rcc_get_div_from_hpre(uint8_t div_val)
This will return the divisor 1/2/4/8/16/64/128/256/512 which is set as a 4-bit value,...
#define RCC_CFGR_RTCPRE_MASK
Definition: f7/rcc.h:138
@ RCC_PWR
Definition: f7/rcc.h:762
@ RCC_HSI
Definition: f7/rcc.h:692
@ RCC_LSI
Definition: f7/rcc.h:694
@ RCC_PLL
Definition: f7/rcc.h:690
@ RCC_LSE
Definition: f7/rcc.h:693
@ RCC_HSE
Definition: f7/rcc.h:691
@ RCC_CLOCK_3V3_END
Definition: f7/rcc.h:668
int rcc_osc_ready_int_flag(enum rcc_osc osc)
Definition: rcc.c:173
int rcc_css_int_flag(void)
Definition: rcc.c:201
void rcc_osc_ready_int_clear(enum rcc_osc osc)
Definition: rcc.c:110
void rcc_wait_for_osc_ready(enum rcc_osc osc)
Wait for Oscillator Ready.
Definition: rcc.c:206
void rcc_css_disable(void)
Definition: rcc.c:292
uint32_t rcc_get_spi_clk_freq(uint32_t spi)
Get the peripheral clock speed for the SPI device at base specified.
Definition: rcc.c:569
void rcc_set_sysclk_source(uint32_t clk)
Definition: rcc.c:297
uint32_t rcc_apb2_frequency
Definition: rcc.c:19
void rcc_set_pll_source(uint32_t pllsrc)
Definition: rcc.c:306
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
Get the peripheral clock speed for the Timer at base specified.
Definition: rcc.c:534
uint32_t rcc_system_clock_source(void)
Definition: rcc.c:370
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
Get the peripheral clock speed for the USART at base specified.
Definition: rcc.c:508
void rcc_set_rtcpre(uint32_t rtcpre)
Definition: rcc.c:342
void rcc_osc_ready_int_enable(enum rcc_osc osc)
Definition: rcc.c:131
void rcc_clock_setup_hse(const struct rcc_clock_scale *clock, uint32_t hse_mhz)
Definition: rcc.c:376
static uint32_t rcc_usart_i2c_clksel_freq(uint32_t apb_clk, uint8_t shift)
Definition: rcc.c:487
const struct rcc_clock_scale rcc_3v3[RCC_CLOCK_3V3_END]
Definition: rcc.c:23
void rcc_osc_ready_int_disable(enum rcc_osc osc)
Definition: rcc.c:152
void rcc_osc_on(enum rcc_osc osc)
Definition: rcc.c:245
uint32_t rcc_ahb_frequency
Definition: rcc.c:17
void rcc_osc_off(enum rcc_osc osc)
Definition: rcc.c:266
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:552
uint32_t rcc_apb1_frequency
Definition: rcc.c:18
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
Definition: rcc.c:227
void rcc_set_ppre1(uint32_t ppre1)
Definition: rcc.c:324
void rcc_css_int_clear(void)
Definition: rcc.c:196
void rcc_set_ppre2(uint32_t ppre2)
Definition: rcc.c:315
void rcc_set_main_pll_hse(uint32_t pllm, uint32_t plln, uint32_t pllp, uint32_t pllq)
Definition: rcc.c:360
void rcc_set_main_pll_hsi(uint32_t pllm, uint32_t plln, uint32_t pllp, uint32_t pllq)
Definition: rcc.c:351
void rcc_css_enable(void)
Definition: rcc.c:287
void rcc_set_hpre(uint32_t hpre)
Definition: rcc.c:333
void rcc_clock_setup_hsi(const struct rcc_clock_scale *clock)
Definition: rcc.c:437
#define TIM2_BASE
#define I2C2_BASE
#define UART7_BASE
#define I2C3_BASE
#define USART1_BASE
#define TIM14_BASE
#define UART4_BASE
#define UART5_BASE
#define USART3_BASE
#define SPI2_BASE
#define I2C1_BASE
#define USART6_BASE
#define USART2_BASE
#define SPI3_BASE
uint8_t ppre1
Definition: f7/rcc.h:678
uint8_t pllq
Definition: f7/rcc.h:675
uint8_t ppre2
Definition: f7/rcc.h:679
uint8_t pllp
Definition: f7/rcc.h:674
uint32_t apb1_frequency
Definition: f7/rcc.h:683
uint32_t ahb_frequency
Definition: f7/rcc.h:682
enum pwr_vos_scale vos_scale
Definition: f7/rcc.h:680
uint16_t plln
Definition: f7/rcc.h:673
uint8_t hpre
Definition: f7/rcc.h:677
uint32_t apb2_frequency
Definition: f7/rcc.h:684
uint8_t overdrive
Definition: f7/rcc.h:681
uint32_t flash_waitstates
Definition: f7/rcc.h:676