I’m trying to use the Arduino IDE on several ATMega 169P devices and there for am trying to modify the pins_arduino.h file for this chip.
When looking at the pins_arduino.h used for the standard boards all the pin and port array things are straight forward even for me as an beginner, but I can’t make out the logic in the following part of the code:
#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0)) #define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) #define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
I do understand the function of PCICR and PCMSK for the pinchange interupt, but don’t understand the pin/bit definition with the use of “<=”, “?”,">=", etc.
I hope someone can explain how the statemens are constructed so I can understand how to construct my own in realtion to the datasheet of the ATmega169P.
Manny thanks in advance.