From 91e45d60f1693ed61c93c0163b7c30d6168cc7d9 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 2 Jan 2024 18:27:18 +0000 Subject: [PATCH] don't read VDDH on Bangle.js 2 as per https://github.com/espruino/Espruino/commit/eabd13cfb8ce1c0a81708bb6e9f37f15b101a5fd#commitcomment-135446714 --- targets/nrf5x/jshardware.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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