Iam trying to make an easy way of defining my IO. Im trying to do this with macro but I cant solve this problem.
I did this:
// Buzzer PORT and PIN mapping
#define BUZZER_PORT B // PORT
#define BUZZER_PIN 2 // PCR pin
#define BUZZER_ALT 1 // Pin alternativne function
#define INIT_BUZZER(PORTX, PIN, ALT) { PORT##PORTX##_PCR(PIN) = PORT_PCR_MUX((ALT)) | PORT_PCR_DSE_MASK; GPIO##PORTX##_PDDR |= PIN<<1; }
Function call working:
INIT_BUZZER(B, BUZZER_PIN, BUZZER_ALT);
Function call wanted:
INIT_BUZZER(BUZZER_PORT, BUZZER_PIN, BUZZER_ALT);
If I call it with port argument BUZZER_PORT I get an error because compiler doesnt take my arguments value but string itself.
How to deal with this?
Thank you.