Is there a way of optionally including code using #define like this?
#define TIMR_TO_USE TIM14
#if TIMR_TO_USE == TIM14
// Do some stuff.
#elif TIMR_TO_USE == TIM16
// Do some other stuff.
#endif
I feel like this ought to work but doesn't. Is there a way round it?
For info I want to optionally choose which timer to use on an STM32. I have lots of places where I have code like
TIMR_TO_USE->ARR = 1000;
But there are other places where I need different lines of code.
#define USE_TIM14and then#ifdef USE_TIM14 .... #elif defined(USE_TIM16) ... #endif. But why would you want something "around it"?TIM14andTIM16to different integer values, e.g. 1 and 2.