From 868812717f432349f911bc45b4f7945d942388fa Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 9 May 2023 16:22:13 +0200 Subject: [PATCH] nrf: add sample time to ADC This is important for inputs with a high input resistance. In those cases, the sample time needs to be longer. --- src/machine/adc.go | 1 + src/machine/machine_nrf52xxx.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/machine/adc.go b/src/machine/adc.go index 739ca2ed..e4b0cb32 100644 --- a/src/machine/adc.go +++ b/src/machine/adc.go @@ -9,4 +9,5 @@ type ADCConfig struct { Reference uint32 // analog reference voltage (AREF) in millivolts Resolution uint32 // number of bits for a single conversion (e.g., 8, 10, 12) Samples uint32 // number of samples for a single conversion (e.g., 4, 8, 16, 32) + SampleTime uint32 // sample time, in microseconds (µs) } diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index f36a05a6..2989e14d 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -30,7 +30,6 @@ func (a ADC) Configure(config ADCConfig) { var configVal uint32 = nrf.SAADC_CH_CONFIG_RESP_Bypass<