Skip to content

Commit 5d15f09

Browse files
committed
Add all analog references supported by the ATtinyX5 series
1 parent e3177a5 commit 5d15f09

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

hardware/arduino/avr/cores/arduino/Arduino.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ void yield(void);
6161
#define FALLING 2
6262
#define RISING 3
6363

64-
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
65-
#define DEFAULT 0
66-
#define EXTERNAL 1
67-
#define INTERNAL 2
64+
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
65+
#define DEFAULT 0
66+
#define EXTERNAL 1
67+
#define INTERNAL1V1 2
68+
#define INTERNAL INTERNAL1V1
69+
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
70+
#define DEFAULT 0
71+
#define EXTERNAL 1
72+
#define INTERNAL1V1 2
73+
#define INTERNAL INTERNAL1V1
74+
#define INTERNAL2V56 6
75+
#define INTERNAL2V56_EXTCAP 7
6876
#else
6977
#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__)
7078
#define INTERNAL1V1 2

hardware/arduino/avr/cores/arduino/wiring_analog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int analogRead(uint8_t pin)
6464
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
6565
// to 0 (the default).
6666
#if defined(ADMUX)
67-
ADMUX = (analog_reference << 6) | (pin & 0x07);
67+
ADMUX = ((analog_reference & 0x3) << 6) | ((analog_reference & 0x4) ? 0x10 : 0) | (pin & 0x07);
6868
#endif
6969

7070
// without a delay, we seem to read from the wrong channel

0 commit comments

Comments
 (0)