diff --git a/targets/nrf5x/jshardware.c b/targets/nrf5x/jshardware.c index 2ae3c69d4b..e2a24348a2 100644 --- a/targets/nrf5x/jshardware.c +++ b/targets/nrf5x/jshardware.c @@ -2805,7 +2805,10 @@ JsVarFloat jshReadVRef() { config.gain = NRF_SAADC_GAIN1_6; // 1/6 of input volts config.mode = NRF_SAADC_MODE_SINGLE_ENDED; -#if defined(NRF52833) || defined(NRF52840) +#if defined(NRF52833) || defined(NRF52840) && !defined(BANGLEJS2) + #define ESPR_VREF_VDDH +#endif +#ifdef ESPR_VREF_VDDH config.pin_p = 0x0D; // Not in Nordic's libs, but this is VDDHDIV5 - we probably want to be looking at VDDH config.pin_n = 0x0D; #else @@ -2829,7 +2832,7 @@ JsVarFloat jshReadVRef() { f = nrf_analog_read() * (6.0 * 0.6 / 16384.0); } while (nrf_analog_read_interrupted); nrf_analog_read_end(adcInUse); -#if defined(NRF52833) || defined(NRF52840) +#ifdef ESPR_VREF_VDDH f *= 5; // we were on VDDHDIV5 #endif