This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADC via DTS on Zephyr

I'm trying out Zephyr on the nRF52 DK, specifically I want to test the ADC drivers. Since things are moving quite fast in the Zephyr development world, there may be some information I'm missing especially given the lack of examples for ADC in the Zephyr tree. In my main function, I attempt the following:

adc_dev = device_get_binding("ADC_0");
if (!adc_dev) {
printk("device_get_binding ADC_0 failed");
return ENODEV;
}

Build command:

cmake -DBOARD=nrf52810_pca10040 ../.. && make

and in my proj.conf I've added CONFIG_ADC=y and CONFIG_ADC_NRFX_SAADC=y. It compiles and runs fine, but device_get_binding returns NULL. This is despite the ADC_0 related #defines seems to be present in generated_dts_board.h. So... how do I obtain the ADC device node in main??

Related