0
votes

I'm very new to STM32 MCU programming and I started a SPI project on TrueStudio. I needed an LCD library as well and hence I adapted an existing library to be used with mine and added those files under Inc and Src.

When I try to compile, I get an error saying that a previously undeclared define is being used for the first time in the function, however, they've been defined in the respective header file and that header file has been included in the C file. What am I missing? All my errors seem to be in the 'HD44780.c' file. I should also mention that I used the CubeMX software to generate the pin definition source code. A zip of the project is available here.

Any help would be appreciated! EDIT: Exact error messages are listed here:

Description                         Resource    Path            Location    Type
'HD44780_D4_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 242    C/C++ Problem
'HD44780_D5_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 241    C/C++ Problem
'HD44780_D6_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 240    C/C++ Problem
'HD44780_D7_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 239    C/C++ Problem
'HD44780_E_GPIO_PORT' undeclared (first use in this function)   HD44780.c   /STM32F103C6T8_SPI/Src  line 39     C/C++ Problem
'HD44780_RS_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 36     C/C++ Problem
'HD44780_RS_GPIO_PORT' undeclared (first use in this function)  HD44780.c   /STM32F103C6T8_SPI/Src  line 37     C/C++ Problem

Warnings
implicit declaration of function 'DELAY_Init' [-Wimplicit-function-declaration] HD44780.c   /STM32F103C6T8_SPI/Src  line 81 C/C++ Problem

Info
each undeclared identifier is reported only once for each function it appears in    HD44780.c   /STM32F103C6T8_SPI/Src  line 36 C/C++ Problem
in expansion of macro 'HD44780_E_BLINK' HD44780.c   /STM32F103C6T8_SPI/Src  line 243    C/C++ Problem
in expansion of macro 'HD44780_E_HIGH'  HD44780.c   /STM32F103C6T8_SPI/Src  line 41 C/C++ Problem
in expansion of macro 'HD44780_RS_HIGH' HD44780.c   /STM32F103C6T8_SPI/Src  line 229    C/C++ Problem
in expansion of macro 'HD44780_RS_LOW'  HD44780.c   /STM32F103C6T8_SPI/Src  line 219    C/C++ Problem
1
Does it compile using the original library and what library have you used?PhilMasteG
Never tried that since the original library was for an STM32F4 MCU. I made changes to the HAL functions to account for the STM32F1 that I'm using.electrophile
Also, what is the exact error you are getting? Have you included all necessary .h files? Do you have any other errors besides that one?PhilMasteG
Edited the Q with the exact errors that I see. AFAIK, I have included all the files. The undeclared errors that I see are being shown for #define that are in the .h file that is included in the .C file and yet I see the errors.electrophile

1 Answers

3
votes

In main.h, you are defining HD44780_*_GPIO_Port instead of HD44780_*_GPIO_PORT. Notice the all-uppercase PORT.