Using C macros is it possible to extract the port information from the text of the pin name and use it to set the port and ddr. If it were possible to pull the "D" from the second character of PD1 you could use it to make PORTD out of PORT+character.
For example:
#define DDR(x) (something) #define PORT(x) (something) #define PIN(x) (something) #define CLK PD0 #define SWITCH PB3 void foo() { DDR( CLK) |= (1<<CLK); // set clock pin for output DDR( SWITCH) &= ~(1<<SWITCH);; // set switch pin for input PORT( SWITCH) |= (1<<SWITCH); // set switch pullup PORT( CLK) ^= (1<<CLK); // toggle clock output if( PIN( SWITCH) & (1<<SWITCH)) { // blah, blah } }
Is something like that possible?