Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0f95982

Browse files
Merge pull request #5300 from mischnic/attiny_anlReference
Add all analog references supported by the ATtinyX5 series
2 parents 6716191 + bb567ae commit 0f95982

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎cores/arduino/Arduino.h‎

Lines changed: 12 additions & 4 deletions
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 4
72+
#define INTERNAL1V1 8
73+
#define INTERNAL INTERNAL1V1
74+
#define INTERNAL2V56 9
75+
#define INTERNAL2V56_EXTCAP 13
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

‎cores/arduino/wiring_analog.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ 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+
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
68+
ADMUX = (analog_reference << 4) | (pin & 0x07);
69+
#else
6770
ADMUX = (analog_reference << 6) | (pin & 0x07);
71+
#endif
6872
#endif
6973

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /