Commit d9d85fd1 authored by Alexander Svensen's avatar Alexander Svensen Committed by Alberto Escolar
Browse files

Bluetooth: controller: split: Refactor the lll_clock_wait() function



This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:

Don't use the preprocessor when unprocessed C language suffices.

Don't undefine macro's.

Avoid global variables when possible.

Use consistent names for similiar things (hf_clock, lf_clock).

Signed-off-by: default avatarAlexander Svensen <alsv@nordicsemi.no>
parent 3d94df7e
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -14,25 +14,23 @@
#include "common/log.h"
#include "hal/debug.h"

#define DRV_NAME DT_NORDIC_NRF_CLOCK_0_LABEL "_32K"
#define K32SRC   CLOCK_CONTROL_NRF_K32SRC

static u8_t is_k32src_stable;

void lll_clock_wait(void)
{
	if (!is_k32src_stable) {
		struct device *clk_k32;
	static bool done;

		is_k32src_stable = 1U;
	if (done) {
		return;
	}
	done = true;

		clk_k32 = device_get_binding(DRV_NAME);
		LL_ASSERT(clk_k32);
	struct device *lf_clock = device_get_binding(
		DT_NORDIC_NRF_CLOCK_0_LABEL "_32K");

		while (clock_control_on(clk_k32, (void *)K32SRC)) {
	LL_ASSERT(lf_clock);

	while (clock_control_on(lf_clock, (void *)CLOCK_CONTROL_NRF_K32SRC)) {
		DEBUG_CPU_SLEEP(1);
		k_cpu_idle();
		DEBUG_CPU_SLEEP(0);
	}
}
}