cancel
Showing results for 
Search instead for 
Did you mean: 

undefined reference to `HAL_UART_Init'

JDrew.469
Associate

I am trying to get UART working on a project for debugging purposes but I can't get my project to compile correctly. I have uncommented "HAL_UART_MODULE_ENABLED" in stm32f4xx_hal_conf.h but it seems to have no affect on my build at all. My Paths and Symbols settings and build output are below:

0690X00000AqtVXQAZ.png

4 REPLIES 4

Must add source code file stm32f4xx_hal_uart.c to project

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JDrew.469
Associate

Well that was easy. I thought that adding the /STM32F4xx_HALL_Driver/Src directory into the includes would make those .c files accessible to me. Is there a "more correct" way of adding these files into my project or should I just copy them into the same directory as my main.c file?

Include Paths are where it looks for.H files you #include, it can determine the search order too, but these things don't contain "code", just interface details.

The body of the code needs to come in as a .C or .LIB/A file

My preference is to keep them in the ...HAL_Driver/Src directory, and Add them into the project tree, if I need to modify them I will bring them into the project's own directory and add "localized" to the name to identify that they aren't the standard file.

Tools like CubeMX seem to copy in the whole kitchen sink, but I'm not a big fan.

At the end of the day it comes down to personal choice, or protocol defined by project lead or customer.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

> Is there a "more correct" way of adding these files into my project or should I just copy them into the same directory as my main.c file?

You can add the Cube library files to the project directly from where the Cube library is installed. But this can create a problem

if the project is moved to another machine or shared among people who have Cube installed in different places,

Eclipse will automatically pick files added to a source directory in the project. So this is the simplest, quickest way.

Eclipse also has so called "linked resources" and "virtual folders" that emulate symbolic links of Unix.

Especially, SW4STM adds the Cube drivers in this way.

The virtual folders look like they are within your project directory, but files in these actually are somewhere else - under the directory where the Cube library is installed. Very useful feature, common in all Eclipses (Atollic ...) but very confusing for beginners.

-- pa