From 22bd23114af166980bad6ff00caaf97fdb1f2cf4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 24 Nov 2015 15:40:59 +0000 Subject: stmhal: On SysTick IRQ, only process one DMA channel at a time. This can be generalised if/when more processing is needed by SysTick. Thanks to @chuckbook for the idea. --- stmhal/dma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'stmhal/dma.c') diff --git a/stmhal/dma.c b/stmhal/dma.c index 7abd521be..2b344141e 100644 --- a/stmhal/dma.c +++ b/stmhal/dma.c @@ -220,14 +220,16 @@ void dma_invalidate_channel(DMA_Stream_TypeDef *dma_stream, uint32_t dma_channel } } -// Called from the SysTick handler (once per millisecond) -void dma_idle_handler() { +// Called from the SysTick handler +// We use LSB of tick to select which controller to process +void dma_idle_handler(int tick) { static const uint32_t controller_mask[] = { DMA1_ENABLE_MASK, DMA2_ENABLE_MASK }; - for (int controller = 0; controller < NCONTROLLERS; controller++) { + { + int controller = tick & 1; if (dma_idle.counter[controller] == 0) { - continue; + return; } if (++dma_idle.counter[controller] > DMA_IDLE_TICK_MAX) { if ((dma_enable_mask & controller_mask[controller]) == 0) { -- cgit v1.2.3