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?
A macro will always be expanded to the corresponding text. It can be written with parameters (as in the '__HANDLE__' part here) which means it will substitute whatever text is in the macro invocation as part of the expansion.
For example:
Code:
#define abc(d) d * 2
fred(abc(x));
will expand to
Code:
fred(x * 2);
From this you should be able to see the answer to your second question: you are not passing the macro as a parameter, you will be passing the textual expansion of the macro - in this case it is an ugly nested ternary statement that will be evaluated at runtime and the result will be the parameter that is passed to the function.
Susan