From f4c8c37b7b4a618574f8255b7b089b34f44a247e Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 9 May 2023 16:46:50 +0200 Subject: [PATCH] nrf: add ADC oversampling support This is a lot easier to support than on other chips, and results in noticeably better output when set to a higher value. --- src/machine/machine_nrf52xxx.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index 2989e14dd..c4605d582 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -24,7 +24,8 @@ func (a ADC) Configure(config ADCConfig) { // enabled. nrf.SAADC.ENABLE.Set(nrf.SAADC_ENABLE_ENABLE_Enabled << nrf.SAADC_ENABLE_ENABLE_Pos) - // Configure ADC. + // Use fixed resolution of 12 bits. + // TODO: is it useful for users to change this? nrf.SAADC.RESOLUTION.Set(nrf.SAADC_RESOLUTION_VAL_12bit) var configVal uint32 = nrf.SAADC_CH_CONFIG_RESP_Bypass<