cancel
Showing results for 
Search instead for 
Did you mean: 

Manually include hal library files

MFran.4
Senior

Hello!

I know that this is not a new topic, and maybe somewhere (even in this forum) someone already answered this question multiple times, but still.....

I crawled the forum looking for advice about using the HAL without CUBE, because where I work they have a nice proprietary c++ hal and I was starting to port it for STM32.

C++ classes would operate on top of the hal, but I'd like the possibility to, say, instantiate an UART class without previous cube initialization, and so on with other peripherals (timers, adc, dac ecc).

I followed the following steps but I'm stuck (no compilation errors but no autocomplete, like the IDE knows the files are there but doesn't really know...):

  • Created new STM32CubeIDE project with Cube (i wanted to keep the clock tree init)
  • Created a Usart class
  • Included "stm32l4xx_hal.h"
  • Manually uncommented (this is temporary) the line " #define HAL_USART_MODULE_ENABLED"
  • Copied the necessary files in the driver folder with the others (usart/usart ex .c/.h)

My idea is to have an header file that will be included in "stm32l4xx_hal_conf.h" (manually added, 'cause cube obviously erases it) where basically I can activate/deactivate the various peripherals like cube does (comment/uncomment above).

I'm no include-wizard so I can't figure out what's the correct way to do this. Any pointers?

Thank you!

4 REPLIES 4
TDK
Guru

The general idea would be to include files, try to compile, and address the errors that come up.

You need the CMSIS header file as well, and the HAL_Tick type functions.

> no compilation errors but no autocomplete

So it works/builds, and the problem is solely that you don't have autocomplete? Rebuilding the index should fix it, assuming your defines are set correctly.

If you feel a post has answered your question, please click "Accept as Solution".
MFran.4
Senior

> The general idea would be to include files, try to compile, and address the errors that come up.

Ok! I was following the right path then, I'll continue that way.

> You need the CMSIS header file as well, and the HAL_Tick type functions.

I'm including "main.h" in my cpp files, and it seems to give access to HAL_Tick functions. I'm not sure I understood your statement: where do I have to include CMSIS header?

My Classes (.cpp/.h) will always go in cubeMX generated projects, so (I don't really know why) I assume including "main.h" would suffice as it's including all that's needed in the main.c source file.

>So it works/builds, and the problem is solely that you don't have autocomplete? Rebuilding the index should fix it, assuming your defines are set correctly.

Autocomplete is fixed thanks to the index rebuilding! I always forget about index rebuilding... 😅 thanks a lot!

I'll make some more development tomorrow and eventually close this question.

TDK
Guru

The CMSIS header file is included from within "stm32l4xx.h" based on your defines. If it's compiling, then it's being included somewhere in the chain.

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

Is there any comply with-up right here? I am getting what I trust to be a similar blunders on an F2 tool the use of a custom document descriptor here. It reasons class parsing mistakes ensuing in intermittent USB enumeration.