Created
January 26, 2016 09:30
-
-
Save matthijskooijman/30786c61a08cfa56530c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Arduino.h: | |
#define digitalPinToPort(P) digitalPinToPortFunction(pin); | |
static inline uint8_t digitalPinToPortFunction(uint8_t pin) __attribute__((always_inline)); | |
static inline uint8_t digitalPinToPortFunction(uint8_t pin) { | |
#if !defined(ARDUINO_MAIN) | |
if __builtin_constant_p(pin) | |
return digital_pin_to_port[P]; | |
else | |
#endif | |
return pgm_read_byte( digital_pin_to_port_PGM + pin ); | |
} | |
#ifdef ARDUINO_MAIN | |
#define DIGITAL_PIN_TO_PORT_TABLE const uint8_t PROGMEM digital_pin_to_port_PGM[] | |
#else | |
#define DIGITAL_PIN_TO_PORT_TABLE static const uint8_t PROGMEM digital_pin_to_port[] | |
#endif | |
pins_arduino.h: | |
DIGITAL_PIN_TO_PORT_TABLE = { | |
PD, /* 0 */ | |
PD, | |
etc. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment