Hello, guys!
My goal is to monitor battery voltage by using a voltage divider and ADC peripheral of nRF51822 SoC. I find that this example perfectly fits my needs. Consequently, I included the device tree node that describes the voltage divider for battery monitoring:
/ {
vbatt {
compatible = "voltage-divider";
io-channels = <&adc 6>;
output-ohms = <1000>;
full-ohms = <(1000 + 3000)>;
power-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
};
};
prj.conf file contains the following ADC-related line:
CONFIG_ADC=y
However, when I try to build the example, I get the Unsupported ADC error that is a consequence of this part of the code (in battery.c file):
#ifdef CONFIG_ADC_NRFX_SAADC
*accp = (struct adc_channel_cfg){
.gain = BATTERY_ADC_GAIN,
.reference = ADC_REF_INTERNAL,
.acquisition_time = ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40),
};
if (cfg->output_ohm != 0) {
accp->input_positive = SAADC_CH_PSELP_PSELP_AnalogInput0
+ iocp->channel;
} else {
accp->input_positive = SAADC_CH_PSELP_PSELP_VDD;
}
asp->resolution = 14;
#else /* CONFIG_ADC_var */
#error Unsupported ADC
#endif /* CONFIG_ADC_var */
I tried including CONFIG_NRFX_SAADC=y or CONFIG_ADC_NRFX_SAADC=y lines in prj.conf file but to no avail. Adding #include <nrfx_saadc.h> in battery.c file did not help as well.
Do you have any idea what I am missing here in order to be able to compile and try this example with nRF51822 SoC?
Thanks in advance for your time and efforts.
Cheers
Bojan.