AnsweredAssumed Answered

HAL_SPI_TransmitReceive_DMA() missing error handling

Question asked by Geoffrey Davis on Oct 12, 2017

Not a question, but an observation. I am using the STM32L476G-EVAL board with STM32Cube_FW_L4_V1.9.0 and noted that within the call to HAL_SPI_TransmitReceive_DMA(), if calls to HAL_DMA_Start_IT() do not succeed for some reason, the error isn't trapped as it should be. I made the modifications in bold below:

  /* Enable the Rx DMA Stream/Channel  */
  errorcode = HAL_DMA_Start_IT(hspi->hdmarx, (uint32_t)&hspi->Instance->DR, (uint32_t)hspi->pRxBuffPtr, hspi->RxXferCount);
  if (errorcode != HAL_OK) {
    goto error;
  }

...

  /* Enable the Tx DMA Stream/Channel  */
  errorcode = HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t)hspi->pTxBuffPtr, (uint32_t)&hspi->Instance->DR, hspi->TxXferCount);
  if (errorcode != HAL_OK) {
    goto error;
  }

I was hoping that the changes could be incorporated into the next library release, if it is agreed that they are necessary.

Outcomes