1 /*
2 * Copyright (c) 2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/drivers/adc.h>
8 #include <zephyr/ztest.h>
9
10 #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), io_channels)
11 static const struct adc_dt_spec adc_channel = ADC_DT_SPEC_GET(DT_PATH(zephyr_user));
12 #else
13 #error "Unsupported board."
14 #endif
15
get_adc_channel(void)16 const struct adc_dt_spec *get_adc_channel(void)
17 {
18 return &adc_channel;
19 }
20
adc_setup(void)21 static void *adc_setup(void)
22 {
23 int ret;
24
25 zassert_true(adc_is_ready_dt(&adc_channel), "ADC device is not ready");
26 ret = adc_channel_setup_dt(&adc_channel);
27 zassert_equal(ret, 0,
28 "Setting up of the ADC channel failed with code %d", ret);
29
30 return NULL;
31 }
32
33 ZTEST_SUITE(adc_accuracy_test, NULL, adc_setup, NULL, NULL, NULL);
34