Skip to content

Commit

Permalink
[stm32] Add half transfer handler for DMA
Browse files Browse the repository at this point in the history
  • Loading branch information
lukh authored and chris-durand committed May 4, 2022
1 parent ab9bcee commit dab6c79
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/modm/platform/dma/stm32/dma.hpp.in
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)
};
Expand All @@ -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)]
};
Expand All @@ -322,6 +338,8 @@ public:
if (transferError)
transferError();
}
if ((isr & HT_Flag) and halfTransferComplete)
halfTransferComplete();
if ((isr & TC_Flag) and transferComplete)
transferComplete();

Expand Down Expand Up @@ -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"]:
Expand Down

0 comments on commit dab6c79

Please sign in to comment.