[email protected] wrote:
i tried to use these macros for simplified port definitions
because i want to change only one line when i change the port (PANIC_PORT):
// standard macros (K&R A.12, C-FAQs 11.17)
# define mc_CAT(x, y) x ## y
# define mc_XCAT(x, y) mc_CAT(x, y)
# define PANIC_PORT P3
# define PANIC_PORT_DIR mc_XCAT(PANIC_PORT,DIR)
# define PANIC_PORT_SEL mc_XCAT(PANIC_PORT,SEL)
# define PANIC_PORT_OUT mc_XCAT(PANIC_PORT,OUT) // line 35
instead of that, you could duplicate the "sfr" definitions of the ports
in msp430/gpio.h. and use "P3IN_" as refenece (the header files define
the constants with underlines to the address of the coresponding
peripheral register)
or you could use the "port" structs. see msp430/iostructures.h
that way you have only one name and can access the ports as structure
like "port3.out.pin1 = 0;"
and it almost works, but not for the out port, because OUT is defined as 0x0004:
...
Why is OUT defined?
the timer capture/compare controls (CCTL1...) have a bit with that name.
And can
#undef OUT
cause problems?
not if you dont intend to use that constant. but it may have unexpected
effects if someone else later takes your code and want to use the timer
in compare mode ;-)
chris