Skip to main content
skrowten_hermit
Associate II
May 29, 2021
Solved

How to add APIs

  • May 29, 2021
  • 2 replies
  • 1506 views

I am new to STM32CubeIDE and I was trying to write a simple UART driver using polling method. I was successful when I wrote the function in the main.c and compiled the code.

So, I wanted to make an API of the same function and moved the function to separate .c files (in 01-uart/Core/Src/ i.e., where main.c is placed by default on code generation) and added the declaration in respective .h files (in 01-uart/Core/Inc/ i.e., where main.h is placed by default on code generation) just like in any other C project source code. But this threw 150+ errors on build and all related to HAL types. How do I fix it? It would be helpful if someone could give a pointer on how to do this. Attached below is my source code.

This topic has been closed for replies.
Best answer by TDK

The only file you should include is "stm32f3xx_hal.h". Look at the generated main.h for an example.

2 replies

TDK
TDKBest answer
May 31, 2021

The only file you should include is "stm32f3xx_hal.h". Look at the generated main.h for an example.

"If you feel a post has answered your question, please click ""Accept as Solution""."
skrowten_hermit
Associate II
June 1, 2021

Thanks a lot @TDK​ . My include was clearly wrong. I had #included "stm32f3xx_hal_uart.h" instead.