aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorNiklas Mischkulnig <niklas@mischkulnig.de>2016-08-27 11:48:04 +0200
committerNiklas Mischkulnig <niklas@mischkulnig.de>2016-08-27 11:48:04 +0200
commit1a280c0d5b66fecd0ef719ed7e31ad685522c2f5 (patch)
tree587a0671e9a90d7d8b9d2c6c2511c0cc2e7f4093 /cores/arduino
parent04713212a845d690de6d8c85724337a422c76dde (diff)
Add all analog references supported by the ATtinyX5 series
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/Arduino.h16
-rw-r--r--cores/arduino/wiring_analog.c2
2 files changed, 13 insertions, 5 deletions
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h
index f1da68d..e71c9c3 100644
--- a/cores/arduino/Arduino.h
+++ b/cores/arduino/Arduino.h
@@ -61,10 +61,18 @@ void yield(void);
#define FALLING 2
#define RISING 3
-#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
-#define DEFAULT 0
-#define EXTERNAL 1
-#define INTERNAL 2
+#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
+ #define DEFAULT 0
+ #define EXTERNAL 1
+ #define INTERNAL1V1 2
+ #define INTERNAL INTERNAL1V1
+#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+ #define DEFAULT 0
+ #define EXTERNAL 1
+ #define INTERNAL1V1 2
+ #define INTERNAL INTERNAL1V1
+ #define INTERNAL2V56 6
+ #define INTERNAL2V56_EXTCAP 7
#else
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
#define INTERNAL1V1 2
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c
index 1a4701a..c545e6d 100644
--- a/cores/arduino/wiring_analog.c
+++ b/cores/arduino/wiring_analog.c
@@ -64,7 +64,7 @@ int analogRead(uint8_t pin)
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
// to 0 (the default).
#if defined(ADMUX)
- ADMUX = (analog_reference << 6) | (pin & 0x07);
+ ADMUX = ((analog_reference & 0x3) << 6) | ((analog_reference & 0x4) ? 0x10 : 0) | (pin & 0x07);
#endif
// without a delay, we seem to read from the wrong channel