/** * @brief ADC initialization. */ static void adc_config(void) { ret_code_t ret_code; nrf_drv_adc_config_t config = NRF_DRV_ADC_DEFAULT_CONFIG; ret_code = nrf_drv_adc_init(&config, adc_event_handler); APP_ERROR_CHECK(ret_code); nrf_drv_adc_channel_enable(&m_channel_config); }
/** * @brief Configure and initialize the ADC */ static void adc_config(void) { ret_code_t ret_code; nrf_drv_adc_config_t adc_config = NRF_DRV_ADC_DEFAULT_CONFIG; //Get default ADC configuration static nrf_drv_adc_channel_t adc_channel_config = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_2); //Get default ADC channel configuration //Uncomment the following two lines to sample the supply voltage of the nRF51 directly (not from a pin) //adc_channel_config.config.config.input = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD; //adc_channel_config.config.config.ain = NRF_ADC_CONFIG_INPUT_DISABLED; ret_code = nrf_drv_adc_init(&adc_config, adc_event_handler); //Initialize the ADC APP_ERROR_CHECK(ret_code); nrf_drv_adc_channel_enable(&adc_channel_config); //Configure and enable an ADC channel }