Skip to content

Commit

Permalink
stm32h7/serial: fix TX DMA
Browse files Browse the repository at this point in the history
  • Loading branch information
kk-thrane committed Mar 8, 2024
1 parent 7e95326 commit 48d521f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions arch/arm/src/stm32h7/stm32_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -3314,11 +3314,7 @@ static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
* This is important to free TX buffer space by 'uart_xmitchars_done'.
*/

if (status & DMA_SCR_HTIE)
{
priv->dev.dmatx.nbytes += priv->dev.dmatx.length / 2;
}
else if (status & DMA_SCR_TCIE)
if (status & DMA_SCR_TCIE)
{
priv->dev.dmatx.nbytes += priv->dev.dmatx.length;
if (priv->dev.dmatx.nlength)
Expand Down Expand Up @@ -3346,11 +3342,20 @@ static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
}
}

nxsem_post(&priv->txdmasem);

/* Adjust the pointers */

uart_xmitchars_done(&priv->dev);

/* Initiate another transmit if data is ready */

if (priv->dev.xmit.tail != priv->dev.xmit.head)
{
uart_xmitchars_dma(&priv->dev);
}
else
{
nxsem_post(&priv->txdmasem);
}
}
#endif

Expand All @@ -3372,6 +3377,14 @@ static void up_dma_txavailable(struct uart_dev_s *dev)
int rv = nxsem_trywait(&priv->txdmasem);
if (rv == OK)
{
if (dev->xmit.head == dev->xmit.tail)
{
/* No data to transfer. Release semaphore. */

nxsem_post(&priv->txdmasem);
return;
}

uart_xmitchars_dma(dev);
}
}
Expand Down

0 comments on commit 48d521f

Please sign in to comment.