Text alias / substitution

I have various control lines for external DA converters, relays etc.

I may have something like:

PORTB.2 - datalatch PORTD.2 - datastrobe

I can access these by using:

bitSet(PORTB,2); bitSet(PORTD,2);

Which can be improved by using a define:

define datalatch 2

define datastrobe 2

Which means I can use:

bitSet(PORTB,datalatch); bitSet(PORTD,datastrobe);

My question is, is there a way to substitute 'PORTB,2' with a named string constant?

This would mean I could use: bitSet(datalatch);

It makes no difference to the executable code, but makes the code easier to read and especially easier to debug, in the first two cases cut and paste editing can easily result in PORTB and PORTB being incorrectly used and a significant time spent in debugging.


And the reason you aren't using digitalWrite() is?

define is just a simple text replace.