Skip to content

Commit

Permalink
[nrf toup] tests: drivers: counter: Add clock stabilization nRF
Browse files Browse the repository at this point in the history
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 <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 94b7d5a)
(cherry-picked from commit 7cf7991)
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information
ioannisg committed Oct 17, 2019
1 parent ead42b0 commit ade600a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/drivers/counter/counter_basic_api/src/test_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <kernel.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(test);
#ifdef CONFIG_SOC_FAMILY_NRF
#include <drivers/clock_control/nrf_clock_control.h>
#include <clock_control.h>
#endif

static volatile u32_t top_cnt;
static volatile u32_t alarm_cnt;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ade600a

Please sign in to comment.