Skip to content

cpu/stm32f1: reworked clock initialization code#6970

Merged
kYc0o merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_stm32f1_clkinit
Apr 27, 2017
Merged

cpu/stm32f1: reworked clock initialization code#6970
kYc0o merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_stm32f1_clkinit

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

This PR improves the clock initialization for the STM32F1 in many ways:

  • it includes a STM32 common interface for clock handling
  • makes sure the system is always in a defined state -> hopefully solves problems with OTA and booting into different images
  • enables the use of HSE, HSI, or PLL as system clock
  • adds separate function for enabling the low speed clock (LSI or LSE)

The goal of the common clock handling interface is to implement it for each of the STM32 CPUs. With this then we can (i) move the cpu.c files into the common stm32_common tree, and (ii) use the low-freq clock functions for RTC etc.

@haukepetersen haukepetersen added Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Apr 26, 2017
@haukepetersen haukepetersen added this to the Release 2017.07 milestone Apr 26, 2017
Copy link
Copy Markdown
Contributor

@kYc0o kYc0o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very small comments which are not important.

I tested with OTA and works as is.

So, ACK.

RCC->CFGR &= ~(RCC_CFGR_SW);
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI) {}

/* its save now to program the flash wait states */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get this comment... maybe it was misspelled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spellings seems correct. Meaning: say you had a (fast) PLL configured as clock in the bootloader, but want to switch to some significant slower clock in some image you boot into. Then you would break the code if you would reprogram the flash wait states to some slower value while the PLL is still driving the system. But now that we switched to the HSI as system clock, we can program the flash wait states to whatever we like without breaking anything...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's a typo in the comment: save => safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ähh yap, should clean my glasses... sorry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/* the actual PLL values are automatically generated */
**/
/* high speed clock configuration:
* 0 := use internal HSI oscillator (alway 8MHz)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always.

/* the actual PLL values are automatically generated */
**/
/* high speed clock configuration:
* 0 := use internal HSI oscillator (alway 8MHz)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always.

/* configuration of PLL prescaler and multiply values */
/* CORECLOCK := CLOCK_SOURCE / PLL_DIV * PLL_MUL */
/* high speed clock configuration:
* 0 := use internal HSI oscillator (alway 8MHz)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always.

/* configuration of PLL prescaler and multiply values */
/* CORECLOCK := CLOCK_SOURCE / PLL_DIV * PLL_MUL */
/* high speed clock configuration:
* 0 := use internal HSI oscillator (alway 8MHz)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always.

@kYc0o kYc0o added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 26, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

addressed comments and squashed.

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Apr 27, 2017

Go then!

@kYc0o kYc0o merged commit 1e9ea82 into RIOT-OS:master Apr 27, 2017
@haukepetersen haukepetersen deleted the opt_stm32f1_clkinit branch April 28, 2017 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants