From d982a85af3444e328fc881949895533599213e08 Mon Sep 17 00:00:00 2001 From: "Sascha Schade (strongly-typed)" Date: Sat, 25 Feb 2023 13:09:53 +0100 Subject: [PATCH] [stm32] [dma] [irq] Check for pointer first for speed In case of IRQ for transferComplete is used and halfTransferComplete is not used: HT_Flag is always/mostly set when TC_Flag is set. So checking the flag first is wasting time. In case that TC_Flag is set and halfTransferComplete is used, IRQ latency stays the same with this change. --- src/modm/platform/dma/stm32/dma.hpp.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modm/platform/dma/stm32/dma.hpp.in b/src/modm/platform/dma/stm32/dma.hpp.in index 7b1c5cbdff..adec14cc0e 100644 --- a/src/modm/platform/dma/stm32/dma.hpp.in +++ b/src/modm/platform/dma/stm32/dma.hpp.in @@ -339,10 +339,12 @@ public: if (transferError) transferError(); } - if ((isr & HT_Flag) and halfTransferComplete) + if (halfTransferComplete and (isr & HT_Flag)) { halfTransferComplete(); - if ((isr & TC_Flag) and transferComplete) + } + if (transferComplete and (isr & TC_Flag)) { transferComplete(); + } ControlHal::clearInterruptFlags(InterruptFlags::Global, ChannelID); }