2022-06-21 07:53 AM
Hi all,
i like to build my own costum library that i can reuse in multiple projects. But this library should use the HAL peripheral library like SPI or uart or stuff like that. So how to initialize the peripheral, should it be done in the lilbrary or must it be done in the application which uses the lib. An reference whould be nice.
Greetings
2022-06-21 09:34 AM
If you're building a BSP (Board Support Package) put all the board specific peripheral and pin initialization within that.
2022-06-21 11:16 AM
Cube mistify peaple with library name, but real library in C is header only and precompiled lib.
Lib is loaded to linker in linking part. STM use this only in 3party as TouchGFX ...
If your code is precompiled lib, then all config is only possible over call func parameters.
But if scene is source/header file then init peripherals in source perfectly managed in header and
#ifdef UART3
...
instead
if (huart == UART3)
2022-06-22 12:17 AM
Hi, it more like headers and lib. A useful case would be an application that needs to be updated via the internet. For that i need to have the tcp/ip stack on both the bootloader and the application. To prevent that i thought of kind a putting that inside the library so both could use them. But question is how to initialize the peripherals. Maybe there have to be a peripheral init and deinit function in the lib?
Is there a good documentation where i can look it up or a example code?
Greetings
2022-06-28 01:59 PM
And if the updated code doesn't work, then the bootloader also doesn't work and the device is bricked. You don't want the bootloader or any parts of it to be updated!