Skip to content

tests: drivers: adc_dma: fix sampling interval failing NXP tests #56104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions tests/drivers/adc/adc_dma/src/test_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) 2018 Nordic Semiconductor ASA
* Copyright (c) 2016 Intel Corporation
* Copyright (c) 2020, NXP
* Copyright (c) 2023, Nobleo Technology
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -23,6 +24,7 @@
#define ADC_1ST_CHANNEL_ID 26
#define COUNTER_NODE_NAME pit0
#define HW_TRIGGER_INTERVAL (2U)
#define SAMPLE_INTERVAL_US HW_TRIGGER_INTERVAL

#elif defined(CONFIG_BOARD_FRDM_K82F)

Expand All @@ -34,6 +36,7 @@
#define ADC_1ST_CHANNEL_ID 26
#define COUNTER_NODE_NAME pit0
#define HW_TRIGGER_INTERVAL (2U)
#define SAMPLE_INTERVAL_US HW_TRIGGER_INTERVAL

#elif defined(CONFIG_BOARD_NUCLEO_H743ZI)

Expand Down Expand Up @@ -64,8 +67,12 @@
#define BUFFER_MEM_REGION EMPTY
#endif

/* for DMA HW trigger interval need large than HW trigger interval*/
#define SAMPLE_INTERVAL_US (10000U)
/* The sample interval between consecutive samplings. Some drivers require
* specific values to function.
*/
#if !defined(SAMPLE_INTERVAL_US)
#define SAMPLE_INTERVAL_US 0
#endif

#define BUFFER_SIZE 24
#ifndef ALIGNMENT
Expand Down Expand Up @@ -284,7 +291,7 @@ static int test_task_asynchronous_call(void)
const struct adc_sequence_options options = {
.extra_samplings = 4,
/* Start consecutive samplings as fast as possible. */
.interval_us = 0,
.interval_us = SAMPLE_INTERVAL_US,
};
const struct adc_sequence sequence = {
.options = &options,
Expand Down Expand Up @@ -348,7 +355,7 @@ static int test_task_with_interval(void)
int64_t milliseconds_spent;

const struct adc_sequence_options options = {
.interval_us = 500UL, /*make this double to sample time*/
.interval_us = 100 * 1000, /* 10 ms - much larger than expected sampling time */
.callback = sample_with_interval_callback,
.extra_samplings = 1,
};
Expand All @@ -372,7 +379,7 @@ static int test_task_with_interval(void)
time_stamp = k_uptime_get();
ret = adc_read(adc_dev, &sequence);
milliseconds_spent = k_uptime_delta(&time_stamp);
printk("now spend = %lldms\n", milliseconds_spent);
zassert_true(milliseconds_spent >= (options.interval_us / 1000UL));
zassert_equal(ret, 0, "adc_read() failed with code %d", ret);
}
check_samples2(1 + options.extra_samplings);
Expand Down Expand Up @@ -438,7 +445,6 @@ static int test_task_repeated_samplings(void)
*/
.extra_samplings = 2,
/* Start consecutive samplings as fast as possible. */
/* but the interval shall be larger than the HW trigger*/
.interval_us = SAMPLE_INTERVAL_US,
};
const struct adc_sequence sequence = {
Expand Down