Skip to content

Commit 1417ccc

Browse files
Thinh Le Congduynguyenxa
authored andcommitted
tests: drivers: adc: Add tests support for ADC driver on 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 dd2e08b commit 1417ccc

File tree

7 files changed

+146
-13
lines changed

7 files changed

+146
-13
lines changed

tests/drivers/adc/adc_accuracy_test/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ config NUMBER_OF_PASSES
2323
int "Number of passes"
2424
default 5
2525

26+
config ADC_CALIBRATE_REQUIRED
27+
bool "Require calibrate field in ADC test"
28+
default y if DT_HAS_RENESAS_RA_ADC_ENABLED
29+
2630
if DAC_SOURCE_TEST
2731

2832
config DAC_BUFFER_NOT_SUPPORTED
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 3>;
10+
dac = <&dac0>;
11+
dac-channel-id = <0>;
12+
dac-resolution = <12>;
13+
};
14+
};
15+
16+
&pinctrl {
17+
adc0_default: adc0_default {
18+
group1 {
19+
/* input */
20+
psels = <RA_PSEL(RA_PSEL_ADC, 0, 15)>;
21+
renesas,analog-enable;
22+
};
23+
};
24+
};
25+
26+
&adc0{
27+
#address-cells = <1>;
28+
#size-cells = <0>;
29+
interrupts = <31 1>;
30+
interrupt-names = "scanend";
31+
status = "okay";
32+
33+
/*
34+
* Channel 3 is used in single ended mode, with 15 bit resolution
35+
*/
36+
channel@3 {
37+
reg = <3>;
38+
zephyr,gain = "ADC_GAIN_1";
39+
zephyr,reference = "ADC_REF_EXTERNAL0";
40+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
41+
zephyr,resolution = <15>;
42+
zephyr,vref-mv = <3300>;
43+
};
44+
};

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 CONFIG_ADC_CALIBRATE_REQUIRED
47+
.calibrate = true,
48+
#endif
4649
};
4750

4851
const struct device *dac_dev = init_dac();

tests/drivers/adc/adc_accuracy_test/testcase.yaml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,8 @@ tests:
1212
fixture: dac_adc_loopback
1313
platform_allow:
1414
- frdm_k64f
15-
drivers.adc.accuracy.ref_volt:
16-
harness_config:
17-
fixture: adc_ref_volt
18-
platform_allow:
19-
- frdm_kl25z
20-
- ek_ra8m1
21-
- frdm_mcxc242
22-
- frdm_mcxc444
23-
- nrf52840dk/nrf52840
24-
- nrf54h20dk/nrf54h20/cpuapp
25-
- nrf54l15dk/nrf54l15/cpuapp
26-
- nrf54lm20dk/nrf54lm20a/cpuapp
27-
- ophelia4ev/nrf54l15/cpuapp
2815
- ek_ra8d1
16+
- ek_ra8m1
2917
- mck_ra8t1
3018
- ek_ra6e2
3119
- ek_ra6m1
@@ -36,14 +24,32 @@ tests:
3624
- fpb_ra6e1
3725
- fpb_ra6e2
3826
- ek_ra4e2
27+
- ek_ra4l1
28+
- ek_ra4m1
3929
- ek_ra4m2
4030
- ek_ra4m3
4131
- ek_ra4w1
32+
- fpb_ra4e1
33+
- ek_ra2a1
34+
- ek_ra2l1
35+
drivers.adc.accuracy.ref_volt:
36+
harness_config:
37+
fixture: adc_ref_volt
38+
platform_allow:
39+
- frdm_kl25z
40+
- frdm_mcxc242
41+
- frdm_mcxc444
42+
- nrf52840dk/nrf52840
43+
- nrf54h20dk/nrf54h20/cpuapp
44+
- nrf54l15dk/nrf54l15/cpuapp
45+
- nrf54lm20dk/nrf54lm20a/cpuapp
46+
- ophelia4ev/nrf54l15/cpuapp
4247
- xg24_dk2601b
4348
- xg24_rb4187c
4449
- xg27_dk2602a
4550
- xg29_rb4412a
4651
- bg29_rb4420a
52+
- ek_ra4c1
4753
integration_platforms:
4854
- frdm_kl25z
4955
- nrf54l15dk/nrf54l15/cpuapp

tests/drivers/adc/adc_api/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ config ADC_API_SAMPLE_INTERVAL_US
1313

1414
config ADC_32_BITS_DATA
1515
bool "ADC data is 32-bits long"
16+
17+
config ADC_CALIBRATE_REQUIRED
18+
bool "Require calibrate field in ADC test"
19+
default y if DT_HAS_RENESAS_RA_ADC_ENABLED
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
status = "okay";
26+
#address-cells = <1>;
27+
#size-cells = <0>;
28+
interrupts = <31 1>;
29+
interrupt-names = "scanend";
30+
31+
/*
32+
* Channel 0 is used in single ended mode, with 15 bit resolution
33+
*/
34+
channel@0 {
35+
reg = <0>;
36+
zephyr,gain = "ADC_GAIN_1";
37+
zephyr,reference = "ADC_REF_EXTERNAL0";
38+
zephyr,resolution = <15>;
39+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
40+
zephyr,vref-mv = <3300>;
41+
};
42+
43+
/*
44+
* Channel 1 is used in single ended mode, with 15 bit resolution
45+
*/
46+
channel@1 {
47+
reg = <1>;
48+
zephyr,gain = "ADC_GAIN_1";
49+
zephyr,reference = "ADC_REF_EXTERNAL0";
50+
zephyr,resolution = <15>;
51+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
52+
zephyr,vref-mv = <3300>;
53+
};
54+
};

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 CONFIG_ADC_CALIBRATE_REQUIRED
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 CONFIG_ADC_CALIBRATE_REQUIRED
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 CONFIG_ADC_CALIBRATE_REQUIRED
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 CONFIG_ADC_CALIBRATE_REQUIRED
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 CONFIG_ADC_CALIBRATE_REQUIRED
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 CONFIG_ADC_CALIBRATE_REQUIRED
402+
.calibrate = true,
403+
#endif
386404
};
387405

388406
init_adc();

0 commit comments

Comments
 (0)