I'm using SDK v2.4.2 and trying to measure the voltage on the AIN0 pin of the nRF9160 SoC. The relevant code from my device tree source is as follows:
/ { batt { io-channels = <&adc 0>; }; }; &adc { status = "okay"; #address-cells = <1>; #size-cells = <0>; channel@0 { reg = <0>; zephyr,gain = "ADC_GAIN_1_6"; zephyr,reference = "ADC_REF_INTERNAL"; zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 10)>; zephyr,input-positive = <NRF_SAADC_AIN0>; zephyr,resolution = <12>; zephyr,oversampling = <1>; }; };
In the C source code, I created an adc_dt_spec structure as follows:
static struct adc_dt_spec _batt_spec = ADC_DT_SPEC_GET(DT_PATH(batt));
For some reason, this results in a huge compilation error with hundreds of messages. However, if I simply change batt to zephyr,user in the device tree and accordingly to zephyr_user in the C code, the code compiles. I also noticed that if I want to stick with the name batt, then I must make the node compatible with the voltage-divider binding.
/ { batt { compatible = "voltage-divider"; io-channels = <&adc 0>; output-ohms = <10000000>; full-ohms = <14700000>; }; };
With this, the code compiles without errors. However, I'd like to define some nodes with only the io-channels property as they aren't connected to any voltage dividers on my hardware. Is there a way to do so without being forced to place the node at the path /zephyr,user?