Skip to content

Commit ade600a

Browse files
committed
[nrf toup] tests: drivers: counter: Add clock stabilization nRF
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 <[email protected]> Signed-off-by: Robert Lubos <[email protected]> (cherry picked from commit 94b7d5a) (cherry-picked from commit 7cf7991) Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent ead42b0 commit ade600a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/drivers/counter/counter_basic_api/src/test_counter.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <kernel.h>
1010
#include <logging/log.h>
1111
LOG_MODULE_REGISTER(test);
12+
#ifdef CONFIG_SOC_FAMILY_NRF
13+
#include <drivers/clock_control/nrf_clock_control.h>
14+
#include <clock_control.h>
15+
#endif
1216

1317
static volatile u32_t top_cnt;
1418
static volatile u32_t alarm_cnt;
@@ -81,6 +85,16 @@ typedef bool (*counter_capability_func_t)(const char *dev_name);
8185

8286
static void counter_setup_instance(const char *dev_name)
8387
{
88+
#ifdef CONFIG_SOC_FAMILY_NRF
89+
struct device *clock =
90+
device_get_binding(DT_INST_0_NORDIC_NRF_CLOCK_LABEL "_32K");
91+
92+
__ASSERT_NO_MSG(clock);
93+
94+
while (clock_control_on(clock, (void *)CLOCK_CONTROL_NRF_K32SRC) != 0) {
95+
/* empty */
96+
}
97+
#endif
8498
alarm_cnt = 0U;
8599
}
86100

0 commit comments

Comments
 (0)