Skip to main content
MQi.1
Senior II
January 5, 2021
Question

Where is the "stm32l5xx_hal.h"?

  • January 5, 2021
  • 14 replies
  • 5229 views

I made a project based on NECLEO STM32L552ZE-Q, when I made it from MX configuration tool, I found there was no "stm32l5xx_hal.h", while it was included in main.c, where could I find it?0693W000006HUTzQAO.png

This topic has been closed for replies.

14 replies

MQi.1
MQi.1Author
Senior II
January 5, 2021

here is the prompt in console:

​

​

08:39:20 **** Incremental Build of configuration Debug for project test_TrustZone-1_NonSecure ****
make -j8 all 
arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m33 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DSTM32L552xx -DDEBUG -c -I../Core/Inc -I../../Secure_nsclib -I../../Drivers/STM32L5xx_HAL_Driver/Inc -I../../Drivers/CMSIS/Device/ST/STM32L5xx/Include -I../../Drivers/STM32L5xx_HAL_Driver/Inc/Legacy -I../../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/main.o"
In file included from ../../Drivers/CMSIS/Device/ST/STM32L5xx/Include/stm32l5xx.h:98:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_def.h:34,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_rcc.h:29,
 from ../Core/Inc/stm32l5xx_hal_conf.h:246,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/CMSIS/Device/ST/STM32L5xx/Include/stm32l552xx.h:1893:29: error: expected declaration specifiers or '...' before '(' token
 #define GPIOC_NS ((GPIO_TypeDef *) GPIOC_BASE_NS)
 ^
../../Drivers/CMSIS/Device/ST/STM32L5xx/Include/stm32l552xx.h:2631:40: note: in expansion of macro 'GPIOC_NS'
 #define GPIOC GPIOC_NS
 ^~~~~~~~
../Core/Inc/main.h:72:29: note: in expansion of macro 'GPIOC'
 #define LED_GREEN_GPIO_Port GPIOC
 ^~~~~
../Core/Src/main.c:55:20: note: in expansion of macro 'LED_GREEN_GPIO_Port'
 HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
 ^~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:250:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_gpio.h:92:36: error: expected declaration specifiers or '...' before '(' token
 #define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */
 ^
../Core/Inc/main.h:70:23: note: in expansion of macro 'GPIO_PIN_7'
 #define LED_GREEN_Pin GPIO_PIN_7
 ^~~~~~~~~~
../Core/Src/main.c:55:41: note: in expansion of macro 'LED_GREEN_Pin'
 HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
 ^~~~~~~~~~~~~
../Core/Src/main.c: In function 'main':
../Core/Src/main.c:103:41: error: 'InputChar' undeclared (first use in this function)
 while (HAL_UART_Receive (&hlpuart1, &InputChar, 1, 1000) == HAL_OK)
 ^~~~~~~~~
../Core/Src/main.c:103:41: note: each undeclared identifier is reported only once for each function it appears in
../Core/Src/main.c:105:22: error: 'Status' undeclared (first use in this function); did you mean 'ITStatus'?
 if (InputChar != Status)
 ^~~~~~

MQi.1
MQi.1Author
Senior II
January 5, 2021

and these:

ITStatus
../Core/Src/main.c:108:37: warning: pointer targets in passing argument 2 of 'HAL_UART_Transmit' differ in signedness [-Wpointer-sign]
 HAL_UART_Transmit (&hlpuart1, "\r\n to be switched to S world.");
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:108:7: error: too few arguments to function 'HAL_UART_Transmit'
 HAL_UART_Transmit (&hlpuart1, "\r\n to be switched to S world.");
 ^~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: declared here
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:110:37: warning: pointer targets in passing argument 2 of 'HAL_UART_Transmit' differ in signedness [-Wpointer-sign]
 HAL_UART_Transmit (&hlpuart1, "\r\n to be switched to NS world.");
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:110:7: error: too few arguments to function 'HAL_UART_Transmit'
 HAL_UART_Transmit (&hlpuart1, "\r\n to be switched to NS world.");
 ^~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: declared here
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:112:6: warning: implicit declaration of function 'SECURE_RetargetISR' [-Wimplicit-function-declaration]
 SECURE_RetargetISR (InputChar);
 ^~~~~~~~~~~~~~~~~~
../Core/Src/main.c:116:36: warning: pointer targets in passing argument 2 of 'HAL_UART_Transmit' differ in signedness [-Wpointer-sign]
 HAL_UART_Transmit(&hlpuart1, "\r\n User Button has been switched to S world.");
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:116:7: error: too few arguments to function 'HAL_UART_Transmit'
 HAL_UART_Transmit(&hlpuart1, "\r\n User Button has been switched to S world.");
 ^~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: declared here
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:118:36: warning: pointer targets in passing argument 2 of 'HAL_UART_Transmit' differ in signedness [-Wpointer-sign]
 HAL_UART_Transmit(&hlpuart1, "\r\n User Button has been switched to NS world.");
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:118:7: error: too few arguments to function 'HAL_UART_Transmit'
 HAL_UART_Transmit(&hlpuart1, "\r\n User Button has been switched to NS world.");
 ^~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: declared here
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:121:36: warning: pointer targets in passing argument 2 of 'HAL_UART_Transmit' differ in signedness [-Wpointer-sign]
 HAL_UART_Transmit(&hlpuart1, "\r\n the same state, do nothing. \n");
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
../Core/Src/main.c:121:7: error: too few arguments to function 'HAL_UART_Transmit'
 HAL_UART_Transmit(&hlpuart1, "\r\n the same state, do nothing. \n");
 ^~~~~~~~~~~~~~~~~
