STMicroelectronics / STM32CubeF4

STM32Cube MCU Full Package for the STM32F4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
824 stars 408 forks source link

STM32412G-Discovery BSP : Undefined behavior when `BSP_COM_Init` is called with `COM2` #138

Closed supcik closed 7 months ago

supcik commented 1 year ago

Setup

Describe the bug

The BSP for the STM32F412G-DISCO (Drivers/BSP/STM32412G-Discovery/stm32412g_discovery.c) has a method to initialize the serial communication :

void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart)

According to the documentation, COM can be COM1 or COM2:

  * @param  COM: COM port to be configured.
  *          This parameter can be one of the following values:
  *          COM1 
  *          COM2 
  * @param  huart: Pointer

But actually, only COM1 (which is used for USART2) can be used. Indeed, the number of COM is set to 1:

#define COMn ((uint8_t)1)

and the arrays COM_USART[COMn], COM_TX_PORT[COMn], COM_RX_PORT[COMn], COM_TX_PIN[COMn], COM_RX_PIN[COMn], COM_TX_AF[COMn], COM_RX_AF[COMn] are only defined for a single entry : COM1.

So when BSP_COM_Init is called with COM2 for the COM argument, the result is undefined.

How To Reproduce

  1. Call BSP_COM_Init with COM2 as first argument

Additional context

Screenshots

n/a

ASELSTM commented 1 year ago

ST Internal Reference: 132859

TOUNSTM commented 7 months ago

Hello @supcik,

The issue you reported has been fixed in the frame of version v1.28.0 of the STM32CubeF4 published recently on GitHub. Thank you again for having reported.

With regards,