diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index 259f0503..e0d9d152 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -19,7 +19,21 @@ func InitADC() { // Configure configures an ADC pin to be able to read analog data. func (a ADC) Configure(ADCConfig) { - return // no pin specific setup on nrf52 machine. + // Enable ADC. + // The ADC does not consume a noticeable amount of current simply by being + // enabled. + nrf.SAADC.ENABLE.Set(nrf.SAADC_ENABLE_ENABLE_Enabled << nrf.SAADC_ENABLE_ENABLE_Pos) + + // 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<