STMicroelectronics / stm32g4xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32G4 series.
BSD 3-Clause "New" or "Revised" License
12 stars 8 forks source link

[HAL][SPI] State stuck in HAL_SPI_STATE_BUSY_RX when invalid parameters are passed to Rx functions #17

Open raqnarok opened 1 week ago

raqnarok commented 1 week ago

Description: When using full-duplex SPI in master mode, there is an issue with the state management in the Rx functions. The parameters of the Rx function are checked within the TxRx functions. However, the state HAL_SPI_STATE_BUSY_RX is set within the Rx function itself. This leads to a scenario where if the Rx function is called with invalid parameters, the TxRx function returns an error, leaving the SPI state stuck in HAL_SPI_STATE_BUSY_RX.

Steps to Reproduce:

  1. Set up SPI in full-duplex master mode.
  2. Call the Rx function with invalid parameters.
  3. Observe that the TxRx function returns an error.
  4. Notice that the SPI state remains stuck in HAL_SPI_STATE_BUSY_RX.

Expected Behavior: The SPI state should not be stuck in HAL_SPI_STATE_BUSY_RX when invalid parameters are passed to the Rx functions. Proper parameter validation should occur before changing the state.

Proposed Solution: Move the parameter validation to occur before setting the state to HAL_SPI_STATE_BUSY_RX in the Rx functions. This ensures that the state is only set if the parameters are valid.

KRASTM commented 6 days ago

Hello @raqnarok,

Thank you for the report. The issue already detected on other series, and Our team will fix it.

With regards,

KRASTM commented 6 days ago

ST Internal Reference: 185358