STM32 HAL Library, DMA problem

Thread Starter

ssonel1

Joined Feb 24, 2020
15
I want to use DMA with UART for both Rx and Tx concurrently. I examine the UART HAL library for that. What I see is, HAL library doesn't let me to do that. Because It arranges callbacks for only one purpose(Rx or Tx). The code explains itself:

The function HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) contains the code below:
/* Set the UART DMA transfer complete callback */
huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt;
/* Set the UART DMA Half transfer complete callback */
huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt;
/* Set the DMA error callback */
huart->hdmarx->XferErrorCallback = UART_DMAError;
/* Set the DMA abort callback */
huart->hdmarx->XferAbortCallback = NULL;
/* Enable the DMA stream */
tmp = (uint32_t *)&pData;
HAL_DMA_Start_IT(huart->hdmarx, (uint32_t)&huart->Instance->DR, *(uint32_t *)tmp, Size);


And the function HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) contains the code below:
/* Set the UART DMA transfer complete callback */
huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt;
/* Set the UART DMA Half transfer complete callback */
huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt;
/* Set the DMA error callback */
huart->hdmatx->XferErrorCallback = UART_DMAError;
/* Set the DMA abort callback */
huart->hdmatx->XferAbortCallback = NULL;
/* Enable the UART transmit DMA stream */
tmp = (uint32_t *)&pData;
HAL_DMA_Start_IT(huart->hdmatx, *(uint32_t *)tmp, (uint32_t)&huart->Instance->DR, Size);


As you can see the both function uses same DMA structure which is situated below UART_Handle_Typedef. Am I missing something or HAL missing something?
 

Thread Starter

ssonel1

Joined Feb 24, 2020
15
I just notice right after sending this thread that DMA structures is not same. One is hdmatx and other one is hdmarx. I look for deleting the thread but couldn't found. Sorry for redundant post. If editor can delete it I would be appreciate.
 
Top