From e82f595f371d29ba1c963ba849c60ca59e8b5193 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 9 May 2023 15:49:41 +0200 Subject: [PATCH] nrf: add ability to set the reference voltage The reference voltage can't be 3.3V, so we pick 3.0V as this was the previous default. --- src/machine/machine_nrf52xxx.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index e0d9d152..f36a05a6 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -18,7 +18,7 @@ func InitADC() { } // Configure configures an ADC pin to be able to read analog data. -func (a ADC) Configure(ADCConfig) { +func (a ADC) Configure(config ADCConfig) { // Enable ADC. // The ADC does not consume a noticeable amount of current simply by being // enabled. @@ -27,13 +27,35 @@ func (a ADC) Configure(ADCConfig) { // Configure ADC. nrf.SAADC.RESOLUTION.Set(nrf.SAADC_RESOLUTION_VAL_12bit) - // Configure channel 0, which is the only channel we use. - nrf.SAADC.CH[0].CONFIG.Set(nrf.SAADC_CH_CONFIG_RESP_Bypass<