stm32h7:serial make TX DMA busy when there are an outstanding transaction

If a TX DMA completion interrups a forground write.
    The TX DMA completion can start a dma_send and it will
    then followed by the forground write's dma_send
    stoping the,then in progress DMA.

    By atomicaly marking the tx dma busy, the forground
    write will not perform the dma_send, and will only
    enqueue the data. At the next TX dma completion any
    data pending in the tx queue will be sent
This commit is contained in:
David Sidrane 2024-01-18 07:18:01 -08:00 committed by Xiang Xiao
parent 1c28bf2ed1
commit 6c186b6084
1 changed files with 5 additions and 1 deletions

View File

@ -3356,13 +3356,17 @@ static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
static void up_dma_txavailable(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags = enter_critical_section();
/* Only send when the DMA is idle */
if (stm32_dmaresidual(priv->txdma) == 0)
if ((priv->dev.dmatx.length && priv->dev.dmatx.nlength) == 0 &&
stm32_dmaresidual(priv->txdma) == 0)
{
uart_xmitchars_dma(dev);
}
leave_critical_section(flags);
}
#endif