Skip to main content
KiptonM
Senior III
February 27, 2021
Solved

How can you tell if HAL_UART_Transmit_DMA() function has not finished?

  • February 27, 2021
  • 2 replies
  • 880 views

I have been looking for something in the structure.

while ((huart1.hdmatx->State != HAL_DMA_STATE_READY) && (huart1.hdmatx->Lock != HAL_UNLOCKED))

But that does not seem to work.

The only other way I can think of is when you call HAL_UART_Transmit_DMA() set a variable to 1, and then setup a callback complete and set it to 0. Is that the best way to do it?

This topic has been closed for replies.
Best answer by Vangelis Fortounas

Hello

The HAL way (the best way depends to peogrammer) to know when HAL_UART_Transmit_DMA is finished , is when HAL_UART_TxCpltCallback(..) called by HAL.

2 replies

Vangelis Fortounas
Associate II
February 27, 2021

Hello

The HAL way (the best way depends to peogrammer) to know when HAL_UART_Transmit_DMA is finished , is when HAL_UART_TxCpltCallback(..) called by HAL.

Piranha
Principal III
February 28, 2021

One should not use driver structures internal elements externally, because it's not thread safe and not future proof. The driver state is returned by HAL_UART_GetState(). Though that function is also not thread safe, as is almost everything in the broken HAL...