cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SPI_TransmitReceive_DMA() missing error handling

Geoffrey Davis
Associate
Posted on October 12, 2017 at 16:30

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.

0 REPLIES 0