Skip to main content
StefanRickli
Associate
March 2, 2022
Solved

STM32CubeMX removes spi.h include as soon as QUADSPI peripheral is activated

  • March 2, 2022
  • 2 replies
  • 1330 views

It's not a big deal but this got me confused for a moment when I suddenly got compiler warnings.

Steps to reproduce:

  1. Start a new project in STM32CubeIDE
  2. Use STM32L422RBI MCU, default settings, finish
  3. CubeMX: Enable SPI1 peripheral, Full-Duplex Master, default configuration
  4. CubeMX: Project Manager > Code Generator > Enable "Generate peripheral initialization as a pair of '.c/.h' files per peripheral"
  5. Save IOC, generate code, build project: observe 0 errors, 0 warnings
  6. Note that in Core/main.c, there is a line #include "spi.h"
  7. Open IOC in CubeMX again
  8. CubeMX: Activate QUADSPI peripheral, Bank1 with Single/Dual Lines, default configuration
  9. Save IOC, generate code, build project: observe 0 errors, 1 warning: "implicit declaration of function 'MX_SPI1_Init'; did you mean 'MX_GPIO_Init'? [-Wimplicit-function-declaration]"
  10. Observe that #include "spi.h" has been replaced by #include "quadspi.h"

This can easily be fixed manually by adding the missing include below in the user includes but still, it should be fixed in the CubeMX code generator.

Thanks!

This topic has been closed for replies.
Best answer by Sara BEN HADJ YAHYA

Hello @StefanRickli​ ,

Thanks for your feedback,

This is issue is the same as the one reported in this thread Missing <include "spi.h"> in STM32CubeMX V. 6.4.0. / HAL 1.9.1 (STM32H7). it is already raised to the dev team to be fixed. I will keep you posted with updates.

As you mentioned, the workaround for this issue is to manually add #include "spi.h" in the user section.

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

2 replies

Sara BEN HADJ YAHYA
ST Technical Moderator
March 4, 2022

Hello @StefanRickli​ ,

Thanks for your feedback,

This is issue is the same as the one reported in this thread Missing <include "spi.h"> in STM32CubeMX V. 6.4.0. / HAL 1.9.1 (STM32H7). it is already raised to the dev team to be fixed. I will keep you posted with updates.

As you mentioned, the workaround for this issue is to manually add #include "spi.h" in the user section.

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Sara BEN HADJ YAHYA
ST Technical Moderator
March 7, 2022

Hello ​ @StefanRickli,

This issue is fixed in STM32CubeMX latest release.

V6.5.0 is now available under this Link.

Thanks for your contribution.

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.