From e6da6a720fb2bb48c6885e5f28f5f917690080fd Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 11 Nov 2016 17:24:18 +1100 Subject: [PATCH] stmhal/dma: De-init the DMA peripheral properly before initialising. The DMA state is always HAL_DMA_STATE_RESET because of the memset clearing all the data, so prior to this patch HAL_DMA_DeInit was never called. Now it is always called to make sure the DMA is properly reset. --- stmhal/dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stmhal/dma.c b/stmhal/dma.c index 218d0fbef2..7b540f847e 100644 --- a/stmhal/dma.c +++ b/stmhal/dma.c @@ -430,9 +430,8 @@ void dma_init(DMA_HandleTypeDef *dma, const dma_descr_t *dma_descr, void *data){ dma_last_sub_instance[dma_id] = sub_inst; // reset and configure DMA peripheral - if (HAL_DMA_GetState(dma) != HAL_DMA_STATE_RESET) { - HAL_DMA_DeInit(dma); - } + // (dma->State is set to HAL_DMA_STATE_RESET by memset above) + HAL_DMA_DeInit(dma); HAL_DMA_Init(dma); HAL_NVIC_SetPriority(dma_irqn[dma_id], IRQ_PRI_DMA, IRQ_SUBPRI_DMA); }