Other Parts Discussed in Thread: SIMPLICITI
Hello all,
I am trying to put toghether a piece of code that should compile and run on multiple evaluation kits (ez430rf, exp4518 and exp5438). I understand that various functions will be assigned to different GPIOs, so I came up with the following solution:
// eZ430RF EXP461x EXP5438
//LED1 P1.0 P2.2 P1.0
//LED2 P1.1 P2.1 P1.1
//SW1 P1.2 P1.0 P2.6
//SW2 null P1.1 P2.7
#if (defined __eZ430RF__)
#define PLED P1
#define LED1BIT 0x01
#define LED2BIT 0x02
#define PSW P1
#define SW1BIT 0x04
#define SW2BIT null
#elif (defined __EXP461z__)
#define PLED P2
#define LED1BIT 0x02
#define LED2BIT 0x04
#define PSW P1
#define SW1BIT 0x01
#define SW2BIT 0x02
#elif (defined __EXP5438__)
#define PLED P1
#define LED1BIT 0x01
#define LED2BIT 0x02
#define PSW P2
#define SW1BIT 0x40
#define SW2BIT 0x80
#else
#error "Must have a valid board"
#endif
#define PortFuncEval(func1) P ## func1
#define PortFunc(func1) PortFuncEval(func1)
#define step1(x,y) x ## y
#define step2(x,y) step1(x,y)
#define Port(func,op) step2(PortFunc(func),op)
Port(LED,DIR) |= (LED1BIT+LED2BIT); // P1DIR |= 0x03; Set P1.0,1 Output
The thing works, replacing "Port(LED,DIR)" with P1DIR correctly. Unfortunately to get the P1OUT, for example, the "Port(LED,OUT)" doesn't work! It gives me the "expression must be a modifiable lvalue" error (I think, because "OUT" is declared in the msp430Fxxxx.h file).
I have tryed to use small letters ( as opposed to CAPS), but I got difficulties when I've tryed to convert to CAPS with "toupper()".
Is any of you guys, having an ideea of how can I accomplish this (without modifying the include/definition files, as the code must be portable)?
Many thanks!
Bogdan