Prototype21
Junior Member level 1
Hey Guys,
I am new to edaboard and ARM microcontroller. I happened to encounter the following two macro definition in HAL library in STMCubeMX.
First:
Second:
In the c file, it called like
I am little confused here. How can a macro behave like a function. Is it possible to pass __HAL_DMA_GET_TC_FLAG_INDEX(hdma) as a parameter to __HAL_DMA_CLEAR_FLAG. Whats happening here?
I am new to edaboard and ARM microcontroller. I happened to encounter the following two macro definition in HAL library in STMCubeMX.
First:
Code:
#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
DMA_FLAG_TC5)
Second:
Code:
__HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (DMA1->IFCR = (__FLAG__))
In the c file, it called like
Code:
__HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
I am little confused here. How can a macro behave like a function. Is it possible to pass __HAL_DMA_GET_TC_FLAG_INDEX(hdma) as a parameter to __HAL_DMA_CLEAR_FLAG. Whats happening here?