I hope that someone might have an idea on how to control / specify the extension order of macros. Here is the context:
// 32 bit increments, processor has registers for set, clear and invert
//Now if I use this I can do it quite nicely with
SET(LATB, STATUS_LED); // LATB is port of the LED.
I actually had to move the hardware a bit, so I decided to group the LATB information using STATUS_LED, like ...
#define STATUS_LED_PORT LATB
#define STATUS_LED_MASK 0x0040;
#define STATUS_LED STATUS_LED_PORT, STATUS_LED_MASK
SET( STATUS_LED );
But, alas, LATB, 0x0040 is passed to argument 1 of the SET macro. If this macro is not used as a macro, this method works correctly:
inline void SET(u32_t *reg, u32_t bits) { ((volatile u32_t *) (((u32_t)reg) + SET_OFF*4 )) = bits; }
#define STATUS_LED &STATUS_LED_PORT, STATUS_LED_MASK
SET( STATUS_LED);
But, unfortunately, my compiler does not see the need to embed the function and calls 6 instructions for setting the register, as opposed to 4, so this is unpredictable for use in bitmapping.
I hope someone can learn about a way to first increase the STATUS_LED macro, something like:
SET( ##STATUS_LED )
SET SETRM (set register, mask), , , SET ...
#define SETRM(reg,bits) ...
#define SET(args) SETRM(args)
, , n- , , , , : (.
, , , , SET .