aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/pins_arduino.h
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-02-18 10:41:29 -0500
committerDavid A. Mellis <d.mellis@arduino.cc>2011-02-18 10:41:29 -0500
commit860c6f203103f329d192547c4f62ff2471f99b43 (patch)
treecef1d63cc3361f6ad0be727b8248d181edccded3 /cores/arduino/pins_arduino.h
parent63515122ca28d9a60e6aba2948fb01765ca1138e (diff)
Revert "Changes to optimized digitalWrte(), etc."
This reverts commit aa1f1cbda9d6bb52785f98b40746920853d6579b.
Diffstat (limited to 'cores/arduino/pins_arduino.h')
-rw-r--r--cores/arduino/pins_arduino.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/cores/arduino/pins_arduino.h b/cores/arduino/pins_arduino.h
index 4bf6470..63f4257 100644
--- a/cores/arduino/pins_arduino.h
+++ b/cores/arduino/pins_arduino.h
@@ -339,8 +339,6 @@ 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) {
@@ -455,8 +453,6 @@ 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) {
@@ -481,4 +477,46 @@ 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