Skip to content

Commit d338f22

Browse files
committed
Adding basic macros for analog + digital pin information.
http://code.google.com/p/arduino/issues/detail?id=495
1 parent f179794 commit d338f22

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

hardware/arduino/pins/mega/pins_arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727

2828
#include <avr/pgmspace.h>
2929

30+
#define NUM_DIGITAL_PINS 70
31+
#define NUM_ANALOG_INPUTS 16
32+
#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1)
33+
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
34+
3035
const static uint8_t SS = 53;
3136
const static uint8_t MOSI = 51;
3237
const static uint8_t MISO = 50;

hardware/arduino/pins/standard/pins_arduino.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727

2828
#include <avr/pgmspace.h>
2929

30+
#define NUM_DIGITAL_PINS 20
31+
#define NUM_ANALOG_INPUTS 6
32+
#define analogInputToDigitalPin(p) ((p < 6) ? (p) + 14 : -1)
33+
34+
#if defined(__AVR_ATmega8__)
35+
#define digitalPinHasPWM(p) ((p) == 9 || (p) == 10 || (p) == 11)
36+
#else
37+
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
38+
#endif
39+
3040
const static uint8_t SS = 10;
3141
const static uint8_t MOSI = 11;
3242
const static uint8_t MISO = 12;

0 commit comments

Comments
 (0)