cancel
Showing results for 
Search instead for 
Did you mean: 

TRY TO CREATE MY OWN LIB but SPI_Handler couldn't get recognized

SKAŞ.1
Associate II

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.

0693W00000D1I2xQAF.jpg 

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Ş

1 ACCEPTED SOLUTION

Accepted Solutions

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).

View solution in original post

8 REPLIES 8
TDK
Guru

Go into stm32f4xx_hal_conf.h and ensure the SPI module is enabled.

Ensure you're including "stm32f4xx.h" before using any HAL functionality.

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

in stm32f4xx_hal_conf.h, SPI module was already enabled.

0693W00000D1JbjQAF.jpgI also include stm32f4xx.h header in my main, but It seems still giving errors.

0693W00000D1JdaQAF.jpg*I am sorry I reply too late, due to the time difference.

TDK
Guru

You need to include HAL functions prior to using them.

So include stm32f4xx.h before you use them in ILI9341.h.

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

0693W00000D1T6WQAV.jpgthat doesn't work either.

Should I write something like

#ifndef SPI

#define SPI

#endif

into ILI header file?

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?

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).

TDK
Guru

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?

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

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.