Skip to content

Commit

Permalink
stm32h7:serial make TX DMA busy when there are an outstanding transac…
Browse files Browse the repository at this point in the history
…tion

    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
  • Loading branch information
davids5 authored and xiaoxiang781216 committed Jan 22, 2024
1 parent 1c28bf2 commit 6c186b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/arm/src/stm32h7/stm32_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6c186b6

Please sign in to comment.