Skip to content

Commit

Permalink
[nrf fromlist] tests: drivers: adc_accuracy: parametrize expected acc…
Browse files Browse the repository at this point in the history
…uracy

On nrf boards expected accuracy from ref voltage is 64 instead of 32.

Upstream PR: zephyrproject-rtos/zephyr#76088

Signed-off-by: Bartlomiej Buczek <[email protected]>
  • Loading branch information
nordic-babu committed Jul 23, 2024
1 parent d27c6c4 commit db037cd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
zephyr,user {
io-channels = <&adc0 12>;
reference_mv = <1100>;
expected_accuracy = <32>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
zephyr,user {
io-channels = <&adc 0>;
reference_mv = <3000>;
expected_accuracy = <32>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
zephyr,user {
io-channels = <&adc 0>;
reference_mv = <1800>;
expected_accuracy = <64>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
zephyr,user {
io-channels = <&adc 0>;
reference_mv = <1800>;
expected_accuracy = <64>;
};
};

Expand Down
3 changes: 2 additions & 1 deletion tests/drivers/adc/adc_accuracy_test/src/ref_volt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <zephyr/ztest.h>

#define REF_V DT_PROP(DT_PATH(zephyr_user), reference_mv)
#define EXP_ACC DT_PROP(DT_PATH(zephyr_user), expected_accuracy)

extern const struct adc_dt_spec *get_adc_channel(void);

Expand All @@ -31,7 +32,7 @@ static int test_ref_to_adc(void)
ret = adc_raw_to_millivolts_dt(adc_channel, &sample_buffer);
zassert_equal(ret, 0, "adc_raw_to_millivolts_dt() failed with code %d",
ret);
zassert_within(sample_buffer, REF_V, 32,
zassert_within(sample_buffer, REF_V, EXP_ACC,
"Value %d mV read from ADC does not match expected range (%d mV).",
sample_buffer, REF_V);

Expand Down

0 comments on commit db037cd

Please sign in to comment.