Dear All,
I am working on SDK 2.1.0 and I was going through the ADC sample found in ncs/zephyr/samples/drivers/adc directory.
I am working with a custom board, so I want to implement the "overlay" inside the original dts file of the device. The device is effectively a nRF9160 device.
So, what I am trying to do is to create a node that will contain the configuration for the ADC device that I can then later get using
ADC_DT_SPEC_GET.
What I have tried so far is this:
In my XXX_nrf9160_common.dts file I have added the following node (?):
...
&adc {
status = "okay";
};
/{
adc {
#address-cells = <1>;
#size-cells = <0>;
battery: channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN7>;
zephyr,resolution = <12>;
};
};
};
...I am getting this error:
battery_devices.c: In function 'battery_device_init':
C:/ncs/zephyr/include/zephyr/drivers/adc.h:281:41: error: expected expression before '{' token
281 | #define ADC_DT_SPEC_STRUCT(ctlr, input) { \
| ^
C:/ncs/zephyr/include/zephyr/drivers/adc.h:368:2: note: in expansion of macro 'ADC_DT_SPEC_STRUCT'
368 | ADC_DT_SPEC_STRUCT(DT_IO_CHANNELS_CTLR_BY_IDX(node_id, idx), \
| ^~~~~~~~~~~~~~~~~~
C:/ncs/zephyr/include/zephyr/drivers/adc.h:393:34: note: in expansion of macro 'ADC_DT_SPEC_GET_BY_IDX'
393 | #define ADC_DT_SPEC_GET(node_id) ADC_DT_SPEC_GET_BY_IDX(node_id, 0) when doing this:battery_devices->batt_data = ADC_DT_SPEC_GET(battery);.
Thank you very much for your assistance