Sorry for my lack in knowledge about preprocess code and macro definition, but i'm trying to work on #define macros in order to make more efficient my avr code. I want to develop a driver routine to manage a 1-wire digital thermometer. My purpose is to obtain a preliminar definition of port and pin registers to be reused in my avr library and i would like to make all these preliminar definitions through macros. I'll explain better:
I'd like to have a definition function like that:
#define (port, pin)
and to use port and pin parameters to define other basic macros like:
#define DRIVER_PORT PORT##port
#define DRIVER_PIN PIN##port##pin
#define DRIVER_DDR DDR##port
So, from here on out i'd be able to use the value DRIVER_PORT to manage input/output/high-z port pins, DRIVER_PIN to read port value and so on...
Googling over, I've produced this non-working code:
[...]
#define define_pin(port,pin) { \
#define DRIVER_PORT PORT##port \
#define DRIVER_PIN PIN##port##pin \
#define DRIVER_PINR PIN##port \
#define DRIVER_DDR DDR##port \
}
[...]
1° question: Is it possible to obtain what i'm pursuing? 2° question: If so, what's the right and best method to obtain that?
Thank's in advance for the help!