Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stm32] add Half Transfer handler for dma #858

Merged
merged 1 commit into from
May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/modm/platform/dma/stm32/dma.hpp.in
Original file line number Diff line number Diff line change
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