8
\$\begingroup\$

I am taking code from a stm32f0 series and trying to convert it to a stm32l4 series dev kit. I have already changed the necessary addresses and include files that I needed to migrate, but I keep on getting the following errors in the stm32l4xx_hal_uart Files:

../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h:610:1: error: unknown type name 'HAL_StatusTypeDef'; did you mean 'HAL_RTCStateTypeDef'? HAL_StatusTypeDef HAL_DeInit(void); ^~~~~~~~~~~~~~~~~

The error appears by this segment of code:

HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);

I have already defined the HAL_UART_MODULE_ENABLED in the stm32l4xx_hal_conf.h and nothing has changed.

What is the cause of this and how can I fix it?

\$\endgroup\$
6
  • \$\begingroup\$ Find the header file that defines a HAL_StatusTypeDef and make sure it gets included. It might help to enable the switch that will have your compiler save the preprocessor output. There really is no magic bullet here. \$\endgroup\$ Jun 11, 2019 at 13:39
  • \$\begingroup\$ I have included it in the header files, that is in the STM32L4xx_HAL_Driver and it still gives me that error, I do not understand by what you mean by enable the switch that will have your compiler save the preprocessor output. \$\endgroup\$
    – user150963
    Jun 11, 2019 at 13:55
  • \$\begingroup\$ Do you have a valid stm32l4xx_hal_conf.h file for your project? You're supposed to take stm32l4xx_hal_conf_template.h, make a copy named just stm32l4xx_hal_conf.h, and then edit it to enable the particular modules you're using. If you've done that properly then all the STM HAL library includes & typedefs should just work... \$\endgroup\$
    – brhans
    Jun 11, 2019 at 17:33
  • \$\begingroup\$ Have you changed the definition of the used controller type in your project settings? \$\endgroup\$
    – A.R.C.
    Jun 12, 2019 at 9:28
  • \$\begingroup\$ I do not understand what you mean by controller type? \$\endgroup\$
    – user150963
    Jun 12, 2019 at 10:31

1 Answer 1

16
\$\begingroup\$

I just got the same issue but with an STM32F407 microcontroller. Suddently, the build broke and there were 102 errors saying that HAL_StatusTypeDef was unknown. I followed the path to all the includes, and what I saw is that "stm32f4xx_hal_def.h" includes "stm32f4xx.h", which indirectly re-includes "stm32f4xx_hal_def.h" for each device you have enabled in "stm32f4xx_hal_conf.h". Except that each include of "stm32f4xx_hal_conf.h" includes again "stm32f4xx_hal_def.h", but this will fail, as the #define __STM32F4xx_HAL_DEF guards the file of being included twice ! So the conclusion for me was to always include "stm32f4xx.h", and not any intermediate file, as all these circular includes are calling for trouble !

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.