How to know UART DMA TX is finished for RS485 enable process in STM32F4 CubeMX
You should use the following function:

HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)


and make sure that the UART and the DMA interrupts are enabled.

If you look into the implementation, (only a part of it):

/* Set the UART DMA transfer complete callback */
huart-&gt;hdmatx-&gt;XferCpltCallback = UART_DMATransmitCplt;

/* Set the UART DMA Half transfer complete callback */
huart-&gt;hdmatx-&gt;XferHalfCpltCallback = UART_DMATxHalfCplt;

/* Set the DMA error callback */
huart-&gt;hdmatx-&gt;XferErrorCallback = UART_DMAError;

/* Enable the UART transmit DMA Stream */
tmp = (uint32_t*)&amp;pData;
HAL_DMA_Start_IT(huart-&gt;hdmatx, *(uint32_t*)tmp, (uint32_t)&amp;huart-&gt;Instance-&gt;DR, Size);


The DMA will be started in IT mode, and there are three HAL_UART callbacks which will be called by the callback functions above.


Transmit complete callback: HAL_UART_TxCpltCallback
Half of the bytes are sent: HAL_UART_TxHalfCpltCallback
Error: HAL_UART_ErrorCallback


All of these have weak declaration so you have to implement them. For example:

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
    if (huart-&gt;Instance == USART1)  // change USART instance
    {
       // Transmit complete handle RS-485 related stuff
    }
}