2020-08-02 12:41 PM
Hello,
I am new with STM32CUBE. I have a weather station that I want to couple on the STM32F411 PCB (from Aliexpress). It works when I put the uint8_t WH24P_Data[21] data buffer in main.c. I have made WH24P.c and WH24P.h and I want to declare this buffer in WH24P.c from main.c with including #include "WH24P.h" from main.c. So I can use this external declared buffer in main. But If I move the buffer outside main.c, the data will not be send to the USB CDC. I can't even open the virtual comport. I just placed WH24P.c to Core-Src and WH24P.h to Core-Inc. But how do I import it the correct way? Maybe in a directory like the USB_DEVICE directory (WH24P name instead). How do I know it's included? It failed in the beginning, so that's why I put it in the Core directory at the moment.
This is in WH24P.c
uint8_t WH24P_Data[21];
This is in WH24P.h
extern uint8_t WH24P_Data[21];
Why can't I use this buffer from main.c when it is placed in WH24P.c and .h? The easiest way would be to have a ll the functions in main.c, but I want to make a separate file, so I can easily compile it later for another controller.
So the question in short. How can I include external files in STM32CUBE, so I can access the buffers declared in that other file. Because I am a beginner, please put it simply. Right click this and click that. Thank you very much.
Kind regards,
Ad
2020-08-02 12:50 PM
You're placing the files in the correct directories and have the correct definitions.
You need to #include "WH24P.h" from within main.c so it sees the definition.
2020-08-02 09:24 PM
You need to define the folder where the files are as source and header folder.
To define a header (include) folder:
In "Project Explorer", right click on the project and select "Properties" from the context menu.
In the properties window, go under "C/C++ General" and select "Paths and Symbols". Then on the right side you should see "include directories". This is where you list all folders you want to include header files from.
To include different source folders (so they are compiled), select "Source Location" from the same view and list necessary folders.
Hope this helps.
2020-08-02 10:39 PM
That reminds me that if you want to import a source file to your project, you can drag and drop on cube ide and it will ask to link or copy the file where you want it to be.. but it is too dumb not to detect the folder is not in compiler path and won t offer to add it...
2020-08-03 12:48 AM
Have a look to https://community.st.com/s/question/0D50X0000BRYmPbSQL/stm32cubeide-not-including-library-files-correctly some good tips inside