Skip to main content
Associate
September 21, 2026
Question

stm32CubeMX: User labels for handle structure 

  • September 21, 2026
  • 2 replies
  • 28 views

User labels for handle structure 

In STM32CubeMX, the user can define a User Label for GPIO pins.

For example:
  User Label: LED_RED

This generates:
#define LED_RED_Pin GPIO_PIN_5
#define LED_RED_GPIO_Port GPIOA

However, there is no User Label option for handle structures.
For example:

extern I2C_HandleTypeDef hi2c;
extern TIM_HandleTypeDef htim2;
extern ADC_HandleTypeDef hadc1;
extern UART_HandleTypeDef huart1;

Is would be nice to have al user label for a uart, so the application source can refer to that user label. 
For example:

extern UART_HandleTypeDef MY_COM_huart;
extern TIM_HandleTypeDef LED_RED_htim;

Thanks,

2 replies

ST Technical Moderator
September 21, 2026

Hello ​@rgpb 

Let me thank you for posting and welcome to the ST Community.

You are able to set the UART pins label through STM32CubeMX.

Thanks.

Mahmoud

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
rgpbAuthor
Associate
September 23, 2026

Hello  Mahmoud, 

Ok, this is a future request. 

But is still need to use "huart1" or "huart2" in the application source code. 

HAL_UART_Transmit(&huart1, (uint8_t *)str, (uint16_t)strlen(str), HAL_MAX_DELAY);
HAL_UART_Transmit(&huart2, (uint8_t *)str, (uint16_t)strlen(str), HAL_MAX_DELAY);

I like to have in the hal software something like : 
#define  TEST_UART    (&huart1)
#define  TEST_UART    (&huart2)

So the application source can use:
HAL_UART_Transmit(TEST_UART, (uint8_t *)str, (uint16_t)strlen(str), HAL_MAX_DELAY);


Thanks, 
Robert