From 26e6e7ad1f43909013f672b24f7f9a26800f0701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Thu, 1 Oct 2020 14:04:00 +0200 Subject: [PATCH] drivers: adc: Improve the default routine providing sampling intervals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This part of common code for ADC drivers, the adc_context_enable_timer() function, was still converting sampling interval values to milliseconds (the only option available at the time this code has been created) when setting up the kernel timer, consequently limiting the maximum sampling frequency to 1000 samples per second. This patch switches the routine to specifying the interval in microseconds, to remove this limitation. Signed-off-by: Andrzej Głąbek --- drivers/adc/adc_context.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/adc/adc_context.h b/drivers/adc/adc_context.h index 8138a142767..ea5a96c9ec8 100644 --- a/drivers/adc/adc_context.h +++ b/drivers/adc/adc_context.h @@ -92,10 +92,7 @@ static inline void adc_context_request_next_sampling(struct adc_context *ctx) #ifdef ADC_CONTEXT_USES_KERNEL_TIMER static inline void adc_context_enable_timer(struct adc_context *ctx) { - uint32_t interval_us = ctx->options.interval_us; - uint32_t interval_ms = ceiling_fraction(interval_us, 1000UL); - - k_timer_start(&ctx->timer, K_NO_WAIT, K_MSEC(interval_ms)); + k_timer_start(&ctx->timer, K_NO_WAIT, K_USEC(ctx->options.interval_us)); } static inline void adc_context_disable_timer(struct adc_context *ctx)