いくつかの役に立つマクロ


わかる人がいるのは知っていますが...
define CAT1(x,y) x##y//Concatenates 2 strings
define CAT2(x,y) CAT1(x,y)//Forces evaluation of CAT1
//OCM port I/O defintions//Builds I/O port name: PNAME(1,INP) ==> P1INP
define PNAME(y,z) CAT2(P,CAT2(y,z))
//Builds I/O bit name: BNAME(1,2) ==> P1_2
define BNAME(port,pin) CAT2(CAT2(P,port),CAT2(_,pin))
define IO_OUT 1
define IO_IN 0
define IO_DIR_PORT_PIN(port, pin, dir)\
{\if ( dir == IO_OUT )\
PNAME(port,DIR) |= (1<<(pin)); \

else\
PNAME(port,DIR) &= ~(1<<(pin)); \

}