This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PORT and PIN C Macro

Other Parts Discussed in Thread: MSPWARE

mspware does have functions to set up pins, but if you don't use that lib here is how I do it with a C macro (tested on IAR)
makes it easy to change at one location if pcb board change, with much less chance of a bug if you missed a change somewhere.
## in the macro is so "P1" "OUT" is one word

place this in common.h

#define read &
#define clear &= ~
#define set |=
#define toggle ^=
#define Button(y,x)     (P1 ##x y BIT3)     // active low
#define RedLED(y,x)     (P1 ##x y BIT0)     // active high
then in main when you set up button IRQ for example, you can do this:
  Button(set,OUT);                               // Pull-up
  Button(set,IES);                               // falling edge