cancel
Showing results for 
Search instead for 
Did you mean: 

Macro for different DMA types

AShetty
Associate II
I am making an application using the STM32 drivers. Currently, I am using the following macro defined in the 'Device' drivers to distinguish the chip families:

 

/** * @brief STM32 Family */ #if !defined (STM32F4) #define STM32F4 #endif /* STM32F4 */

 

As we know, STM32F2/F4 and F7 have a different type of DMA implementation than STM32H5, leading to differences in elements in DMA_InitTypeDef and DMA_HandleTypeDef structures. 
Is there a macro that will help us distinguish these DMA types, rather than the chip family macro?

2 REPLIES 2
TDK
Guru

No, there are not per-peripheral macros for each family and version of peripheral.

If you feel a post has answered your question, please click "Accept as Solution".

CubeIDE will automatically include a #define for the chip you're using; eg,

AndrewNeil_1-1726840311434.pngAndrewNeil_2-1726840319895.png

AndrewNeil_5-1726840755592.png

So you could use that to create your "family" macro; eg,

 

#if defined STM32F051x8 || defined STM32F030x8 #define STM32F0 #elif defined STM32L073xx #define STM32L0 #else #error "Unknown chip" #endif

 

 

EDIT:

Sorry, I mis-read the question.

But, in a similar style, you could provide your own "DMA Type" macro:

#if defined STM32F2 || defined STM32F4 || defined STM32F7 #define DMA_TYPE_1 #elif defined STM32H5 #define DMA_TYPE_2 #else #error "Unknown STM32 family." #endif