Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

STM32H7 SPI + Exti fixes + BMI088 driver#1052

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
[stm32] Add interface to query DMA transfer status without interrupt
  • Loading branch information
@chris-durand
chris-durand committedOct 4, 2023
commit0b0ddd4f4b73bfec5f24d4ce705f272c85320035
50 changes: 44 additions & 6 deletionssrc/modm/platform/dma/stm32/dma.hpp.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
* Copyright (c) 2014-2017, Niklas Hauser
* Copyright (c) 2020, Mike Wolfram
* Copyright (c) 2021, Raphael Lehmann
* Copyright (c) 2021, Christopher Durand
* Copyright (c) 2021-2023, Christopher Durand
*
* This file is part of the modm project.
*
Expand DownExpand Up@@ -116,6 +116,10 @@ public:

using ChannelHal = DmaChannelHal<ChannelID, CHANNEL_BASE>;

%% if dmaType in ["stm32-stream-channel", "stm32-mux-stream"]
static constexpr uint8_t FlagOffsetLut[8] = {0, 6, 16, 22, 0+32, 6+32, 16+32, 22+32};
%% endif

public:
/**
* Configure the DMA channel
Expand DownExpand Up@@ -145,7 +149,7 @@ public:
}

/**
* Start the transfer of the DMA channel
* Start the transfer of the DMA channel and clear all interrupt flags.
*/
static void
start()
Expand DownExpand Up@@ -321,15 +325,14 @@ public:
uint32_t(InterruptFlags::Error) << (uint32_t(ChannelID) * 4)
};
%% 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)]
uint64_t(InterruptFlags::HalfTransferComplete) <<FlagOffsetLut[uint32_t(ChannelID)]
};
static const uint64_t TC_Flag {
uint64_t(InterruptFlags::TransferComplete) <<offsetLut[uint32_t(ChannelID)]
uint64_t(InterruptFlags::TransferComplete) <<FlagOffsetLut[uint32_t(ChannelID)]
};
static const uint64_t TE_Flag {
uint64_t(InterruptFlags::Error) <<offsetLut[uint32_t(ChannelID)]
uint64_t(InterruptFlags::Error) <<FlagOffsetLut[uint32_t(ChannelID)]
};
%% endif

Expand All@@ -349,6 +352,41 @@ public:
ControlHal::clearInterruptFlags(InterruptFlags::Global, ChannelID);
}

/**
* Read channel status flags when channel interrupts are disabled.
* This function is useful to query the transfer state when the use of
* the channel interrupt is not required for the application.
*
* @warning Flags are automatically cleared in the ISR if the channel
* interrupt is enabled or when start() is called.
*/
static InterruptFlags_t
getInterruptFlags()
{
const auto globalFlags = ControlHal::getInterruptFlags();
const auto mask = static_cast<uint8_t>(InterruptFlags::All);
%% if dmaType in ["stm32-channel-request", "stm32-channel", "stm32-mux"]
const auto shift = static_cast<uint32_t>(ChannelID) * 4;
%% elif dmaType in ["stm32-stream-channel", "stm32-mux-stream"]
const auto shift = FlagOffsetLut[uint32_t(ChannelID)];
%% endif
const auto channelFlags = static_cast<uint8_t>((globalFlags >> shift) & mask);
return InterruptFlags_t{channelFlags};
}

/**
* Clear channel interrupt flags.
* Use only when the channel interrupt is disabled.
*
* @warning Flags are automatically cleared in the ISR if the channel
* interrupt is enabled or when start() is called.
*/
static void
clearInterruptFlags(InterruptFlags_t flags = InterruptFlags::All)
{
ControlHal::clearInterruptFlags(flags, ChannelID);
}

/**
* Enable the IRQ vector of the channel
*
Expand Down
8 changes: 4 additions & 4 deletionssrc/modm/platform/dma/stm32/dma_base.hpp.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -228,15 +228,15 @@ public:
};

%% if dmaType in ["stm32-stream-channel", "stm32-mux-stream"]
enum class InterruptEnable {
enum class InterruptEnable: uint32_t{
DirectModeError= DMA_SxCR_DMEIE,
TransferError= DMA_SxCR_TEIE,
HalfTransfer= DMA_SxCR_HTIE,
TransferComplete= DMA_SxCR_TCIE,
};
MODM_FLAGS32(InterruptEnable);

enum class InterruptFlags {
enum class InterruptFlags: uint8_t{
FifoError = 0b00'0001,
DirectModeError = 0b00'0100,
Error = 0b00'1000,
Expand All@@ -247,14 +247,14 @@ public:
};
MODM_FLAGS32(InterruptFlags);
%% elif dmaType in ["stm32-channel-request", "stm32-channel", "stm32-mux"]
enum class InterruptEnable {
enum class InterruptEnable: uint32_t{
TransferComplete= DMA_CCR_TCIE,
HalfTransfer= DMA_CCR_HTIE,
TransferError= DMA_CCR_TEIE,
};
MODM_FLAGS32(InterruptEnable);

enum class InterruptFlags {
enum class InterruptFlags: uint8_t{
Global = 0b0001,
TransferComplete = 0b0010,
HalfTransferComplete = 0b0100,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp