Dear Nordic Community
I am trying to get the nrfx adc driver to work with zephyr (link). With the help of this post, I ended up with the following code:
prj.conf ->
CONFIG_ADC=n CONFIG_NRFX_SAADC=y
main.c ->
#include <zephyr.h>
#include <nrfx_adc.h>
struct nrfx_adc_channel_s spec_ana_ch;
void adc_init(){
//Setup ADC
nrfx_adc_init(NRFX_ADC_DEFAULT_CONFIG,NULL);
spec_ana_ch.config.resolution = NRF_ADC_CONFIG_RES_10BIT;
spec_ana_ch.config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
spec_ana_ch.config.extref = NRF_ADC_CONFIG_EXTREFSEL_NONE;
spec_ana_ch.config.reference = NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF;
spec_ana_ch.config.input = SPEC_ANA_CH;
nrfx_adc_channel_enable(&spec_ana_ch);
}
/**@brief Function for application main entry.
*/
void main(void) {
// Init Board
adc_init();
}but compiling fails with the following croped error message:
In file included from C:\Users\raffa\Github\ncs\modules\hal\nordic\nrfx\drivers\include\nrfx_adc.h:38,
from C:\Users\raffa\Github\ncs\modules\hal\nordic\nrfx\drivers\src\nrfx_adc.c:38:
C:\Users\raffa\Github\ncs\modules\hal\nordic\nrfx\hal\nrf_adc.h:54:29: error: 'ADC_INTENSET_END_Msk' undeclared here (not in a function); did you mean 'PDM_INTENSET_END_Msk'?
54 | NRF_ADC_INT_END_MASK = ADC_INTENSET_END_Msk, /**< ADC interrupt on END event. */
| ^~~~~~~~~~~~~~~~~~~~
| PDM_INTENSET_END_Msk
C:\Users\raffa\Github\ncs\modules\hal\nordic\nrfx\hal\nrf_adc.h:60:32: error: 'ADC_CONFIG_RES_8bit' undeclared here (not in a function)
60 | NRF_ADC_CONFIG_RES_8BIT = ADC_CONFIG_RES_8bit, /**< 8-bit resolution. */
| ^~~~~~~~~~~~~~~~~~~
C:\Users\raffa\Github\ncs\modules\hal\nordic\nrfx\hal\nrf_adc.h:61:32: error: 'ADC_CONFIG_RES_9bit' undeclared here (not in a function); did you mean 'NRF_ADC_CONFIG_RES_8BIT'?
61 | NRF_ADC_CONFIG_RES_9BIT = ADC_CONFIG_RES_9bit, /**< 9-bit resolution. */
| ^~~~~~~~~~~~~~~~~~~
| NRF_ADC_CONFIG_RES_8BIT
I did some research and found out that the missing declaration of ADC_CONFIG_RES_8bit should happen in the soc-specific bitfields header file, as defined in nrf51_bitfields.h.
But this file only gets included when there is a nRF51 SOC used. So is the file nrf_adc.h is not usabel with newer SOCs than nRF51?
Thanks for your help in advance.
My enviroment is:
-- Zephyr version: 2.6.99 (C:/Users/raffa/Github/ncs/zephyr), build: v2.6.99-ncs1-1