GENERATE CODE error, unknown type name 'HAL_StatusTypeDef'
Eval board used: Nucleo-U385RG-Q
Software tools:
STM32CubeIDE Version: 2.0.0 Build: 26820_20251114_1348 (UTC)
STM32CubeMX Version: 6.15.0
The provided project for the eval board builds without errors.
But when I modify the MCU to add a GPIO or I2C using STM32CubeMX,
multiple build errors are generated after using "GENERATE CODE" command.
These errors are:
unknown type name 'HAL_StatusTypeDef'
unknown type name 'HAL_LockTypeDef'
Although these definitions are defined in the following *.h file:
stm32u3xx_hal_def.h
/**
* @brief HAL Status structures definition
*/
typedef enum
{
HAL_OK = 0x00,
HAL_ERROR = 0x01,
HAL_BUSY = 0x02,
HAL_TIMEOUT = 0x03
} HAL_StatusTypeDef;
/**
* @brief HAL Lock structures definition
*/
typedef enum
{
HAL_UNLOCKED = 0x00,
HAL_LOCKED = 0x01
} HAL_LockTypeDef;
Apparently, the errors are created from define guards not allowing other files
to access and use the “typedef enum HAL_StatusTypeDef and HAL_LockTypeDef in stm32u3xx_hal_def.h.
To correct the problem:
I had to move HAL_StatusTypeDef and HAL_LockTypeDef defines To: stm32u3xx_hal_conf.h
Unfortunately, each to I modify the MCU pin definition or add a pin assignment with STM32CubeMX
and regenerate the code using "GENERATE CODE", the same errors are created after a build is started.
It seems there is a bug in the STM32CubeMX when using the "GENERATE CODE".
