[gnoduino: 65/237] Adding pin-change interrupt pin mapping macros to pins_arduino.h. http://code.google.com/p/arduino/i



commit 26528a77ce0bfb1a9e39889ca9d8f0a7bd495df2
Author: David A. Mellis <d mellis arduino cc>
Date:   Fri Aug 12 17:31:22 2011 -0400

    Adding pin-change interrupt pin mapping macros to pins_arduino.h.
    http://code.google.com/p/arduino/issues/detail?id=490

 arduino/pins/mega/pins_arduino.h     |   25 +++++++++++++++++++++++++
 arduino/pins/standard/pins_arduino.h |    5 +++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/arduino/pins/mega/pins_arduino.h b/arduino/pins/mega/pins_arduino.h
index acbd28f..b25f858 100644
--- a/arduino/pins/mega/pins_arduino.h
+++ b/arduino/pins/mega/pins_arduino.h
@@ -53,6 +53,31 @@ const static uint8_t A13 = 67;
 const static uint8_t A14 = 68;
 const static uint8_t A15 = 69;
 
+// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
+// Only pins available for RECEIVE (TRANSMIT can be on any pin):
+// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
+// Pins: 10, 11, 12, 13,  50, 51, 52, 53,  62, 63, 64, 65, 66, 67, 68, 69
+
+#define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 13)) || \
+                                  (((p) >= 50) && ((p) <= 53)) || \
+                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
+
+#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
+                                ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
+                                0 ) )
+
+#define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
+                                ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
+                                ((uint8_t *)0) ) )
+
+#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
+                                ( ((p) == 50) ? 3 : \
+                                ( ((p) == 51) ? 2 : \
+                                ( ((p) == 52) ? 1 : \
+                                ( ((p) == 53) ? 0 : \
+                                ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
+                                0 ) ) ) ) ) )
+
 #ifdef ARDUINO_MAIN
 
 const uint16_t PROGMEM port_to_mode_PGM[] = {
diff --git a/arduino/pins/standard/pins_arduino.h b/arduino/pins/standard/pins_arduino.h
index b42755d..8e25435 100644
--- a/arduino/pins/standard/pins_arduino.h
+++ b/arduino/pins/standard/pins_arduino.h
@@ -45,6 +45,11 @@ const static uint8_t A5 = 19;
 const static uint8_t A6 = 20;
 const static uint8_t A7 = 21;
 
+#define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0))
+#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1))
+#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
+#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
+
 #ifdef ARDUINO_MAIN
 
 // On the Arduino board, digital pins are also used



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