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 684cafc

Browse files
Merge pull request #190 from facchinm/aref_internal_fix_getter
analogReference: add getter for AR_INTERNAL if defined at variant level
2 parents d0354d4 + 0ce10bf commit 684cafc

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

‎cores/arduino/analog.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,17 @@ float analogReference() {
570570
case ADC_VREF_CONTROL_VREFH0_AVSS0:
571571
// the user must know the voltage he applies from outside
572572
return NAN;
573+
#ifdef AR_INTERNAL_VOLTAGE
574+
case ADC_VREF_CONTROL_IVREF_AVSS0:
575+
return AR_INTERNAL_VOLTAGE;
576+
#endif
573577
default:
574578
#if defined(AVCC_MEASURE_PIN)
575579
if (aref == 0) {
576580
analogReference(AR_INTERNAL);
577581
delayMicroseconds(5);
578582
for (int i = 0; i < 10; i++) {
579-
aref += analogRead(AVCC_MEASURE_PIN) * 1.43f * AVCC_MULTIPLY_FACTOR / (1 << _analogRequestedReadResolution);
583+
aref += analogRead(AVCC_MEASURE_PIN) * AR_INTERNAL_VOLTAGE * AVCC_MULTIPLY_FACTOR / (1 << _analogRequestedReadResolution);
580584
}
581585
aref = aref / 10;
582586
analogReference(AR_DEFAULT);

‎variants/MINIMA/pins_arduino.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ static const uint8_t SS = PIN_SPI_CS;
156156
#define AVCC_MEASURE_PIN 20
157157
#define AVCC_MULTIPLY_FACTOR 8.33
158158

159+
#define AR_INTERNAL_VOLTAGE 1.43f
160+
159161
#define USB_VID (0x2341)
160162
#define USB_PID (0x0069)
161163
#define USB_NAME "UNO R4 Minima"

‎variants/PORTENTA_C33/pins_arduino.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,5 @@ static const uint8_t SS = PIN_SPI_CS;
207207
#define SerialLoRa Serial3
208208

209209
#define RTC_CLOCK_SOURCE RTC_CLOCK_SOURCE_SUBCLK
210+
211+
#define AR_INTERNAL_VOLTAGE 1.18f

‎variants/UNOWIFIR4/pins_arduino.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ static const uint8_t SS = PIN_SPI_CS;
158158
#define AVCC_MEASURE_PIN 20
159159
#define AVCC_MULTIPLY_FACTOR 8.33
160160

161+
#define AR_INTERNAL_VOLTAGE 1.43f
162+
161163
#define USB_VID (0x2341)
162164
#define USB_PID (0x006D)
163165
#define USB_NAME "UNO R4 WiFi"

0 commit comments

Comments
(0)

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