diff options
author | Niklas Mischkulnig <niklas@mischkulnig.de> | 2016-09-07 19:02:48 +0200 |
---|---|---|
committer | Niklas Mischkulnig <niklas@mischkulnig.de> | 2016-09-07 19:02:48 +0200 |
commit | bb567ae644b3a2ebbf228e83802a5e7411a1e8eb (patch) | |
tree | 1fc2621b7e1d7faae4acd0117dca6b2ddd98007a /cores/arduino/wiring_analog.c | |
parent | 1a280c0d5b66fecd0ef719ed7e31ad685522c2f5 (diff) |
Requested changes to not change code for non ATtinyX5s
Diffstat (limited to 'cores/arduino/wiring_analog.c')
-rw-r--r-- | cores/arduino/wiring_analog.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index c545e6d..967c2b9 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -64,7 +64,11 @@ 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 & 0x3) << 6) | ((analog_reference & 0x4) ? 0x10 : 0) | (pin & 0x07); +#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 |