cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to force CUBEMX to include HAL drivers that are not normally loaded into my project?

roman239955
Associate III

I need to use hal_flash/hal_flash_ex/hal_flash_ramfunc but all of my normal peripherals are LL so the base hal drivers are not loaded into my project when I GENERATE CODE.  

My workaround is to include something like CRC/HAL to load a bunch of hal drivers then I deinit the CRC in main.

Likewise, is there a way to load HAL AND LL drivers? In CubeMX we can only choose one or the other.

6 REPLIES 6
Pavel A.
Evangelist III

Yes it is possible to use HAL & LL drivers even without Cube-generated stuff, and add any driver to your project manually. Have a look at stm32.....hal_conf.h file.

Additionally, for LL drivers make sure that USE_FULL_LL_DRIVER is defined.

roman239955
Associate III

Parel,

Thank you for taking the time to answer but I think I worded my question incorrectly.

I wish to force CubeMX to generate specific HAL flash drivers when I click the Generate Code button even when the desired HAL drivers are not selected in the Driver Selector.

Is it possible to force CubeMX to add flash drivers that are not normally generated with a click of Generate Code?

Best Regards,

Roman

CubeMX doesnt "generate" the drivers, it just adds the corresponding #include to your project.

what it does create is the init functions & structs to initialice the peripheral (you would need to do this yourself)

As all HAL .c/.h shoud be in the same place and aleady included your IDE path, add #include "stm32blabladriverofyourchoice.h" between the

/* USER CODE BEGIN Includes */
 
/* USER CODE END Includes */

in your main.c and check it out yourself

we dont need to firmware by ourselves, lets talk

@roman239955​ As Javier wrote, Cube does not "generate" HAL drivers, it just copies them from the "repository" into the project directory. And this is optional: you can choose not to copy these files, instead use links or references to the originals in the "repository".

This is, by the way, what I prefer. Otherwise, I'd end with a lot of copies in my projects, that are hard to tell which HAL library version they came from (updates do happen).

You just can use this way and assume all the HAL files are always available, just need to add some #defines and #includes to enable them.

roman239955
Associate III

Pavel Javier,

Thank you for the responses.

It is unfortunate that we cannot force CubeMX to include drivers that are not used for uninitialized peripherals or add both HAL and LL drivers simultaneously.

Yep, and it does not make coffee ((