From dab6c79db9125e6409103b80ad15d8ed656aa2a5 Mon Sep 17 00:00:00 2001 From: Vivien Henry Date: Tue, 3 May 2022 12:12:39 +0200 Subject: [PATCH] [stm32] Add half transfer handler for DMA --- src/modm/platform/dma/stm32/dma.hpp.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/modm/platform/dma/stm32/dma.hpp.in b/src/modm/platform/dma/stm32/dma.hpp.in index 5f56237bbf..a77e57551d 100644 --- a/src/modm/platform/dma/stm32/dma.hpp.in +++ b/src/modm/platform/dma/stm32/dma.hpp.in @@ -245,6 +245,16 @@ public: { transferError = irqHandler; } + /** + * Set the IRQ handler for half transfer complete + * + * Called by the channels IRQ handler when the transfer is half complete. + */ + static void + setHalfTransferCompleteIrqHandler(IrqHandler irqHandler) + { + halfTransferComplete = irqHandler; + } /** * Set the IRQ handler for transfer complete * @@ -300,6 +310,9 @@ public: interruptHandler() { %% if dmaType in ["stm32-channel-request", "stm32-channel", "stm32-mux"] + static const uint32_t HT_Flag { + uint32_t(InterruptFlags::HalfTransferComplete) << (uint32_t(ChannelID) * 4) + }; static const uint32_t TC_Flag { uint32_t(InterruptFlags::TransferComplete) << (uint32_t(ChannelID) * 4) }; @@ -308,6 +321,9 @@ public: }; %% elif dmaType in ["stm32-stream-channel", "stm32-mux-stream"] constexpr uint8_t offsetLut[8] = {0, 6, 16, 22, 0+32, 6+32, 16+32, 22+32}; + static const uint64_t HT_Flag { + uint64_t(InterruptFlags::HalfTransferComplete) << offsetLut[uint32_t(ChannelID)] + }; static const uint64_t TC_Flag { uint64_t(InterruptFlags::TransferComplete) << offsetLut[uint32_t(ChannelID)] }; @@ -322,6 +338,8 @@ public: if (transferError) transferError(); } + if ((isr & HT_Flag) and halfTransferComplete) + halfTransferComplete(); if ((isr & TC_Flag) and transferComplete) transferComplete(); @@ -380,6 +398,7 @@ public: private: static inline DmaBase::IrqHandler transferError { nullptr }; + static inline DmaBase::IrqHandler halfTransferComplete { nullptr }; static inline DmaBase::IrqHandler transferComplete { nullptr }; %% if dmaType in ["stm32-mux", "stm32-mux-stream"]: