2021-08-02 06:40 AM
Hello folks,
I want to create my own library.
However, it seems I cannot send SPI_HandleTypedef between the main source and my library file.
My codes are not even close to the finish, but I placed in here so that maybe I have different issues that I may miss.
*FOR THE ONES WHO ARE CURIOUS:
I am planning to get data from UART (I DON'T KNOW WHY BUT I COULDN'T RUN VCP), and get time via RTC. Lastly, print that info in a presentable shape to LCD.
I use Tilen Majerle codes (for SPI initializing). https://github.com/MaJerle/stm32f429/tree/master/08-STM32F429_ILI9341
I couldn't be able to make LCD work on my own. I thought maybe I have a problem with SPI initializing. that's some irrelevant info but for someone who is interested.
Thanks for your attention and help,
Kind Regards.
Serkan KAŞ
Solved! Go to Solution.
2021-08-03 11:28 PM
Every c-file needs to be compilable individually (i.e. the compiler needs to be able to find all the variable types, function signatures, ...).
So yes, wherever SPI_HandleTypedef is used, you need to include the file where that type is defined.
by including stm32f4xx_hal, you will automatically include stm32f4xx_hal_spi where the type is defined.
Typically, when creating a larger program using various interfaces, stm32f4xx_hal.h will be included in many c-files (or even in your custom header files).
2021-08-02 06:47 AM
Go into stm32f4xx_hal_conf.h and ensure the SPI module is enabled.
Ensure you're including "stm32f4xx.h" before using any HAL functionality.
2021-08-02 09:33 AM
in stm32f4xx_hal_conf.h, SPI module was already enabled.
I also include stm32f4xx.h header in my main, but It seems still giving errors.
*I am sorry I reply too late, due to the time difference.
2021-08-02 09:43 AM
You need to include HAL functions prior to using them.
So include stm32f4xx.h before you use them in ILI9341.h.
2021-08-03 10:05 PM
that doesn't work either.
Should I write something like
#ifndef SPI
#define SPI
#endif
into ILI header file?
2021-08-03 10:15 PM
Well actualy, even that doesn't worked.
However, when I include stm32f4xx.h file into ILI library it erases the error.
But is it the correct way to do it this way, when I also have #include "stm32f4xx.h" at main?
2021-08-03 11:28 PM
Every c-file needs to be compilable individually (i.e. the compiler needs to be able to find all the variable types, function signatures, ...).
So yes, wherever SPI_HandleTypedef is used, you need to include the file where that type is defined.
by including stm32f4xx_hal, you will automatically include stm32f4xx_hal_spi where the type is defined.
Typically, when creating a larger program using various interfaces, stm32f4xx_hal.h will be included in many c-files (or even in your custom header files).
2021-08-04 07:27 AM
You're showing code in main.c but your errors are coming from ILI9341.c. Why are you marking your own posts as answering the question?
2021-08-04 09:48 AM
I mean, at top of the post, you suggest me to define stm32f4xx lib to before ILI9341 lib right? Did I misunderstood?
Anyway, the solution was, as both me and Sebastian said, when I include stm32f4xx library in ILI9341.c, it fixed.
So, I got answered of my question.