From 75a934de0d56e7d155e0aa92724601744fad7abd Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 21 May 2024 19:13:37 +0200 Subject: [PATCH] ports/mimxrt: Retry transfer if the DMA is still busy. Retry to submit the transfer a few times if the DMA is busy, before dropping the frame. --- src/omv/ports/mimxrt/sensor.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/omv/ports/mimxrt/sensor.c b/src/omv/ports/mimxrt/sensor.c index a7dccc9dc..e5a1a88c3 100644 --- a/src/omv/ports/mimxrt/sensor.c +++ b/src/omv/ports/mimxrt/sensor.c @@ -224,10 +224,18 @@ int sensor_dma_memcpy(void *dma, void *dst, void *src, int bpp, bool transposed) MAIN_FB()->u * bpp, // bytesEachRequest MAIN_FB()->u * bpp); // transferBytes - // Drop the frame if EDMA is not keeping up as the image will be corrupt. - if (EDMA_SubmitTransfer(handle, &config) != kStatus_Success) { - sensor.drop_frame = true; - return 0; + size_t retry = 3; + status_t status = kStatus_EDMA_Busy; + while (status == kStatus_EDMA_Busy) { + status = EDMA_SubmitTransfer(handle, &config); + if (status == kStatus_Success) { + break; + } + if (--retry == 0) { + // Drop the frame if EDMA is not keeping up as the image will be corrupt. + sensor.drop_frame = true; + return 0; + } } EDMA_TriggerChannelStart(handle->base, handle->channel);