Lines Matching +full:one +full:- +full:timer +full:- +full:only
5 * SPDX-License-Identifier: Apache-2.0
22 * - adc_context_start_sampling() that will be called when a sampling (of one
24 * - adc_context_update_buffer_pointer() that will be called when the sample
33 * If a given driver uses some dedicated hardware timer to trigger consecutive
36 * this module that utilize a standard kernel timer.
58 struct k_timer timer; member
77 ._ctx_name.timer = Z_TIMER_INITIALIZER(_data._ctx_name.timer, \
95 k_timer_init(&ctx->timer, adc_context_on_timer_expired, NULL); in adc_context_init()
97 k_sem_init(&ctx->lock, 0, 1); in adc_context_init()
98 k_sem_init(&ctx->sync, 0, 1); in adc_context_init()
103 if (atomic_inc(&ctx->sampling_requested) == 0) { in adc_context_request_next_sampling()
108 * do not start another one from here, this will be done from in adc_context_request_next_sampling()
113 ctx->status = -EBUSY; in adc_context_request_next_sampling()
120 k_timer_start(&ctx->timer, K_NO_WAIT, K_USEC(ctx->options.interval_us)); in adc_context_enable_timer()
125 k_timer_stop(&ctx->timer); in adc_context_disable_timer()
131 CONTAINER_OF(timer_id, struct adc_context, timer); in adc_context_on_timer_expired()
141 k_sem_take(&ctx->lock, K_FOREVER); in adc_context_lock()
144 ctx->asynchronous = asynchronous; in adc_context_lock()
145 ctx->signal = signal; in adc_context_lock()
152 if (ctx->asynchronous && (status == 0)) { in adc_context_release()
157 k_sem_give(&ctx->lock); in adc_context_release()
162 if (!k_sem_count_get(&ctx->lock)) { in adc_context_unlock_unconditionally()
163 k_sem_give(&ctx->lock); in adc_context_unlock_unconditionally()
170 if (ctx->asynchronous) { in adc_context_wait_for_completion()
175 int status = k_sem_take(&ctx->sync, ADC_CONTEXT_WAIT_FOR_COMPLETION_TIMEOUT); in adc_context_wait_for_completion()
178 ctx->status = status; in adc_context_wait_for_completion()
181 return ctx->status; in adc_context_wait_for_completion()
191 if (ctx->asynchronous) { in adc_context_complete()
192 if (ctx->signal) { in adc_context_complete()
193 k_poll_signal_raise(ctx->signal, status); in adc_context_complete()
196 k_sem_give(&ctx->lock); in adc_context_complete()
202 * Override the status only when an error is signaled to this function. in adc_context_complete()
207 ctx->status = status; in adc_context_complete()
209 k_sem_give(&ctx->sync); in adc_context_complete()
215 ctx->sequence = *sequence; in adc_context_start_read()
216 ctx->status = 0; in adc_context_start_read()
218 if (sequence->options) { in adc_context_start_read()
219 ctx->options = *sequence->options; in adc_context_start_read()
220 ctx->sequence.options = &ctx->options; in adc_context_start_read()
221 ctx->sampling_index = 0U; in adc_context_start_read()
223 if (ctx->options.interval_us != 0U) { in adc_context_start_read()
224 atomic_set(&ctx->sampling_requested, 0); in adc_context_start_read()
234 * This function should be called after a sampling (of one or more channels,
241 if (ctx->sequence.options) { in adc_context_on_sampling_done()
242 adc_sequence_callback callback = ctx->options.callback; in adc_context_on_sampling_done()
249 &ctx->sequence, in adc_context_on_sampling_done()
250 ctx->sampling_index); in adc_context_on_sampling_done()
263 if (ctx->sampling_index < in adc_context_on_sampling_done()
264 ctx->options.extra_samplings) { in adc_context_on_sampling_done()
265 ++ctx->sampling_index; in adc_context_on_sampling_done()
276 * a zero interval or if the timer expired again while in adc_context_on_sampling_done()
279 if (ctx->options.interval_us == 0U) { in adc_context_on_sampling_done()
281 } else if (atomic_dec(&ctx->sampling_requested) > 1) { in adc_context_on_sampling_done()
288 if (ctx->options.interval_us != 0U) { in adc_context_on_sampling_done()