This is a simple bugfix of the HAL library (unfortunately ST does not allow external commits). If you have any issues regarding the function HAL_DMA_RegisterCallback(…) using the option HAL_DMA_XFER_ALL_CB_ID, you have to add the following case:

     case HAL_DMA_XFER_ALL_CB_ID:
		   hdma->XferErrorCallback = pCallback;
		   hdma->XferHalfCpltCallback = pCallback;
		   hdma->XferCpltCallback = pCallback;
		   hdma->XferAbortCallback = pCallback;
		   break;

The complete function should be like

HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma))
{
  HAL_StatusTypeDef status = HAL_OK;

  /* Process locked */
  __HAL_LOCK(hdma);

  if(HAL_DMA_STATE_READY == hdma->State)
  {
    switch (CallbackID)
    {
     case  HAL_DMA_XFER_CPLT_CB_ID:
           hdma->XferCpltCallback = pCallback;
           break;

     case  HAL_DMA_XFER_HALFCPLT_CB_ID:
           hdma->XferHalfCpltCallback = pCallback;
           break;

     case  HAL_DMA_XFER_ERROR_CB_ID:
           hdma->XferErrorCallback = pCallback;
           break;

     case  HAL_DMA_XFER_ABORT_CB_ID:
           hdma->XferAbortCallback = pCallback;
           break;

     case HAL_DMA_XFER_ALL_CB_ID:
		   hdma->XferErrorCallback = pCallback;
		   hdma->XferHalfCpltCallback = pCallback;
		   hdma->XferCpltCallback = pCallback;
		   hdma->XferAbortCallback = pCallback;
		   break;

     default:
           status = HAL_ERROR;
           break;
    }
  }
  else
  {
    status = HAL_ERROR;
  }

  /* Release Lock */
  __HAL_UNLOCK(hdma);

  return status;
}
Author

Write A Comment