I would like to create a project for STM32 with HAL in C++. Unfortunately, CubeMX supports only projects in C. However, HAL support C++.
I have created a project in CubeMX and I was trying to import it to any of the IDEs above but without any success because it is imported as a C project. So it doesn't look like a good solution.
Also, I have tried creating a C++ project in the mentioned IDE and adding to it files from CubeMX. It seems to be more logic but I can't do it in the right way because my configuration is still wrong.
Could anyone explain me how should I configure new C++ projects in Eclipse or Atollic TrueSTUDIO in order to use HAL?
To start a new project, go to [File]>[New]>[STM32 Project].
You should be ready to build your STM32 project in C++ with all of the object-oriented programming you so desire. Please note that you can generally call C functions from within a C++ program and vice versa. You will need to add extern “C” to your functions, which is detailed in this article.
The STM32 Hardware Abstraction Layer (HAL) provides a simple, generic multi-instance set of APIs (application programming interfaces) to interact with the upper layers like the user application, libraries and stacks.
One of the distinguishing features of STM32CubeIDE is its integration of STM32CubeMX. Developers can select their board or microcontroller and start a project after configuring the pinout and clock tree.
there is very simple way to build a cpp project in stm32cubeide
main.c
in cpp file make a simple function like main2()
main.c
now you can use cpp function through main2()
functionIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With