Skip to content

Commit 4972267

Browse files
author
Thinh Le Cong
committed
tests: drivers: adc: Add tests support for ADC driver on Renesas EK-RA2A1 board
Add Renesas EK-RA2A1 board support for these tests: - tests/drivers/adc/adc_api - tests/drivers/adc/adc_accuracy_test Signed-off-by: Thinh Le Cong <[email protected]>
1 parent 553bef0 commit 4972267

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_DAC_BUFFER_NOT_SUPPORTED=y
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2024-2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
zephyr,user {
9+
io-channels = <&adc0 2>;
10+
reference-mv = <3300>;
11+
expected-accuracy = <32>;
12+
};
13+
};
14+
15+
&pinctrl {
16+
adc0_default: adc0_default {
17+
group1 {
18+
/* input */
19+
psels = <RA_PSEL(RA_PSEL_ADC, 5, 2)>;
20+
renesas,analog-enable;
21+
};
22+
};
23+
};
24+
25+
&adc0{
26+
pinctrl-0 = <&adc0_default>;
27+
pinctrl-names = "default";
28+
#address-cells = <1>;
29+
#size-cells = <0>;
30+
interrupts = <31 1>;
31+
interrupt-names = "scanend";
32+
status = "okay";
33+
34+
/*
35+
* Channel 2 is used in single ended mode, with 15 bit resolution
36+
*/
37+
channel@2 {
38+
reg = <2>;
39+
zephyr,gain = "ADC_GAIN_1";
40+
zephyr,reference = "ADC_REF_EXTERNAL0";
41+
zephyr,acquisition-time = <0>;
42+
zephyr,resolution = <15>;
43+
zephyr,vref-mv = <3300>;
44+
};
45+
};

tests/drivers/adc/adc_accuracy_test/src/dac_source.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static int test_dac_to_adc(void)
4343
struct adc_sequence sequence = {
4444
.buffer = &sample_buffer,
4545
.buffer_size = sizeof(sample_buffer),
46+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
47+
.calibrate = true,
48+
#endif
4649
};
4750

4851
const struct device *dac_dev = init_dac();
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
zephyr,user {
9+
io-channels = <&adc0 0>, <&adc0 1>;
10+
};
11+
};
12+
13+
&pinctrl {
14+
adc0_default: adc0_default {
15+
group1 {
16+
/* input */
17+
psels = <RA_PSEL(RA_PSEL_ADC, 5, 0)>,
18+
<RA_PSEL(RA_PSEL_ADC, 5, 1)>;
19+
renesas,analog-enable;
20+
};
21+
};
22+
};
23+
24+
&adc0 {
25+
pinctrl-0 = <&adc0_default>;
26+
pinctrl-names = "default";
27+
status = "okay";
28+
#address-cells = <1>;
29+
#size-cells = <0>;
30+
interrupts = <31 1>;
31+
interrupt-names = "scanend";
32+
33+
/*
34+
* Channel 0 is used in single ended mode, with 15 bit resolution
35+
*/
36+
channel@0 {
37+
reg = <0>;
38+
zephyr,gain = "ADC_GAIN_1";
39+
zephyr,reference = "ADC_REF_EXTERNAL0";
40+
zephyr,resolution = <15>;
41+
zephyr,acquisition-time = <0>;
42+
zephyr,vref-mv = <3300>;
43+
};
44+
45+
channel@1 {
46+
reg = <1>;
47+
zephyr,gain = "ADC_GAIN_1";
48+
zephyr,reference = "ADC_REF_EXTERNAL0";
49+
zephyr,resolution = <15>;
50+
zephyr,acquisition-time = <0>;
51+
zephyr,vref-mv = <3300>;
52+
};
53+
};

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ static int test_task_one_channel(void)
136136
struct adc_sequence sequence = {
137137
.buffer = m_sample_buffer,
138138
.buffer_size = sizeof(m_sample_buffer),
139+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
140+
.calibrate = true,
141+
#endif
139142
};
140143

141144
init_adc();
@@ -163,6 +166,9 @@ static int test_task_multiple_channels(void)
163166
struct adc_sequence sequence = {
164167
.buffer = m_sample_buffer,
165168
.buffer_size = sizeof(m_sample_buffer),
169+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
170+
.calibrate = true,
171+
#endif
166172
};
167173

168174
init_adc();
@@ -210,6 +216,9 @@ static int test_task_asynchronous_call(void)
210216
.options = &options,
211217
.buffer = m_sample_buffer,
212218
.buffer_size = sizeof(m_sample_buffer),
219+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
220+
.calibrate = true,
221+
#endif
213222
};
214223
struct k_poll_event async_evt =
215224
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
@@ -272,6 +281,9 @@ static int test_task_with_interval(void)
272281
.options = &options,
273282
.buffer = m_sample_buffer,
274283
.buffer_size = sizeof(m_sample_buffer),
284+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
285+
.calibrate = true,
286+
#endif
275287
};
276288

277289
init_adc();
@@ -349,6 +361,9 @@ static int test_task_repeated_samplings(void)
349361
.options = &options,
350362
.buffer = m_sample_buffer,
351363
.buffer_size = sizeof(m_sample_buffer),
364+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
365+
.calibrate = true,
366+
#endif
352367
};
353368

354369
init_adc();
@@ -383,6 +398,9 @@ static int test_task_invalid_request(void)
383398
.buffer = m_sample_buffer,
384399
.buffer_size = sizeof(m_sample_buffer),
385400
.resolution = 0, /* intentionally invalid value */
401+
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_adc)
402+
.calibrate = true,
403+
#endif
386404
};
387405

388406
init_adc();

0 commit comments

Comments
 (0)