cancel
Showing results for 
Search instead for 
Did you mean: 

How to include additional HAL libraries to existing example without using CUBEMX

FSara.1
Associate II

We are working on "Peripheral Lite" from STM32WB_FW and we would like to include SPI and UART libraries .

We imported this project in STM32 IDE by automatic conversion.

Since there is no "ioc" file (CUBEMX) and only a small part of HAL libraries are present, how can we add the other part?

4 REPLIES 4
TDK
Guru

You'll need to copy over the files from the repository, then edit the #defines in the hal_*_conf.h file such that they are included.

If you feel a post has answered your question, please click "Accept as Solution".
FSara.1
Associate II

I've tried importing those files (.h,.c) under a new virtual folder inside the project, then adding that directory to the project includes and sources path (Properties -> C++ general -> path and symbols), and finally modifying my main.c adding

 #include "stm32wbxx_hal_spi.h"

#include "stm32wbxx_hal_usart.h" 

Now the IDE recognize those files and the functions declared inside, the compiler seems to understand their location and actually compiles them but, as soon as it reaches the main.c , gives up with the error that all the functions from the libraries cannot be found ( e.g. HAL_SPI_Init(), but really anything from them)

The stm32wbxx_hal_conf.h should have #defines selection sub-modules, and also pulling in the includes for the other components.

You would then need add the source files for each sub-module to your project so the linker can get closure.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The linker gets closure because all the sub-components get built and all the symbols get matched up.

It doesn't "talk" to the linker, the compiler builds objects, the linker processes and binds them together. The linker complains if you try to reference some subroutine or variable that isn't defined in any of the code that was built.

The #defines cause a selective build, where large sections of the C files disappear during preprocessing, and it also skips include files, this speeds the build / compilation process, and stops a lot of unnecessary junk being fed to the linker for it to do dead-code elimination on.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..