aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/pins_arduino.h
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-02-18 10:40:56 -0500
committerDavid A. Mellis <d.mellis@arduino.cc>2011-02-18 10:40:56 -0500
commit63515122ca28d9a60e6aba2948fb01765ca1138e (patch)
tree4fc54101c58590a6c1c7225a60d223797f4e198b /cores/arduino/pins_arduino.h
parentcd050d05d1fa7ae87da68574a9e50edf6ac1ed8f (diff)
Revert "Adding noAnalogWrite() function to disable PWM."
This reverts commit 38d4a34fec6925b29a732d13e200f54ee4b42025.
Diffstat (limited to 'cores/arduino/pins_arduino.h')
-rw-r--r--cores/arduino/pins_arduino.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/cores/arduino/pins_arduino.h b/cores/arduino/pins_arduino.h
index ca6a821..4bf6470 100644
--- a/cores/arduino/pins_arduino.h
+++ b/cores/arduino/pins_arduino.h
@@ -339,6 +339,30 @@ 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) {
+ case 2: return TIMER3B; // PE 4 ** 2 ** PWM2
+ case 3: return TIMER3C; // PE 5 ** 3 ** PWM3
+ case 4: return TIMER0B; // PG 5 ** 4 ** PWM4
+ case 5: return TIMER3A; // PE 3 ** 5 ** PWM5
+ case 6: return TIMER4A; // PH 3 ** 6 ** PWM6
+ case 7: return TIMER4B; // PH 4 ** 7 ** PWM7
+ case 8: return TIMER4C; // PH 5 ** 8 ** PWM8
+ case 9: return TIMER2B; // PH 6 ** 9 ** PWM9
+ case 10: return TIMER2A; // PB 4 ** 10 ** PWM10
+ case 11: return TIMER1A; // PB 5 ** 11 ** PWM11
+ case 12: return TIMER1B; // PB 6 ** 12 ** PWM12
+ case 13: return TIMER0A; // PB 7 ** 13 ** PWM13
+ case 44: return TIMER5C; // PL 5 ** 44 ** D44
+ case 45: return TIMER5B; // PL 4 ** 45 ** D45
+ case 46: return TIMER5A; // PL 3 ** 46 ** D46
+ default: invalidPinSpecified();
+ }
+}
+
#else // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
INLINED volatile uint8_t *inlined_portModeRegister(uint8_t port_index)
@@ -431,6 +455,25 @@ 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) {
+#if defined(__AVR_ATmega8__)
+ case 11: return TIMER2;
+#else
+ case 3: return TIMER2B;
+ case 5: return TIMER0B;
+ case 6: return TIMER0A;
+ case 11: return TIMER2A;
+#endif
+ case 9: return TIMER1A;
+ case 10: return TIMER1B;
+ default: invalidPinSpecified();
+ }
+}
+
#endif // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// Get the bit location within the hardware port of the given virtual pin.