Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For STM32H7 BSP boards, initialize RCC_...TypeDef structs as empty #1931

Merged
merged 2 commits into from
Mar 9, 2023
Merged

For STM32H7 BSP boards, initialize RCC_...TypeDef structs as empty #1931

merged 2 commits into from
Mar 9, 2023

Conversation

branalba
Copy link
Contributor

@branalba branalba commented Feb 28, 2023

Following how ST's CubeMX/CubeIDE tools generate RCC init structs and general best practice for usage of a struct like this, instances of RCC_ClkInitTypeDef, RCC_OscInitTypeDef, and RCC_PeriphClkInitTypeDef should all be initialized as empty with = {0};. I've confirmed that failing to do this for the RCC_PeriphClkInitTypeDef in the stm32h723nucleo example causes some undefined behavior when implementing a TUSB stack on my own STM32H723 board (I didn't use the example directly but I lifted the contents of the board_stm32h7_clock_init() function and tested both with/without initializing the struct).

From looking at the examples, the initialization may not be needed in all cases since the subsequent population of struct members is sufficient to eliminate any issues, but just to be consistent I applied the change to all occurrences of the aforementioned structs in the STM32H7 BSP examples.

This is my first PR on Github so apologies in advance if I've made any errors; I know this is a fairly minor set of changes but thought it would be good to include.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

Look good, thank you

@hathach hathach merged commit 990fb6a into hathach:master Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants