Skip to main content
roman239955
Associate II
November 4, 2022
Question

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

  • November 4, 2022
  • 3 replies
  • 3751 views

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.

This topic has been closed for replies.

3 replies

Pavel A.
Super User
November 5, 2022

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 II
November 7, 2022

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

Javier1
Principal
November 7, 2022

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
roman239955
Associate II
November 8, 2022

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.

Pavel A.
Super User
November 9, 2022

Yep, and it does not make coffee ((