Skip to content

Commit 7128cc8

Browse files
committed
tests: drivers: adc_dma: wrap nxp specifc functionality
This test contained NXP specific functions, for example the counter trigger, which is not required for all ADC DMA implementations. Also moved NXP specific kconfigs to appropriate board files Signed-off-by: Hein Wessels <[email protected]>
1 parent 7f07074 commit 7128cc8

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

tests/drivers/adc/adc_dma/boards/frdm_k64f.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
#
66

77
CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA=y
8+
CONFIG_ADC_MCUX_ADC16_HW_TRIGGER=y
9+
CONFIG_COUNTER=y
10+
CONFIG_ADC_ASYNC=y

tests/drivers/adc/adc_dma/boards/frdm_k82f.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
#
66

77
CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA=y
8+
CONFIG_ADC_MCUX_ADC16_HW_TRIGGER=y
9+
CONFIG_COUNTER=y
10+
CONFIG_ADC_ASYNC=y

tests/drivers/adc/adc_dma/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ CONFIG_ZTEST=y
22
CONFIG_ZTEST_NEW_API=y
33

44
CONFIG_ADC=y
5-
CONFIG_ADC_ASYNC=y
65
CONFIG_ADC_LOG_LEVEL_INF=y
76
CONFIG_HEAP_MEM_POOL_SIZE=1024
87
CONFIG_TEST_USERSPACE=y
98
CONFIG_DMA=y
10-
CONFIG_COUNTER=y
11-
CONFIG_ADC_MCUX_ADC16_HW_TRIGGER=y

tests/drivers/adc/adc_dma/src/test_adc.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#define ADC_REFERENCE ADC_REF_INTERNAL
2222
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
2323
#define ADC_1ST_CHANNEL_ID 26
24+
#define COUNTER_NODE_NAME pit0
25+
#define HW_TRIGGER_INTERVAL (2U)
2426

2527
#elif defined(CONFIG_BOARD_FRDM_K82F)
2628

@@ -30,15 +32,19 @@
3032
#define ADC_REFERENCE ADC_REF_INTERNAL
3133
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
3234
#define ADC_1ST_CHANNEL_ID 26
35+
#define COUNTER_NODE_NAME pit0
36+
#define HW_TRIGGER_INTERVAL (2U)
3337

3438
#endif
3539

36-
#define HW_TRIGGER_INTERVAL (2U)
3740
/* for DMA HW trigger interval need large than HW trigger interval*/
3841
#define SAMPLE_INTERVAL_US (10000U)
3942

4043
#define BUFFER_SIZE 24
44+
#ifndef ALIGNMENT
4145
#define ALIGNMENT DMA_BUF_ADDR_ALIGNMENT(DT_NODELABEL(test_dma))
46+
#endif
47+
4248
static ZTEST_BMEM __aligned(ALIGNMENT) int16_t m_sample_buffer[BUFFER_SIZE];
4349
static ZTEST_BMEM __aligned(ALIGNMENT) int16_t m_sample_buffer2[2][BUFFER_SIZE];
4450
static int current_buf_inx;
@@ -78,6 +84,7 @@ const struct device *get_adc_device(void)
7884

7985
const struct device *get_count_device(void)
8086
{
87+
#if defined(COUNTER_NODE_NAME)
8188
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(pit0));
8289

8390
if (!device_is_ready(dev)) {
@@ -86,12 +93,16 @@ const struct device *get_count_device(void)
8693
}
8794

8895
return dev;
96+
#else
97+
return NULL;
98+
#endif
8999
}
90100

91-
static void init_pit(void)
101+
#if defined(COUNTER_NODE_NAME)
102+
static void init_counter(void)
92103
{
93104
int err;
94-
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(pit0));
105+
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(COUNTER_NODE_NAME));
95106
struct counter_top_cfg top_cfg = { .callback = NULL,
96107
.user_data = NULL,
97108
.flags = 0 };
@@ -104,6 +115,7 @@ static void init_pit(void)
104115
zassert_equal(0, err, "%s: Counter failed to set top value (err: %d)",
105116
dev->name, err);
106117
}
118+
#endif
107119

108120
static const struct device *init_adc(void)
109121
{
@@ -126,7 +138,9 @@ static const struct device *init_adc(void)
126138

127139
(void)memset(m_sample_buffer, 0, sizeof(m_sample_buffer));
128140

129-
init_pit();
141+
#if defined(COUNTER_NODE_NAME)
142+
init_counter();
143+
#endif
130144

131145
return adc_dev;
132146
}
@@ -245,7 +259,7 @@ static int test_task_asynchronous_call(void)
245259
const struct adc_sequence_options options = {
246260
.extra_samplings = 4,
247261
/* Start consecutive samplings as fast as possible. */
248-
.interval_us = HW_TRIGGER_INTERVAL,
262+
.interval_us = 0,
249263
};
250264
const struct adc_sequence sequence = {
251265
.options = &options,

0 commit comments

Comments
 (0)