From eed15e48d68d10426e015515ec4143849739f2de Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 11 Feb 2011 19:29:46 -0500 Subject: Changes to optimized digitalWrte(), etc. Factoring out the implementation of digitalWrite(), digitalRead(), and pinMode() into macros that can either be inlined (for constant pin numbers) or executed within a function (non-constant pins). Removing testing for timers on pins in digitalWrite(), digitalRead(), and pinMode(). Moving pin to port macros from pins_arduino.h to wiring.h. --- cores/arduino/pins_arduino.h | 46 ++++---------------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'cores/arduino/pins_arduino.h') diff --git a/cores/arduino/pins_arduino.h b/cores/arduino/pins_arduino.h index 63f4257..4bf6470 100644 --- a/cores/arduino/pins_arduino.h +++ b/cores/arduino/pins_arduino.h @@ -339,6 +339,8 @@ INLINED uint8_t inlined_digitalPinToBitMask(uint8_t pin) } } +// XXX: this needs to return false (or -1) if the pin doesn't have a timer, +// rather than throwing a compilation error. INLINED uint8_t inlined_digitalPinToTimer(uint8_t pin) { switch(pin) { @@ -453,6 +455,8 @@ INLINED uint8_t inlined_digitalPinToBitMask(uint8_t pin) } } +// XXX: this needs to return false (or -1) if the pin doesn't have a timer, +// rather than throwing a compilation error. INLINED uint8_t inlined_digitalPinToTimer(uint8_t pin) { switch(pin) { @@ -477,46 +481,4 @@ INLINED uint8_t inlined_digitalPinToTimer(uint8_t pin) #define analogInPinToBit(P) (P) -INLINED uint8_t digitalPinToPort(uint8_t pin) { - if (__builtin_constant_p(pin)) - return inlined_digitalPinToPort(pin); - else - return pgm_read_byte( digital_pin_to_port_PGM + pin ); -} - -INLINED uint8_t digitalPinToBitMask(uint8_t pin) { - if (__builtin_constant_p(pin)) - return inlined_digitalPinToBitMask(pin); - else - return pgm_read_byte( digital_pin_to_bit_mask_PGM + pin ); -} - -INLINED uint8_t digitalPinToTimer(uint8_t pin) { - if (__builtin_constant_p(pin)) - return inlined_digitalPinToTimer(pin); - else - return pgm_read_byte( digital_pin_to_timer_PGM + pin ); -} - -INLINED volatile uint8_t *portOutputRegister(uint8_t index) { - if (__builtin_constant_p(index)) - return inlined_portOutputRegister(index); - else - return (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + index ) ); -} - -INLINED volatile uint8_t* portInputRegister(uint8_t index) { - if (__builtin_constant_p(index)) - return inlined_portInputRegister(index); - else - return (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + index) ); -} - -INLINED volatile uint8_t* portModeRegister(uint8_t index) { - if (__builtin_constant_p(index)) - return inlined_portModeRegister(index); - else - return (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + index) ); -} - #endif -- cgit v1.2.3-18-g5258