summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2020-07-24 11:16:56 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-28 01:03:17 +0000
commitb7c6726e22181f57d92e0069c0fc3c4b12b9a773 (patch)
tree909cc2f040e23cfa0f0c7108194b5e81d0d356be /test
parent00d3f2d0d6e864236c217330659dd7801adf8670 (diff)
downloadchrome-ec-b7c6726e22181f57d92e0069c0fc3c4b12b9a773.tar.gz
Make wait_for_ready available for all
wait_for_ready is a generic function which loops until bits in a register are set. This patch move it to util.c to make it available for all. There are more places where the function is applicable but this CL keeps the scope under chip/stm32/clock-stm32. There is no functionality change. BUG=none BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I796599344c1d86ab7144d1d6b434ec54cf1cc55d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317887 Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/interrupt.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/interrupt.c b/test/interrupt.c
index f43c8b2ccd..ca98309e1f 100644
--- a/test/interrupt.c
+++ b/test/interrupt.c
@@ -29,11 +29,20 @@ void my_isr(void)
interrupt_count++;
}
+static volatile uint32_t enable_ready_reg;
+
+static void set_ready_bit(void)
+{
+ if (enable_ready_reg & BIT(0))
+ enable_ready_reg |= BIT(1);
+}
+
void interrupt_generator(void)
{
while (1) {
udelay(3 * PERIOD_US(prng_no_seed()));
task_trigger_test_interrupt(my_isr);
+ task_trigger_test_interrupt(set_ready_bit);
}
}
@@ -71,12 +80,21 @@ static int interrupt_disable_test(void)
return EC_SUCCESS;
}
+static int test_wait_for_ready(void)
+{
+ wait_for_ready(&enable_ready_reg, BIT(0), BIT(1));
+ TEST_EQ(enable_ready_reg, BIT(0) | BIT(1), "%x");
+
+ return EC_SUCCESS;
+}
+
void run_test(int argc, char **argv)
{
test_reset();
RUN_TEST(interrupt_test);
RUN_TEST(interrupt_disable_test);
+ RUN_TEST(test_wait_for_ready);
test_print_result();
}