Lines Matching +full:single +full:- +full:ended
4 * SPDX-License-Identifier: Apache-2.0
10 #include <zephyr/dt-bindings/adc/nrf-saadc-v3.h>
11 #include <zephyr/dt-bindings/adc/nrf-saadc-nrf54l.h>
68 "Definitions from nrf-adc.h do not match those from nrf_saadc.h");
112 if (NRF_SAADC_8BIT_SAMPLE_WIDTH == 8 && sequence->resolution == 8) { in samples_to_bytes()
147 result = -EINVAL; in adc_convert_acq_time()
162 tacq = (nrf_saadc_acqtime_t)(acq_time / MINIMUM_ACQ_TIME_IN_NS) - 1; in adc_convert_acq_time()
164 result = -EINVAL; in adc_convert_acq_time()
190 return -ENOTSUP; in saadc_pm_hook()
204 uint8_t channel_id = channel_cfg->channel_id; in adc_nrfx_channel_setup()
205 uint32_t input_negative = channel_cfg->input_negative; in adc_nrfx_channel_setup()
208 return -EINVAL; in adc_nrfx_channel_setup()
211 switch (channel_cfg->gain) { in adc_nrfx_channel_setup()
265 return -EINVAL; in adc_nrfx_channel_setup()
268 switch (channel_cfg->reference) { in adc_nrfx_channel_setup()
286 return -EINVAL; in adc_nrfx_channel_setup()
289 int ret = adc_convert_acq_time(channel_cfg->acquisition_time, &config.acq_time); in adc_nrfx_channel_setup()
293 return -EINVAL; in adc_nrfx_channel_setup()
296 /* Store channel mode to allow correcting negative readings in single-ended mode in adc_nrfx_channel_setup()
299 if (channel_cfg->differential) { in adc_nrfx_channel_setup()
301 m_data.single_ended_channels &= ~BIT(channel_cfg->channel_id); in adc_nrfx_channel_setup()
304 m_data.single_ended_channels |= BIT(channel_cfg->channel_id); in adc_nrfx_channel_setup()
308 if ((channel_cfg->input_positive >= ARRAY_SIZE(saadc_psels)) || in adc_nrfx_channel_setup()
309 (channel_cfg->input_positive < NRF_SAADC_AIN0)) { in adc_nrfx_channel_setup()
310 return -EINVAL; in adc_nrfx_channel_setup()
316 return -EINVAL; in adc_nrfx_channel_setup()
328 m_data.positive_inputs[channel_id] = channel_cfg->input_positive; in adc_nrfx_channel_setup()
351 if (ctx->sequence.calibrate) { in adc_context_start_sampling()
368 samples_to_bytes(&ctx->sequence, nrfy_saadc_amount_get(NRF_SAADC)); in adc_context_update_buffer_pointer()
372 samples_to_bytes(&ctx->sequence, nrfy_saadc_amount_get(NRF_SAADC)); in adc_context_update_buffer_pointer()
382 switch (sequence->resolution) { in set_resolution()
397 sequence->resolution); in set_resolution()
398 return -EINVAL; in set_resolution()
410 if ((active_channels > 1) && (sequence->oversampling > 0)) { in set_oversampling()
412 "Oversampling is supported for single channel only"); in set_oversampling()
413 return -EINVAL; in set_oversampling()
416 switch (sequence->oversampling) { in set_oversampling()
446 sequence->oversampling); in set_oversampling()
447 return -EINVAL; in set_oversampling()
461 if (sequence->options) { in check_buffer_size()
462 needed_buffer_size *= (1 + sequence->options->extra_samplings); in check_buffer_size()
465 if (sequence->buffer_size < needed_buffer_size) { in check_buffer_size()
467 sequence->buffer_size, needed_buffer_size); in check_buffer_size()
468 return -ENOMEM; in check_buffer_size()
476 return sequence->channels & m_data.single_ended_channels; in has_single_ended()
482 uint8_t selected_channels = sequence->channels; in correct_single_ended()
503 uint32_t selected_channels = sequence->channels; in start_read()
504 uint8_t resolution = sequence->resolution; in start_read()
509 * a non-existing one is selected). in start_read()
514 return -EINVAL; in start_read()
531 return -EINVAL; in start_read()
534 * single ended with a resolution which is identical in start_read()
535 * to the sample bit size. The SAADC's "single ended" in start_read()
541 * correct them to 0 after the sequencen has ended. in start_read()
545 LOG_ERR("Channel %u invalid single ended resolution", in start_read()
547 return -EINVAL; in start_read()
553 * event is not generated) after switching to a single in start_read()
559 (sequence->oversampling != 0U ? in start_read()
600 m_data.user_buffer = sequence->buffer; in start_read()
608 (nrf_saadc_value_t *)sequence->buffer, in start_read()