LED Port configuration with STM32H573I-DK (PushPull vs. OpenDrain)
When configuring the LEDs for the STM32H573I-DK using the STM32CubeMX it generated code which initializes the LED pins as PushPull (rather than OpenDrain).
Lookign at the schematics of the STM32H573I-DK it seems to be not "the best option".
Would you agree that OpenDrain (GPIO_MODE_OUTPUT_OD) is the better option here, rather than PushPull (GPIO_MODE_OUTPUT_PP)?
/**
* @brief Configures LED on GPIO.
* @PAram Led LED to be configured.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @arg LED4
* @retval BSP status
*/
int32_t BSP_LED_Init(Led_TypeDef Led)
{
int32_t ret = BSP_ERROR_NONE;
GPIO_InitTypeDef gpio_init_structure;
if ((Led != LED1) && (Led != LED2) && (Led != LED3) && (Led != LED4))
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
switch (Led)
{
case LED2:
/* Enable the LED2 GPIO clock */
LED2_GPIO_CLK_ENABLE();
break;
case LED3:
/* Enable the LED3 GPIO clock */
LED3_GPIO_CLK_ENABLE();
break;
case LED4:
/* Enable the LED4 GPIO clock */
LED4_GPIO_CLK_ENABLE();
break;
case LED1:
default:
/* Enable the LED1 GPIO clock */
LED1_GPIO_CLK_ENABLE();
break;
}
/* Configure the GPIO_LED pin */
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
gpio_init_structure.Pin = LED_PIN [Led];
HAL_GPIO_Init(LED_PORT[Led], &gpio_init_structure);
HAL_GPIO_WritePin(LED_PORT [Led], (uint16_t)LED_PIN[Led], GPIO_PIN_SET);
}
return ret;
} 

