Skip to content

Commit

Permalink
tests: drivers: adc_accuracy: parametrize expected accuracy
Browse files Browse the repository at this point in the history
On nrf boards expected accuracy from ref voltage is 64 instead of 32.

Signed-off-by: Bartlomiej Buczek <[email protected]>
  • Loading branch information
nordic-babu authored and henrikbrixandersen committed Oct 23, 2024
1 parent 008f8ba commit 557b5bd
Show file tree
Hide file tree
Showing 7 changed files with 8 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 0>;
reference_mv = <3300>;
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 = <&adc0 12>;
reference_mv = <1100>;
expected_accuracy = <32>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
zephyr,user {
io-channels = <&adc0 1>;
reference_mv = <1650>;
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 557b5bd

Please sign in to comment.