cancel
Showing results for 
Search instead for 
Did you mean: 

Use STM32Cube HAL as dependency for my own module

Omar Suárez
Senior
Posted on November 15, 2017 at 13:32

Hi everyone,

I am developping some modules in C and ithey need to use some structures and functions from the HAL Cube. I have include the 'stm32f7xx_hal.h' inside the '.h' file of my module but the Keil compiler throw me some undefined errors.

In fact al the undefined variables are from the HAL so I guess I am not including the correct '.h' file or the way of use the HAL as dependency is different.

This is a chunk of my code :

&sharpifndef __COMM_MODULE_H

&sharpdefine __COMM_MODULE_H

&sharpinclude <stdint.h>

&sharpinclude 'stm32f7xx_hal.h'

....

/* INTERFACE */

extern UART_HandleTypeDef huart3;

extern UART_HandleTypeDef huart6;

extern uint8_t rxBuffer[RXBUFFERSIZE];

extern uint8_t txBuffer[TXBUFFERSIZE];

extern volatile ITStatus Uart6Ready;

extern volatile ITStatus Uart3Ready;

extern void open_BT(void);

extern void open_USB(void);

extern void close_BT(void);

extern void close_USB(void);

extern void write_BT(uint8_t* txBuff, uint8_t size);

extern void write_USB(uint8_t* txBuff, uint8_t size);

extern void read_BT(uint8_t* rxBuff, uint8_t size);

extern void read_USB(uint8_t* rxBuff, uint8_t size);

....

....

&sharpendif

The compiler then shows that the undefined variables are:

   + UART_HandleTypeDef

   + ITStatus

What is the correct way of using the HAL inside my own module as dependency?

Thanks in advanced,

Omar

#keil-mdk5 #stm32f7
7 REPLIES 7
AvaTar
Lead
Posted on November 15, 2017 at 13:53

I have include the 'stm32f7xx_hal.h' inside the '.h' file of my module but the Keil compiler throw me some undefined errors.

In fact al the undefined variables are from the HAL so I guess I am not including the correct '.h' file or the way of use the HAL as dependency is different.

I don't do Cube, but check if the definitions you need are not surrounded by '

#ifdef

' statements, making it 'invisible' to the compiler.

Perhaps there is a Cube manual that explains the include file structure ...

The compiler then shows that the undefined variables are:

   + UART_HandleTypeDef

   + ITStatus

Can you show the compiler/toolchain output ?

Your code just declares this variables, perhaps they are nowhere defined.

Posted on November 15, 2017 at 15:28

Command line defines required to select HAL (USE_HAL_DRIVER), and further module level defines need to be in stm32f7xx_hal_conf.h

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on November 15, 2017 at 15:04

 ,

 ,

I will try to locate this info in the HAL manual to check the include file structure.

The file attached shows the errors throwed by Keil.

I declare the variables in this '.h' file but they are also defined inside the '.c' file.

Below you can see the error log (the actual log is longer but the errors are similar as in this snippet) :

Output:

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'communication_module_cemitec' compiling stm32f7xx_it.c... compiling stm32f7xx_hal_msp.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0 ../Src/stm32f7xx_hal_msp.c: 0 warnings, 4 errors compiling main.c... compiling stm32f7xx_hal_gpio.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0 ../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c: 0 warnings, 4 errors compiling comm_module.c... compiling stm32f7xx_hal_tim.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0 ../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c: 0 warnings, 4 errors compiling stm32f7xx_hal_dma.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0 ../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c: 0 warnings, 4 errors compiling stm32f7xx_hal_cortex.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0 ../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c: 0 warnings, 4 errors compiling stm32f7xx_hal.c... ../Inc/comm_module.h(24): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart3, ../Inc/comm_module.h(25): error: , ♯ 20: identifier 'UART_HandleTypeDef' is undefined , , extern UART_HandleTypeDef huart6, ../Inc/comm_module.h(31): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart6Ready, KB: Unexpected type: 0 error type>,(32): error: , ♯ 20: identifier 'ITStatus' is undefined , , extern volatile ITStatus Uart3Ready, KB: Unexpected type: 0

 ,

...

 ,

...

Thanks,

Omar

Posted on November 15, 2017 at 15:30

Long outputs in one line is hard to read ... ;-(

error:  ♯ 20: identifier 'UART_HandleTypeDef' is undefined   extern UART_HandleTypeDef huart3; ../Inc/comm_module.h(25):

Should mean the type definition is unknown when parsing your header (comm_module.h).

As said, I'm unaware how Cube is structured.

If 'stm32f7xx_hal.h' doesn't pull in other peripheral includes (the old SPL did conditionally), you need to do it yourself.

I guess you know, but when dealing with compil error output, always begin with the first error in the list.

Posted on November 15, 2017 at 15:34

There are module level defines, typically in stm32f7xx_hal_conf.h, that control which includes are pulled in.

&sharpdefine HAL_USART_MODULE_ENABLED  

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on November 15, 2017 at 16:39

Hi Clive,

those are all defined in the hal_conf file and the USE_HAL_DRIVER is also defined in the Preprocessor Symbols.

Posted on November 15, 2017 at 16:54

Then you're going to have to figure out why the preprocessor isn't pulling in what you think it should be.

Have the compiler generate a preprocessor output file and review that.

I would perhaps &sharpinclude 'stm32f7xx.h' outside of your &sharpifdef scoping, and make sure every file with this issue is &sharpincluding the right files.

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