From 2f9a541cbc23f9922a7358c85b8a5364c53b7b5b Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Fri, 11 Mar 2016 04:17:18 +0200 Subject: [PATCH] Abort DMA transfer after snapshot. --- src/omv/sensor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/omv/sensor.c b/src/omv/sensor.c index e6e0cb836..57ca0fa85 100644 --- a/src/omv/sensor.c +++ b/src/omv/sensor.c @@ -595,6 +595,11 @@ int sensor_snapshot(image_t *image) } } + // Abort DMA transfer. + // Note: In JPEG mode the DMA will still be waiting for data since + // the max frame size is set, so we need to abort the DMA transfer. + HAL_DMA_Abort(&DMAHandle); + // Disable DMA IRQ HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); @@ -608,9 +613,6 @@ int sensor_snapshot(image_t *image) fb->bpp = 2; break; case PIXFORMAT_JPEG: - // The frame readout has finished, however the DMA's still waiting for data - // because the max frame size is set, so we need to abort the DMA transfer. - HAL_DMA_Abort(&DMAHandle); // Read the number of data items transferred fb->bpp = (MAX_XFER_SIZE - DMAHandle.Instance->NDTR)*4; break;