From ca3b62925435fce924556d8d1cb92fc0a3264cf4 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 17 Oct 2019 17:14:18 +0200 Subject: [PATCH] [nrf toup] tests: drivers: counter: Add clock stabilization nRF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xtal LF clock source starts hundreds of milliseconds. When it is not start, test may fail due to wrong timing. Added pending on LF clock being start in test setup. Signed-off-by: Krzysztof Chruscinski Signed-off-by: Robert Lubos (cherry picked from commit 94b7d5affeea5df700c2aa1e3329292fa3b8e8eb) (cherry-picked from commit 7cf799102d9a35781cc09b2f1d515ec2386ad1c4) Signed-off-by: Ioannis Glaropoulos (cherry picked from commit ade600a816779bb71f2e94e0f979b1552d6a9352) Signed-off-by: Martí Bolívar --- .../counter/counter_basic_api/src/test_counter.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/drivers/counter/counter_basic_api/src/test_counter.c b/tests/drivers/counter/counter_basic_api/src/test_counter.c index 862c24d22fc0..29bb733f4c86 100644 --- a/tests/drivers/counter/counter_basic_api/src/test_counter.c +++ b/tests/drivers/counter/counter_basic_api/src/test_counter.c @@ -9,6 +9,10 @@ #include #include LOG_MODULE_REGISTER(test); +#ifdef CONFIG_SOC_FAMILY_NRF +#include +#include +#endif static volatile u32_t top_cnt; static volatile u32_t alarm_cnt; @@ -81,6 +85,16 @@ typedef bool (*counter_capability_func_t)(const char *dev_name); static void counter_setup_instance(const char *dev_name) { +#ifdef CONFIG_SOC_FAMILY_NRF + struct device *clock = + device_get_binding(DT_INST_0_NORDIC_NRF_CLOCK_LABEL "_32K"); + + __ASSERT_NO_MSG(clock); + + while (clock_control_on(clock, (void *)CLOCK_CONTROL_NRF_K32SRC) != 0) { + /* empty */ + } +#endif alarm_cnt = 0U; }