In file included from ../Core/Inc/stm32l5xx_hal_conf.h:402:0,
 from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,
 from ../Core/Inc/main.h:31,
 from ../Core/Src/main.c:21:
../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal_uart.h:1581:19: note: declared here
 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
 ^~~~~~~~~~~~~~~~~
make: *** [Core/Src/subdir.mk:33: Core/Src/main.o] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
 
08:39:21 Build Failed. 10 errors, 6 warnings. (took 574ms)
 

TDK
January 5, 2021

It shows right in the console output:

from ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h:30,

The "Drivers" folder is a top-level folder within your project.

You've got some other usage errors happening. HAL_UART_Transmit requires a pointer, a length, and a timeout value. You're just trying to pass a raw string, which isn't even the right number of arguments.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MQi.1
MQi.1Author
Senior II
January 5, 2021

Yes, I found it, but the others are all set the same way, since this pin I used, so does that mean the configuration would rewrite the file "stm32l5xx_hal.h", and so my configuration has errors?

0693W000006HXZgQAO.png

Tesla DeLorean
Guru
January 5, 2021

Double check what modules are enabled in your project's stm32l5xx_hal_conf.h

This needs a timeout parameter

HAL_UART_Transmit(&hlpuart1, "\r\n the same state, do nothing. \n");

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MQi.1
MQi.1Author
Senior II
January 5, 2021

"This needs a timeout parameter"

For such error, Where could I get the HAL functions prototype(the documents) ?

MQi.1
MQi.1Author
Senior II
January 18, 2021

Now, it shown:"../Core/Src/main.c:121:28: error: 'hlpuart1' undeclared (first use in this function)", should I declared a "hlpuart1" object of "HLPUART" in main.c or main.h? Since I hasn't found it in " ../../Drivers/STM32L5xx_HAL_Driver/Inc/stm32l5xx_hal.h".

MQi.1
MQi.1Author
Senior II
January 18, 2021

for "Double check what modules are enabled in your project's stm32l5xx_hal_conf.h", I found these, is it enough?

#ifdef HAL_UART_MODULE_ENABLED

 #include "stm32l5xx_hal_uart.h"

#endif /* HAL_UART_MODULE_ENABLED */

#ifdef HAL_USART_MODULE_ENABLED

 #include "stm32l5xx_hal_usart.h"

#endif /* HAL_USART_MODULE_ENABLED */

TDK
January 19, 2021

HAL is open source, you can look at the source files directly to see how to use them. F3 will jump to the definition. There are also quite a few examples in the CubeMX repository that you can look at, although the L5 is relatively new and may not have as many as the other families.

If you enable these things within CubeMX, it will generate the code you need to run them, such as the definition of hlpuart1. That would probably be the easiest method to get started.

As far as what modules are enabled, your code snippet doesn't provide that info. Are the HAL_UART_MODULE_ENABLED and HAL_USART_MODULE_ENABLED #defines enabled? They would be higher up in that file.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MQi.1
MQi.1Author
Senior II
January 21, 2021

“HAL_UART_MODULE_ENABLED�?​ was found in NonSecure's "stm32l5xx_hal_conf.h" after MX. Since I have set LPUART1 as "asynchronous" , so USART is not needed.

MQi.1
MQi.1Author
Senior II
January 20, 2021

The recent time, I ran the code, it didn't show the error, and the code has been updated into board, since when I push the user button, I saw the first time what I expected, but I couldn't communicate with it by serial port, I guesses maybe as you said " the HAL_UART_MODULE_ENABLED and HAL_USART_MODULE_ENABLED" has not been enabled. But I could not fine the file"stm32l5xx_hal_conf.h", although I could find file "stm32l5xx_hal.h" there.

And, the board was shown as "STMicroelectronics STLink Virture COM Port (COM7)" in"Devices Manager" of Windows 10, I could only find COM1(Communications Port) in Putty.

TDK
January 20, 2021

> But I could not fine the file"stm32l5xx_hal_conf.h", although I could find file "stm32l5xx_hal.h" there.

It's shown in the screenshot in your very top post. You're going to need to try a little harder here if you want to solve issues.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MQi.1
MQi.1Author
Senior II
January 20, 2021

OK, I found it, it was here:

/...(project name)/Core/Inc/stm32l5xx_hal_conf.h

MQi.1
MQi.1Author
Senior II
January 20, 2021

I just tested in VS Code, it was said COM7 connected, no problem no error, but I just could input into it, and could see output from board in it.0693W000007BxOHQA0.jpg