2
2
* Copyright (c) 2018 Nordic Semiconductor ASA
3
3
* Copyright (c) 2016 Intel Corporation
4
4
* Copyright (c) 2020, NXP
5
+ * Copyright (c) 2023, Nobleo Technology
5
6
*
6
7
* SPDX-License-Identifier: Apache-2.0
7
8
*/
23
24
#define ADC_1ST_CHANNEL_ID 26
24
25
#define COUNTER_NODE_NAME pit0
25
26
#define HW_TRIGGER_INTERVAL (2U)
27
+ #define SAMPLE_INTERVAL_US HW_TRIGGER_INTERVAL
26
28
27
29
#elif defined(CONFIG_BOARD_FRDM_K82F )
28
30
34
36
#define ADC_1ST_CHANNEL_ID 26
35
37
#define COUNTER_NODE_NAME pit0
36
38
#define HW_TRIGGER_INTERVAL (2U)
39
+ #define SAMPLE_INTERVAL_US HW_TRIGGER_INTERVAL
37
40
38
41
#elif defined(CONFIG_BOARD_NUCLEO_H743ZI )
39
42
64
67
#define BUFFER_MEM_REGION EMPTY
65
68
#endif
66
69
67
- /* for DMA HW trigger interval need large than HW trigger interval*/
68
- #define SAMPLE_INTERVAL_US (10000U)
70
+ /* The sample interval between consecutive samplings. Some drivers require
71
+ * specific values to function.
72
+ */
73
+ #if !defined(SAMPLE_INTERVAL_US )
74
+ #define SAMPLE_INTERVAL_US 0
75
+ #endif
69
76
70
77
#define BUFFER_SIZE 24
71
78
#ifndef ALIGNMENT
@@ -284,7 +291,7 @@ static int test_task_asynchronous_call(void)
284
291
const struct adc_sequence_options options = {
285
292
.extra_samplings = 4 ,
286
293
/* Start consecutive samplings as fast as possible. */
287
- .interval_us = 0 ,
294
+ .interval_us = SAMPLE_INTERVAL_US ,
288
295
};
289
296
const struct adc_sequence sequence = {
290
297
.options = & options ,
@@ -348,7 +355,7 @@ static int test_task_with_interval(void)
348
355
int64_t milliseconds_spent ;
349
356
350
357
const struct adc_sequence_options options = {
351
- .interval_us = 500UL , /*make this double to sample time*/
358
+ .interval_us = 100 * 1000 , /* 10 ms - much larger than expected sampling time */
352
359
.callback = sample_with_interval_callback ,
353
360
.extra_samplings = 1 ,
354
361
};
@@ -372,7 +379,7 @@ static int test_task_with_interval(void)
372
379
time_stamp = k_uptime_get ();
373
380
ret = adc_read (adc_dev , & sequence );
374
381
milliseconds_spent = k_uptime_delta (& time_stamp );
375
- printk ( "now spend = %lldms\n" , milliseconds_spent );
382
+ zassert_true ( milliseconds_spent >= ( options . interval_us / 1000UL ) );
376
383
zassert_equal (ret , 0 , "adc_read() failed with code %d" , ret );
377
384
}
378
385
check_samples2 (1 + options .extra_samplings );
@@ -438,7 +445,6 @@ static int test_task_repeated_samplings(void)
438
445
*/
439
446
.extra_samplings = 2 ,
440
447
/* Start consecutive samplings as fast as possible. */
441
- /* but the interval shall be larger than the HW trigger*/
442
448
.interval_us = SAMPLE_INTERVAL_US ,
443
449
};
444
450
const struct adc_sequence sequence = {
0 commit comments