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
5@brief <b>libopencm3 STM32L1xx Reset and Clock Control</b>
6
7@version 1.0.0
8
9This library supports the Reset and Clock Control System in the STM32L1xx
10series of ARM Cortex Microcontrollers by ST Microelectronics.
11
12Clock settings and resets for many peripherals are given here rather than in
13the corresponding peripheral library.
14
15The library also provides a number of common configurations for the processor
16system clock. Not all possible configurations are included.
17 */
18/*
19 * This file is part of the libopencm3 project.
20 *
21 * Copyright (C) 2009 Federico Ruiz-Ugalde <memeruiz at gmail dot com>
22 * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
23 * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
24 * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
25 *
26 * This library is free software: you can redistribute it and/or modify
27 * it under the terms of the GNU Lesser General Public License as published by
28 * the Free Software Foundation, either version 3 of the License, or
29 * (at your option) any later version.
30 *
31 * This library is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU Lesser General Public License for more details.
35 *
36 * You should have received a copy of the GNU Lesser General Public License
37 * along with this library. If not, see <http://www.gnu.org/licenses/>.
38 * Based on the F4 code...
39 */
40/**@{*/
41
46
47/* Set the default clock frequencies after reset. */
48uint32_t rcc_ahb_frequency = 2097000;
49uint32_t rcc_apb1_frequency = 2097000;
50uint32_t rcc_apb2_frequency = 2097000;
51
53 { /* 24MHz PLL from HSI */
55 .pll_mul = RCC_CFGR_PLLMUL_MUL3,
56 .pll_div = RCC_CFGR_PLLDIV_DIV2,
57 .hpre = RCC_CFGR_HPRE_NODIV,
58 .ppre1 = RCC_CFGR_PPRE_NODIV,
59 .ppre2 = RCC_CFGR_PPRE_NODIV,
60 .voltage_scale = PWR_SCALE1,
61 .flash_waitstates = 1,
62 .ahb_frequency = 24000000,
63 .apb1_frequency = 24000000,
64 .apb2_frequency = 24000000,
65 },
66 { /* 32MHz PLL from HSI */
67 .pll_source = RCC_CFGR_PLLSRC_HSI_CLK,
68 .pll_mul = RCC_CFGR_PLLMUL_MUL6,
69 .pll_div = RCC_CFGR_PLLDIV_DIV3,
70 .hpre = RCC_CFGR_HPRE_NODIV,
71 .ppre1 = RCC_CFGR_PPRE_NODIV,
72 .ppre2 = RCC_CFGR_PPRE_NODIV,
73 .voltage_scale = PWR_SCALE1,
74 .flash_waitstates = 1,
75 .ahb_frequency = 32000000,
76 .apb1_frequency = 32000000,
77 .apb2_frequency = 32000000,
78 },
79 { /* 16MHz HSI raw */
80 .hpre = RCC_CFGR_HPRE_NODIV,
81 .ppre1 = RCC_CFGR_PPRE_NODIV,
82 .ppre2 = RCC_CFGR_PPRE_NODIV,
83 .voltage_scale = PWR_SCALE1,
84 .flash_waitstates = 0,
85 .ahb_frequency = 16000000,
86 .apb1_frequency = 16000000,
87 .apb2_frequency = 16000000,
88 },
89 { /* 4MHz HSI raw */
90 .hpre = RCC_CFGR_HPRE_DIV4,
91 .ppre1 = RCC_CFGR_PPRE_NODIV,
92 .ppre2 = RCC_CFGR_PPRE_NODIV,
93 .voltage_scale = PWR_SCALE1,
94 .flash_waitstates = 0,
95 .ahb_frequency = 4000000,
96 .apb1_frequency = 4000000,
97 .apb2_frequency = 4000000,
98 },
99 { /* 4MHz MSI raw */
100 .hpre = RCC_CFGR_HPRE_NODIV,
101 .ppre1 = RCC_CFGR_PPRE_NODIV,
102 .ppre2 = RCC_CFGR_PPRE_NODIV,
103 .voltage_scale = PWR_SCALE1,
104 .flash_waitstates = 0,
105 .ahb_frequency = 4194000,
106 .apb1_frequency = 4194000,
107 .apb2_frequency = 4194000,
108 .msi_range = RCC_ICSCR_MSIRANGE_4MHZ,
109 },
110 { /* 2MHz MSI raw */
111 .hpre = RCC_CFGR_HPRE_NODIV,
112 .ppre1 = RCC_CFGR_PPRE_NODIV,
113 .ppre2 = RCC_CFGR_PPRE_NODIV,
114 .voltage_scale = PWR_SCALE1,
115 .flash_waitstates = 0,
116 .ahb_frequency = 2097000,
117 .apb1_frequency = 2097000,
118 .apb2_frequency = 2097000,
119 .msi_range = RCC_ICSCR_MSIRANGE_2MHZ,
120 },
121};
122
124{
125 switch (osc) {
126 case RCC_PLL:
128 break;
129 case RCC_HSE:
131 break;
132 case RCC_HSI:
134 break;
135 case RCC_LSE:
137 break;
138 case RCC_LSI:
140 break;
141 case RCC_MSI:
143 break;
144 }
145}
146
148{
149 switch (osc) {
150 case RCC_PLL:
152 break;
153 case RCC_HSE:
155 break;
156 case RCC_HSI:
158 break;
159 case RCC_LSE:
161 break;
162 case RCC_LSI:
164 break;
165 case RCC_MSI:
167 break;
168 }
169}
170
172{
173 switch (osc) {
174 case RCC_PLL:
175 RCC_CIR &= ~RCC_CIR_PLLRDYIE;
176 break;
177 case RCC_HSE:
178 RCC_CIR &= ~RCC_CIR_HSERDYIE;
179 break;
180 case RCC_HSI:
181 RCC_CIR &= ~RCC_CIR_HSIRDYIE;
182 break;
183 case RCC_LSE:
184 RCC_CIR &= ~RCC_CIR_LSERDYIE;
185 break;
186 case RCC_LSI:
187 RCC_CIR &= ~RCC_CIR_LSIRDYIE;
188 break;
189 case RCC_MSI:
190 RCC_CIR &= ~RCC_CIR_MSIRDYIE;
191 break;
192 }
193}
194
196{
197 switch (osc) {
198 case RCC_PLL:
199 return ((RCC_CIR & RCC_CIR_PLLRDYF) != 0);
200 break;
201 case RCC_HSE:
202 return ((RCC_CIR & RCC_CIR_HSERDYF) != 0);
203 break;
204 case RCC_HSI:
205 return ((RCC_CIR & RCC_CIR_HSIRDYF) != 0);
206 break;
207 case RCC_LSE:
208 return ((RCC_CIR & RCC_CIR_LSERDYF) != 0);
209 break;
210 case RCC_LSI:
211 return ((RCC_CIR & RCC_CIR_LSIRDYF) != 0);
212 break;
213 case RCC_MSI:
214 return ((RCC_CIR & RCC_CIR_MSIRDYF) != 0);
215 break;
216 }
217
218 /* Shouldn't be reached. */
219 return -1;
220}
221
223{
225}
226
228{
229 return ((RCC_CIR & RCC_CIR_CSSF) != 0);
230}
231
233{
234 switch (osc) {
235 case RCC_PLL:
236 return RCC_CR & RCC_CR_PLLRDY;
237 case RCC_HSE:
238 return RCC_CR & RCC_CR_HSERDY;
239 case RCC_HSI:
240 return RCC_CR & RCC_CR_HSIRDY;
241 case RCC_MSI:
242 return RCC_CR & RCC_CR_MSIRDY;
243 case RCC_LSE:
244 return RCC_CSR & RCC_CSR_LSERDY;
245 case RCC_LSI:
246 return RCC_CSR & RCC_CSR_LSIRDY;
247 }
248 return false;
249}
250
252{
253 while (!rcc_is_osc_ready(osc));
254}
255
257{
258 switch (osc) {
259 case RCC_PLL:
262 break;
263 case RCC_HSE:
266 break;
267 case RCC_HSI:
270 break;
271 case RCC_MSI:
274 break;
275 default:
276 /* Shouldn't be reached. */
277 break;
278 }
279}
280
281void rcc_osc_on(enum rcc_osc osc)
282{
283 switch (osc) {
284 case RCC_PLL:
286 break;
287 case RCC_MSI:
289 break;
290 case RCC_HSE:
292 break;
293 case RCC_HSI:
295 break;
296 case RCC_LSE:
298 break;
299 case RCC_LSI:
301 break;
302 }
303}
304
305void rcc_osc_off(enum rcc_osc osc)
306{
307 switch (osc) {
308 case RCC_PLL:
309 RCC_CR &= ~RCC_CR_PLLON;
310 break;
311 case RCC_MSI:
312 RCC_CR &= ~RCC_CR_MSION;
313 break;
314 case RCC_HSE:
315 RCC_CR &= ~RCC_CR_HSEON;
316 break;
317 case RCC_HSI:
318 RCC_CR &= ~RCC_CR_HSION;
319 break;
320 case RCC_LSE:
321 RCC_CSR &= ~RCC_CSR_LSEON;
322 break;
323 case RCC_LSI:
324 RCC_CSR &= ~RCC_CSR_LSION;
325 break;
326 }
327}
328
330{
332}
333
335{
336 RCC_CR &= ~RCC_CR_CSSON;
337}
338
339/**
340 * Set the range of the MSI oscillator
341 * @param range desired range @ref rcc_icscr_msirange
342 */
343void rcc_set_msi_range(uint32_t range)
344{
345 uint32_t reg = RCC_ICSCR;
347 reg |= (range << RCC_ICSCR_MSIRANGE_SHIFT);
348 RCC_ICSCR = reg;
349}
350
351void rcc_set_sysclk_source(uint32_t clk)
352{
353 uint32_t reg32;
354
355 reg32 = RCC_CFGR;
356 reg32 &= ~(RCC_CFGR_SW_MASK << RCC_CFGR_SW_SHIFT);
357 RCC_CFGR = (reg32 | clk << RCC_CFGR_SW_SHIFT);
358}
359
360void rcc_set_pll_configuration(uint32_t source, uint32_t multiplier,
361 uint32_t divisor)
362{
363 uint32_t reg32;
364
365 reg32 = RCC_CFGR;
368 reg32 &= ~(1 << 16);
369 reg32 |= (source << 16);
370 reg32 |= (multiplier << RCC_CFGR_PLLMUL_SHIFT);
371 reg32 |= (divisor << RCC_CFGR_PLLDIV_SHIFT);
372 RCC_CFGR = reg32;
373}
374
375void rcc_set_pll_source(uint32_t pllsrc)
376{
377 uint32_t reg32;
378
379 reg32 = RCC_CFGR;
380 reg32 &= ~(1 << 16);
381 RCC_CFGR = (reg32 | (pllsrc << 16));
382}
383
384void rcc_set_ppre2(uint32_t ppre2)
385{
386 uint32_t reg32;
387
388 reg32 = RCC_CFGR;
390 RCC_CFGR = (reg32 | (ppre2 << RCC_CFGR_PPRE2_SHIFT));
391}
392
393void rcc_set_ppre1(uint32_t ppre1)
394{
395 uint32_t reg32;
396
397 reg32 = RCC_CFGR;
399 RCC_CFGR = (reg32 | (ppre1 << RCC_CFGR_PPRE1_SHIFT));
400}
401
402void rcc_set_hpre(uint32_t hpre)
403{
404 uint32_t reg32;
405
406 reg32 = RCC_CFGR;
408 RCC_CFGR = (reg32 | (hpre << RCC_CFGR_HPRE_SHIFT));
409}
410
411void rcc_set_rtcpre(uint32_t rtcpre)
412{
413 uint32_t reg32;
414
415 reg32 = RCC_CR;
417 RCC_CR = (reg32 | (rtcpre << RCC_CR_RTCPRE_SHIFT));
418}
419
421{
422 /* Return the clock source which is used as system clock. */
423 return (RCC_CFGR & 0x000c) >> 2;
424}
425
426void rcc_rtc_select_clock(uint32_t clock)
427{
429 RCC_CSR |= (clock << RCC_CSR_RTCSEL_SHIFT);
430}
431
432void rcc_clock_setup_msi(const struct rcc_clock_scale *clock)
433{
434 /* Enable internal multi-speed oscillator. */
438
439 /* Select MSI as SYSCLK source. */
441
442 /*
443 * Set prescalers for AHB, ADC, APB1, APB2.
444 * Do this before touching the PLL (TODO: why?).
445 */
446 rcc_set_hpre(clock->hpre);
447 rcc_set_ppre1(clock->ppre1);
448 rcc_set_ppre2(clock->ppre2);
449
452
453 /* I guess this should be in the settings? */
457
458 /* Set the peripheral clock frequencies used. */
462}
463
464
465/**
466 * Switch sysclock to HSI with the given parameters.
467 * This should be usable from any point in time, but only if you have used
468 * library functions to manage clocks. It relies on the global
469 * @ref rcc_ahb_frequency to ensure that it reliably scales voltage up or down
470 * as appropriate.
471 * @param clock full struct with desired parameters
472 */
473void rcc_clock_setup_hsi(const struct rcc_clock_scale *clock)
474{
475 /* Enable internal high-speed oscillator. */
478
479 /* I guess this should be in the settings? */
482
483 /* Don't try and go to fast for a voltage range! */
484 if (clock->ahb_frequency > rcc_ahb_frequency) {
485 /* Going up, power up first */
487 rcc_set_hpre(clock->hpre);
488 rcc_set_ppre1(clock->ppre1);
489 rcc_set_ppre2(clock->ppre2);
491 } else {
492 /* going down, slow down before cutting power */
493 rcc_set_hpre(clock->hpre);
494 rcc_set_ppre1(clock->ppre1);
495 rcc_set_ppre2(clock->ppre2);
498 }
499
501 while (PWR_CSR & PWR_CSR_VOSF) {
502 ;
503 }
505
506 /* Set the peripheral clock frequencies used. */
510}
511
512void rcc_clock_setup_pll(const struct rcc_clock_scale *clock)
513{
514 /* Turn on the appropriate source for the PLL */
515 if (clock->pll_source == RCC_CFGR_PLLSRC_HSE_CLK) {
518 } else {
521 }
522
523 /*
524 * Set prescalers for AHB, ADC, APB1, APB2.
525 * Do this before touching the PLL (TODO: why?).
526 */
527 rcc_set_hpre(clock->hpre);
528 rcc_set_ppre1(clock->ppre1);
529 rcc_set_ppre2(clock->ppre2);
530
533
534 /* I guess this should be in the settings? */
538
539 /* Disable PLL oscillator before changing its configuration. */
541
542 /* Configure the PLL oscillator. */
544 clock->pll_div);
545
546 /* Enable PLL oscillator and wait for it to stabilize. */
549
550 /* Select PLL as SYSCLK source. */
552
553 /* Set the peripheral clock frequencies used. */
557}
558
559/*---------------------------------------------------------------------------*/
560/** @brief Get the peripheral clock speed for the USART at base specified.
561 * @param usart Base address of USART to get clock frequency for.
562 */
563uint32_t rcc_get_usart_clk_freq(uint32_t usart)
564{
565 if (usart == USART1_BASE) {
566 return rcc_apb2_frequency;
567 } else {
568 return rcc_apb1_frequency;
569 }
570}
571
572/*---------------------------------------------------------------------------*/
573/** @brief Get the peripheral clock speed for the Timer at base specified.
574 * @param timer Base address of TIM to get clock frequency for.
575 */
576uint32_t rcc_get_timer_clk_freq(uint32_t timer)
577{
578 /* Handle APB1 timers, and apply multiplier if necessary. */
579 if (timer >= TIM2_BASE && timer <= TIM7_BASE) {
582 : 2 * rcc_apb1_frequency;
583 } else {
586 : 2 * rcc_apb2_frequency;
587 }
588}
589
590/*---------------------------------------------------------------------------*/
591/** @brief Get the peripheral clock speed for the I2C device at base specified.
592 * @param i2c Base address of I2C to get clock frequency for.
593 */
594uint32_t rcc_get_i2c_clk_freq(uint32_t i2c __attribute__((unused)))
595{
596 return rcc_apb1_frequency;
597}
598
599/*---------------------------------------------------------------------------*/
600/** @brief Get the peripheral clock speed for the SPI device at base specified.
601 * @param spi Base address of SPI device to get clock frequency for (e.g. SPI1_BASE).
602 */
603uint32_t rcc_get_spi_clk_freq(uint32_t spi) {
604 if (spi == SPI1_BASE) {
605 return rcc_apb2_frequency;
606 } else {
607 return rcc_apb1_frequency;
608 }
609}
610/**@}*/
void flash_64bit_enable(void)
Enable 64 Bit Programming Mode.
Definition: flash.c:57
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.
#define PWR_CSR
Power control/status register (PWR_CSR)
Definition: pwr_common_v1.h:44
void pwr_set_vos_scale(enum pwr_vos_scale scale)
Definition: pwr_common_v2.c:29
#define RCC_CFGR_HPRE_NODIV
Definition: l1/rcc.h:184
#define RCC_CFGR_HPRE_DIV4
Definition: l1/rcc.h:186
#define RCC_CFGR_PPRE_NODIV
Definition: l1/rcc.h:175
#define RCC_CFGR_PPRE2_HCLK_NODIV
Definition: l1/rcc.h:218
#define RCC_CFGR_PPRE1_HCLK_NODIV
Definition: l1/rcc.h:224
#define RCC_CFGR_PLLSRC_HSI_CLK
Definition: l1/rcc.h:164
#define RCC_CR_RTCPRE_MASK
Definition: l1/rcc.h:90
#define RCC_CFGR_SW_SYSCLKSEL_HSICLK
Definition: l1/rcc.h:207
#define RCC_CFGR_PLLMUL_MUL3
Definition: l1/rcc.h:151
#define RCC_CIR_PLLRDYF
Definition: l1/rcc.h:268
#define RCC_CIR
Definition: l1/rcc.h:58
#define RCC_CIR_HSERDYF
Definition: l1/rcc.h:269
#define RCC_CFGR_PPRE1_MASK
Definition: l1/rcc.h:170
#define RCC_CIR_LSERDYC
Definition: l1/rcc.h:252
#define RCC_CFGR_PPRE2_SHIFT
Definition: l1/rcc.h:167
#define RCC_CFGR_SWS_SYSCLKSEL_HSICLK
Definition: l1/rcc.h:199
#define RCC_CIR_PLLRDYIE
Definition: l1/rcc.h:257
#define RCC_CFGR_PLLSRC_HSE_CLK
Definition: l1/rcc.h:165
#define RCC_CIR_PLLRDYC
Definition: l1/rcc.h:249
#define RCC_CR
Definition: l1/rcc.h:55
#define RCC_ICSCR
Definition: l1/rcc.h:56
#define RCC_CIR_MSIRDYF
Definition: l1/rcc.h:267
#define RCC_CFGR_PLLMUL_MUL6
Definition: l1/rcc.h:153
#define RCC_CFGR_SWS_SYSCLKSEL_HSECLK
Definition: l1/rcc.h:200
#define RCC_CSR_RTCSEL_SHIFT
Definition: l1/rcc.h:428
#define RCC_CFGR_PPRE2_MASK
Definition: l1/rcc.h:168
#define RCC_CFGR_PLLDIV_MASK
Definition: l1/rcc.h:148
#define RCC_CFGR_HPRE_MASK
Definition: l1/rcc.h:194
#define RCC_CFGR_SWS_MASK
Definition: l1/rcc.h:202
#define RCC_CIR_CSSC
Definition: l1/rcc.h:245
#define RCC_CIR_HSERDYIE
Definition: l1/rcc.h:258
rcc_osc
Definition: l1/rcc.h:477
#define RCC_CIR_LSERDYIE
Definition: l1/rcc.h:260
#define RCC_CFGR_SW_SYSCLKSEL_MSICLK
Definition: l1/rcc.h:206
#define RCC_CSR
Definition: l1/rcc.h:68
#define RCC_CFGR_SW_MASK
Definition: l1/rcc.h:210
#define RCC_CSR_LSION
Definition: l1/rcc.h:440
#define RCC_CFGR_PLLDIV_SHIFT
Definition: l1/rcc.h:147
#define RCC_CFGR_SW_SYSCLKSEL_PLLCLK
Definition: l1/rcc.h:209
#define RCC_CR_HSERDY
Definition: l1/rcc.h:78
#define RCC_CIR_LSIRDYIE
Definition: l1/rcc.h:261
#define RCC_CFGR
Definition: l1/rcc.h:57
void rcc_periph_clock_enable(enum rcc_periph_clken clken)
Enable Peripheral Clock in running mode.
#define RCC_CIR_HSERDYC
Definition: l1/rcc.h:250
#define RCC_CSR_RTCSEL_MASK
Definition: l1/rcc.h:429
#define RCC_CIR_LSIRDYC
Definition: l1/rcc.h:253
#define RCC_CR_RTCPRE_SHIFT
Definition: l1/rcc.h:89
#define RCC_CR_HSIRDY
Definition: l1/rcc.h:82
#define RCC_CFGR_PLLDIV_DIV2
Definition: l1/rcc.h:144
#define RCC_CFGR_SWS_SHIFT
Definition: l1/rcc.h:203
#define RCC_CSR_LSIRDY
Definition: l1/rcc.h:439
#define RCC_CFGR_PLLMUL_SHIFT
Definition: l1/rcc.h:160
#define RCC_CIR_MSIRDYIE
Definition: l1/rcc.h:256
#define RCC_CFGR_SWS_SYSCLKSEL_MSICLK
Definition: l1/rcc.h:198
#define RCC_CFGR_HPRE_SHIFT
Definition: l1/rcc.h:195
#define RCC_CIR_LSERDYF
Definition: l1/rcc.h:271
#define RCC_CFGR_SW_SHIFT
Definition: l1/rcc.h:211
#define RCC_CFGR_PLLMUL_MASK
Definition: l1/rcc.h:161
#define RCC_CR_MSIRDY
Definition: l1/rcc.h:80
#define RCC_CFGR_PLLDIV_DIV3
Definition: l1/rcc.h:145
#define RCC_CSR_LSEON
Definition: l1/rcc.h:438
#define RCC_CIR_HSIRDYIE
Definition: l1/rcc.h:259
#define RCC_CIR_LSIRDYF
Definition: l1/rcc.h:272
#define RCC_CR_CSSON
Definition: l1/rcc.h:74
#define RCC_CR_PLLON
Definition: l1/rcc.h:76
#define RCC_CIR_HSIRDYC
Definition: l1/rcc.h:251
#define RCC_CIR_HSIRDYF
Definition: l1/rcc.h:270
#define RCC_CIR_CSSF
Definition: l1/rcc.h:264
#define RCC_CR_HSEON
Definition: l1/rcc.h:79
#define RCC_CFGR_SWS_SYSCLKSEL_PLLCLK
Definition: l1/rcc.h:201
#define RCC_CR_MSION
Definition: l1/rcc.h:81
#define RCC_CSR_LSERDY
Definition: l1/rcc.h:437
#define RCC_CR_HSION
Definition: l1/rcc.h:83
#define RCC_CR_PLLRDY
Definition: l1/rcc.h:75
#define RCC_CFGR_PPRE1_SHIFT
Definition: l1/rcc.h:169
#define RCC_CIR_MSIRDYC
Definition: l1/rcc.h:248
@ RCC_PWR
Definition: l1/rcc.h:528
@ RCC_HSI
Definition: l1/rcc.h:478
@ RCC_LSI
Definition: l1/rcc.h:478
@ RCC_PLL
Definition: l1/rcc.h:478
@ RCC_MSI
Definition: l1/rcc.h:478
@ RCC_LSE
Definition: l1/rcc.h:478
@ RCC_HSE
Definition: l1/rcc.h:478
@ RCC_CLOCK_CONFIG_END
Definition: l1/rcc.h:464
int rcc_osc_ready_int_flag(enum rcc_osc osc)
Definition: rcc.c:195
int rcc_css_int_flag(void)
Definition: rcc.c:227
void rcc_osc_ready_int_clear(enum rcc_osc osc)
Definition: rcc.c:123
void rcc_wait_for_osc_ready(enum rcc_osc osc)
Wait for Oscillator Ready.
Definition: rcc.c:251
void rcc_clock_setup_msi(const struct rcc_clock_scale *clock)
Definition: rcc.c:432
void rcc_css_disable(void)
Definition: rcc.c:334
bool rcc_is_osc_ready(enum rcc_osc osc)
Is the given oscillator ready?
Definition: rcc.c:232
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:603
void rcc_set_sysclk_source(uint32_t clk)
Definition: rcc.c:351
uint32_t rcc_apb2_frequency
Definition: rcc.c:50
void rcc_set_pll_source(uint32_t pllsrc)
Definition: rcc.c:375
void rcc_rtc_select_clock(uint32_t clock)
Definition: rcc.c:426
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
Get the peripheral clock speed for the Timer at base specified.
Definition: rcc.c:576
uint32_t rcc_system_clock_source(void)
Definition: rcc.c:420
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
Get the peripheral clock speed for the USART at base specified.
Definition: rcc.c:563
void rcc_clock_setup_pll(const struct rcc_clock_scale *clock)
Definition: rcc.c:512
void rcc_set_msi_range(uint32_t range)
Set the range of the MSI oscillator.
Definition: rcc.c:343
void rcc_set_rtcpre(uint32_t rtcpre)
Definition: rcc.c:411
void rcc_osc_ready_int_enable(enum rcc_osc osc)
Definition: rcc.c:147
void rcc_osc_ready_int_disable(enum rcc_osc osc)
Definition: rcc.c:171
void rcc_osc_on(enum rcc_osc osc)
Definition: rcc.c:281
uint32_t rcc_ahb_frequency
Definition: rcc.c:48
void rcc_osc_off(enum rcc_osc osc)
Definition: rcc.c:305
void rcc_set_pll_configuration(uint32_t source, uint32_t multiplier, uint32_t divisor)
Definition: rcc.c:360
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:594
const struct rcc_clock_scale rcc_clock_config[RCC_CLOCK_CONFIG_END]
Definition: rcc.c:52
uint32_t rcc_apb1_frequency
Definition: rcc.c:49
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
Definition: rcc.c:256
void rcc_set_ppre1(uint32_t ppre1)
Definition: rcc.c:393
void rcc_css_int_clear(void)
Definition: rcc.c:222
void rcc_set_ppre2(uint32_t ppre2)
Definition: rcc.c:384
void rcc_css_enable(void)
Definition: rcc.c:329
void rcc_set_hpre(uint32_t hpre)
Definition: rcc.c:402
void rcc_clock_setup_hsi(const struct rcc_clock_scale *clock)
Switch sysclock to HSI with the given parameters.
Definition: rcc.c:473
#define RCC_ICSCR_MSIRANGE_SHIFT
Definition: l1/rcc.h:101
#define RCC_ICSCR_MSIRANGE_MASK
Definition: l1/rcc.h:102
#define RCC_ICSCR_MSIRANGE_4MHZ
Definition: l1/rcc.h:112
#define RCC_ICSCR_MSIRANGE_2MHZ
Definition: l1/rcc.h:111
#define PWR_CSR_VOSF
Definition: pwr_common_v2.h:71
@ PWR_SCALE1
high performance, highest voltage
Definition: pwr_common_v2.h:84
#define TIM2_BASE
#define TIM7_BASE
#define SPI1_BASE
#define USART1_BASE
uint8_t ppre1
Definition: l1/rcc.h:448
uint8_t flash_waitstates
Definition: l1/rcc.h:446
uint8_t ppre2
Definition: l1/rcc.h:449
uint32_t apb1_frequency
Definition: l1/rcc.h:452
uint8_t pll_mul
Definition: l1/rcc.h:443
uint32_t ahb_frequency
Definition: l1/rcc.h:451
enum pwr_vos_scale voltage_scale
Definition: l1/rcc.h:450
uint16_t pll_div
Definition: l1/rcc.h:444
uint8_t msi_range
Definition: l1/rcc.h:454
uint8_t hpre
Definition: l1/rcc.h:447
uint32_t apb2_frequency
Definition: l1/rcc.h:453
uint8_t pll_source
Definition: l1/rcc.h:445