Lines Matching +full:valid +full:- +full:channels

4  * SPDX-License-Identifier: Apache-2.0
10 #include <zephyr/dt-bindings/adc/nrf-adc.h>
19 /* Ensure that definitions in nrf-adc.h match MDK. */
28 "Definitions from nrf-adc.h do not match those from nrf_adc.h");
50 uint8_t channel_id = channel_cfg->channel_id; in adc_nrfx_channel_setup()
54 return -EINVAL; in adc_nrfx_channel_setup()
57 if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { in adc_nrfx_channel_setup()
58 LOG_ERR("Selected ADC acquisition time is not valid"); in adc_nrfx_channel_setup()
59 return -EINVAL; in adc_nrfx_channel_setup()
62 if (channel_cfg->differential) { in adc_nrfx_channel_setup()
63 LOG_ERR("Differential channels are not supported"); in adc_nrfx_channel_setup()
64 return -EINVAL; in adc_nrfx_channel_setup()
67 switch (channel_cfg->gain) { in adc_nrfx_channel_setup()
69 config->scaling = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD; in adc_nrfx_channel_setup()
72 config->scaling = NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS; in adc_nrfx_channel_setup()
75 config->scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE; in adc_nrfx_channel_setup()
78 LOG_ERR("Selected ADC gain is not valid"); in adc_nrfx_channel_setup()
79 return -EINVAL; in adc_nrfx_channel_setup()
82 switch (channel_cfg->reference) { in adc_nrfx_channel_setup()
84 config->reference = NRF_ADC_CONFIG_REF_VBG; in adc_nrfx_channel_setup()
85 config->extref = NRF_ADC_CONFIG_EXTREFSEL_NONE; in adc_nrfx_channel_setup()
88 config->reference = NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF; in adc_nrfx_channel_setup()
89 config->extref = NRF_ADC_CONFIG_EXTREFSEL_NONE; in adc_nrfx_channel_setup()
92 config->reference = NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD; in adc_nrfx_channel_setup()
93 config->extref = NRF_ADC_CONFIG_EXTREFSEL_NONE; in adc_nrfx_channel_setup()
96 config->reference = NRF_ADC_CONFIG_REF_EXT; in adc_nrfx_channel_setup()
97 config->extref = NRF_ADC_CONFIG_EXTREFSEL_AREF0; in adc_nrfx_channel_setup()
100 config->reference = NRF_ADC_CONFIG_REF_EXT; in adc_nrfx_channel_setup()
101 config->extref = NRF_ADC_CONFIG_EXTREFSEL_AREF1; in adc_nrfx_channel_setup()
104 LOG_ERR("Selected ADC reference is not valid"); in adc_nrfx_channel_setup()
105 return -EINVAL; in adc_nrfx_channel_setup()
108 config->input = channel_cfg->input_positive; in adc_nrfx_channel_setup()
110 config->resolution = NRF_ADC_CONFIG_RES_8BIT; in adc_nrfx_channel_setup()
139 if (sequence->options) { in check_buffer_size()
140 needed_buffer_size *= (1 + sequence->options->extra_samplings); in check_buffer_size()
143 if (sequence->buffer_size < needed_buffer_size) { in check_buffer_size()
145 sequence->buffer_size, needed_buffer_size); in check_buffer_size()
146 return -ENOMEM; in check_buffer_size()
156 uint32_t selected_channels = sequence->channels; in start_read()
161 /* Signal an error if channel selection is invalid (no channels or in start_read()
162 * a non-existing one is selected). in start_read()
167 LOG_ERR("Invalid selection of channels"); in start_read()
168 return -EINVAL; in start_read()
171 if (sequence->oversampling != 0U) { in start_read()
173 return -EINVAL; in start_read()
176 switch (sequence->resolution) { in start_read()
187 LOG_ERR("ADC resolution value %d is not valid", in start_read()
188 sequence->resolution); in start_read()
189 return -EINVAL; in start_read()
195 /* Enable the channels selected for the pointed sequence. in start_read()
217 m_data.buffer = sequence->buffer; in start_read()
259 if (p_event->type == NRFX_ADC_EVT_DONE) { in event_handler()
272 dev->name); in init_adc()
273 return -EBUSY; in init_adc()