Skip to content

Commit a0e6fe3

Browse files
heinwesselscarlescufi
authored andcommitted
tests: drivers: adc_dma: add nucleo_h743zi
Adds nucleo_h732zi ADC DMA unit tests with multiple channels. The STM32 ADC DMA driver requires the buffers to be placed in a non-cacheable memory region as defined by the DMA. Therefore this adds configurability to the test to change the region the buffer is placed in. Signed-off-by: Hein Wessels <[email protected]>
1 parent 9d314fa commit a0e6fe3

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2023 Nobleo Technology
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
CONFIG_ADC_STM32_DMA=y
8+
CONFIG_ADC_ASYNC=y
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2023 Nobleo Technology
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
&adc1 {
7+
dmas = < &dmamux1 0 9 (STM32_DMA_PERIPH_TO_MEMORY |
8+
STM32_DMA_MEM_INC | STM32_DMA_MEM_16BITS | STM32_DMA_PERIPH_16BITS) >;
9+
dma-names = "dmamux";
10+
11+
#address-cells = <1>;
12+
#size-cells = <0>;
13+
14+
channel@1 {
15+
reg = <1>;
16+
zephyr,gain = "ADC_GAIN_1";
17+
zephyr,reference = "ADC_REF_INTERNAL";
18+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
19+
zephyr,resolution = <12>;
20+
};
21+
};
22+
23+
/* ADC driver expects a buffer in a non-cachable memory region */
24+
&sram4 {
25+
zephyr,memory-region-mpu = "RAM_NOCACHE";
26+
};
27+
28+
&dma1 {
29+
status = "okay";
30+
};
31+
32+
test_dma: &dmamux1 {
33+
status = "okay";
34+
};

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,33 @@
3535
#define COUNTER_NODE_NAME pit0
3636
#define HW_TRIGGER_INTERVAL (2U)
3737

38+
#elif defined(CONFIG_BOARD_NUCLEO_H743ZI)
39+
40+
#define ADC_DEVICE_NODE DT_INST(0, st_stm32_adc)
41+
#define ADC_RESOLUTION 12
42+
#define ADC_GAIN ADC_GAIN_1
43+
#define ADC_REFERENCE ADC_REF_INTERNAL
44+
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
45+
#define ADC_1ST_CHANNEL_ID 1
46+
#define ADC_2ND_CHANNEL_ID 7
47+
#define ALIGNMENT 32
48+
#define BUFFER_MEM_REGION __attribute__((__section__(".sram4")))
49+
50+
#endif
51+
52+
/* Invalid value that is not supposed to be written by the driver. It is used
53+
* to mark the sample buffer entries as empty. If needed, it can be overridden
54+
* for a particular board by providing a specific definition above.
55+
*/
56+
#if !defined(INVALID_ADC_VALUE)
57+
#define INVALID_ADC_VALUE SHRT_MIN
58+
#endif
59+
60+
/* Memory region where buffers will be placed. By default placed in ZTEST_BMEM
61+
* but can be overwritten for a particular board.
62+
*/
63+
#if !defined(BUFFER_MEM_REGION)
64+
#define BUFFER_MEM_REGION EMPTY
3865
#endif
3966

4067
/* for DMA HW trigger interval need large than HW trigger interval*/
@@ -45,8 +72,8 @@
4572
#define ALIGNMENT DMA_BUF_ADDR_ALIGNMENT(DT_NODELABEL(test_dma))
4673
#endif
4774

48-
static __aligned(ALIGNMENT) int16_t m_sample_buffer[BUFFER_SIZE];
49-
static __aligned(ALIGNMENT) int16_t m_sample_buffer2[2][BUFFER_SIZE];
75+
static BUFFER_MEM_REGION __aligned(ALIGNMENT) int16_t m_sample_buffer[BUFFER_SIZE];
76+
static BUFFER_MEM_REGION __aligned(ALIGNMENT) int16_t m_sample_buffer2[2][BUFFER_SIZE];
5077
static int current_buf_inx;
5178

5279
#if defined(CONFIG_ADC_ASYNC)

0 commit comments

Comments
 (0)