[gnoduino: 66/237] Adding basic macros for analog + digital pin information. http://code.google.com/p/arduino/issues/de



commit 68033fe82721df89371d9c8046f8e96f75f12bc4
Author: David A. Mellis <d mellis arduino cc>
Date:   Fri Aug 12 18:27:00 2011 -0400

    Adding basic macros for analog + digital pin information.
    http://code.google.com/p/arduino/issues/detail?id=495

 arduino/pins/mega/pins_arduino.h     |    5 +++++
 arduino/pins/standard/pins_arduino.h |   10 ++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/arduino/pins/mega/pins_arduino.h b/arduino/pins/mega/pins_arduino.h
index b25f858..237173a 100644
--- a/arduino/pins/mega/pins_arduino.h
+++ b/arduino/pins/mega/pins_arduino.h
@@ -27,6 +27,11 @@
 
 #include <avr/pgmspace.h>
 
+#define NUM_DIGITAL_PINS            70
+#define NUM_ANALOG_INPUTS           16
+#define analogInputToDigitalPin(p)  ((p < 16) ? (p) + 54 : -1)
+#define digitalPinHasPWM(p)         (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
+
 const static uint8_t SS   = 53;
 const static uint8_t MOSI = 51;
 const static uint8_t MISO = 50;
diff --git a/arduino/pins/standard/pins_arduino.h b/arduino/pins/standard/pins_arduino.h
index 8e25435..3999d1f 100644
--- a/arduino/pins/standard/pins_arduino.h
+++ b/arduino/pins/standard/pins_arduino.h
@@ -27,6 +27,16 @@
 
 #include <avr/pgmspace.h>
 
+#define NUM_DIGITAL_PINS            20
+#define NUM_ANALOG_INPUTS           6
+#define analogInputToDigitalPin(p)  ((p < 6) ? (p) + 14 : -1)
+
+#if defined(__AVR_ATmega8__)
+#define digitalPinHasPWM(p)         ((p) == 9 || (p) == 10 || (p) == 11)
+#else
+#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
+#endif
+
 const static uint8_t SS   = 10;
 const static uint8_t MOSI = 11;
 const static uint8_t MISO = 12;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]