From 60f7bb6a3c8f541923dcf3cb2e62e945f0a4cc76 Mon Sep 17 00:00:00 2001 From: Tahsin Mutlugun Date: Thu, 19 Dec 2024 15:51:37 +0300 Subject: [PATCH] Add DMA channel number conversion Add a DMA channel conversion function to convert chanel numbers between Zephyr and MSDK. For example, if an SoC has two DMA instances named DMA0 and DMA1, with 4 channels each, DMA1 channel numbers should be offset by 4 before passing to MSDK. Signed-off-by: Tahsin Mutlugun --- Libraries/zephyr/MAX/Include/wrap_max32_dma.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_dma.h b/Libraries/zephyr/MAX/Include/wrap_max32_dma.h index 5690cedc9b..1cd03773dc 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_dma.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_dma.h @@ -87,6 +87,16 @@ static inline int Wrap_MXC_DMA_AcquireChannel(mxc_dma_regs_t *dma) #endif } +static inline int Wrap_MXC_DMA_GetChannelIndex(mxc_dma_regs_t *dma, uint8_t ch) +{ +#if defined(CONFIG_SOC_MAX32657) + (void)dma; + return ch; +#else + return (ch + MXC_DMA_GET_IDX(dma) * (MXC_DMA_CHANNELS / MXC_DMA_INSTANCES)); +#endif +} + static inline void Wrap_MXC_DMA_Handler(mxc_dma_regs_t *dma) { #if defined(CONFIG_SOC_MAX32657) || defined(CONFIG_SOC_MAX32665) || defined(CONFIG_SOC_MAX32666)