aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/wiring_analog.c
diff options
context:
space:
mode:
authorSandeep Mistry <s.mistry@arduino.cc>2016-09-08 15:37:27 -0400
committerSandeep Mistry <s.mistry@arduino.cc>2016-09-08 15:37:27 -0400
commit0f959829ba264a8dabf726048fcee177bd58e1dc (patch)
treee57d12e2f1866f7e5b1b94f0238a4208ad6d75e4 /cores/arduino/wiring_analog.c
parent671619100df5f7a4a4c031c334a1f6f80cff5b92 (diff)
parentbb567ae644b3a2ebbf228e83802a5e7411a1e8eb (diff)
Merge pull request #5300 from mischnic/attiny_anlReference
Add all analog references supported by the ATtinyX5 series
Diffstat (limited to 'cores/arduino/wiring_analog.c')
-rw-r--r--cores/arduino/wiring_analog.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c
index 1a4701a..967c2b9 100644
--- a/cores/arduino/wiring_analog.c
+++ b/cores/arduino/wiring_analog.c
@@ -64,8 +64,12 @@ int analogRead(uint8_t pin)
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
// to 0 (the default).
#if defined(ADMUX)
+#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+ ADMUX = (analog_reference << 4) | (pin & 0x07);
+#else
ADMUX = (analog_reference << 6) | (pin & 0x07);
#endif
+#endif
// without a delay, we seem to read from the wrong channel
//delay(1);