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

Fix compilation error for F091 with SPI #508

Merged
merged 2 commits into from
Sep 16, 2017
Merged

Fix compilation error for F091 with SPI #508

merged 2 commits into from
Sep 16, 2017

Conversation

ghost
Copy link

@ghost ghost commented Sep 15, 2017

Description

This board does not have a STM32_SPII2S_MAX #define and its frequency is limited to 12MHz.

This 12MHz frequency becomes the default value for boards other than STM32F4xx and STM32F7xx for now.

How Has This Been Tested?

No error at compile time with SPI option ON for the STM32F091 board.

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This board does not have a _STM32_SPII2S_MAX_ #define and its frequency is limited to 12MHz.

This 12MHz becomes the default value for boards other than STM32F4xx and STM32F7xx for now.
@nfbot
Copy link
Member

nfbot commented Sep 15, 2017

Hi @MikroBusNet,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

#if defined(STM32F4xx_MCUCONF) || defined(STM32F7xx_MCUCONF)
int32_t clock = STM32_SPII2S_MAX >> 1; // SP1, SPI4, SPI5 and SPI6 on APB2
if (bus == 2 || bus == 3) clock >>= 1; // SPI2 and SPI3 on APB1
#else
Copy link
Member

Choose a reason for hiding this comment

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

Guess this should be good for all STM32F0, but might not be for other series.
This should be stressed in the code by add an if defined(STM32F0xx_MCUCONF) instead of the else.

Copy link
Author

Choose a reason for hiding this comment

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

Sure but what about "other" MCUs we do not handle or know yet ?
Right now, I am sure only about F4/F7 and F0. That's why I have put default value to an arbitrary one.
Another solution could be to leave the code "as is" and wait a compilation error on the STM32_SPII2S_MAX . In this case we will know for sure which new board we have to handle.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed and totally understandable.
That's why I suggested that change. In order to stress that this appears to be handled "by series" and that we've tested it on F4, 7 and 0.
Adding an elseif for F0 and an else with an #error saying that this needs checking on other F's would help when that time comes.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

please see my comment

... if board is not F0/F4/F7
Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

LGTM

@josesimoes josesimoes merged commit b667540 into master Sep 16, 2017
@josesimoes josesimoes deleted the SPI-F091 branch September 16, 2017 10:38
@josesimoes josesimoes restored the SPI-F091 branch September 17, 2017 22:15
@ghost ghost deleted the SPI-F091 branch September 24, 2017 07:48
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