Skip to content

Commit c1a17cf

Browse files
hakehuanggalak
authored andcommitted
test: add adc_dma test application
add adc_dma test application enable periodic_trigger flag for adc edma enable for frdm_k64f and frdm_k82f Signed-off-by: Hake Huang <[email protected]>
1 parent 77f27ac commit c1a17cf

File tree

9 files changed

+577
-0
lines changed

9 files changed

+577
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.13.1)
4+
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
6+
project(adc_dma)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2020, NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA=y
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2020, NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
&adc0 {
7+
clk-source = <0>;
8+
hw-trigger-src = <4>;
9+
continuous-convert;
10+
high-speed;
11+
periodic-trigger;
12+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2020, NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA=y
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2020, NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
&adc0 {
7+
clk-source = <0>;
8+
hw-trigger-src = <4>;
9+
continuous-convert;
10+
high-speed;
11+
periodic-trigger;
12+
};

tests/drivers/adc/adc_dma/prj.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CONFIG_ZTEST=y
2+
3+
CONFIG_ADC=y
4+
CONFIG_ADC_ASYNC=y
5+
CONFIG_ADC_LOG_LEVEL_INF=y
6+
CONFIG_HEAP_MEM_POOL_SIZE=1024
7+
CONFIG_TEST_USERSPACE=y
8+
CONFIG_DMA=y
9+
CONFIG_COUNTER=y
10+
CONFIG_ADC_MCUX_ADC16_HW_TRIGGER=y
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2020, NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
8+
#include <zephyr.h>
9+
#include <ztest.h>
10+
11+
extern void test_adc_sample_one_channel(void);
12+
extern void test_adc_sample_two_channels(void);
13+
extern void test_adc_asynchronous_call(void);
14+
extern void test_adc_sample_with_interval(void);
15+
extern void test_adc_repeated_samplings(void);
16+
extern void test_adc_invalid_request(void);
17+
extern const struct device *get_adc_device(void);
18+
extern const struct device *get_count_device(void);
19+
extern struct k_poll_signal async_sig;
20+
21+
void test_main(void)
22+
{
23+
k_object_access_grant(get_adc_device(), k_current_get());
24+
k_object_access_grant(get_count_device(), k_current_get());
25+
#ifdef CONFIG_ADC_ASYNC
26+
k_object_access_grant(&async_sig, k_current_get());
27+
k_poll_signal_init(&async_sig);
28+
k_thread_system_pool_assign(k_current_get());
29+
#endif
30+
31+
ztest_test_suite(adc_dma_test,
32+
ztest_user_unit_test(test_adc_sample_one_channel),
33+
ztest_user_unit_test(test_adc_sample_two_channels),
34+
ztest_user_unit_test(test_adc_asynchronous_call),
35+
ztest_unit_test(test_adc_sample_with_interval),
36+
ztest_unit_test(test_adc_repeated_samplings),
37+
ztest_user_unit_test(test_adc_invalid_request));
38+
ztest_run_test_suite(adc_dma_test);
39+
}

0 commit comments

Comments
 (0)