Skip to content

Commit d9d85fd

Browse files
Alexander Svensenaescolar
authored andcommitted
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: Alexander Svensen <[email protected]>
1 parent 3d94df7 commit d9d85fd

File tree

1 file changed

+13
-15
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+13
-15
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,23 @@
1414
#include "common/log.h"
1515
#include "hal/debug.h"
1616

17-
#define DRV_NAME DT_NORDIC_NRF_CLOCK_0_LABEL "_32K"
18-
#define K32SRC CLOCK_CONTROL_NRF_K32SRC
19-
20-
static u8_t is_k32src_stable;
21-
2217
void lll_clock_wait(void)
2318
{
24-
if (!is_k32src_stable) {
25-
struct device *clk_k32;
19+
static bool done;
20+
21+
if (done) {
22+
return;
23+
}
24+
done = true;
2625

27-
is_k32src_stable = 1U;
26+
struct device *lf_clock = device_get_binding(
27+
DT_NORDIC_NRF_CLOCK_0_LABEL "_32K");
2828

29-
clk_k32 = device_get_binding(DRV_NAME);
30-
LL_ASSERT(clk_k32);
29+
LL_ASSERT(lf_clock);
3130

32-
while (clock_control_on(clk_k32, (void *)K32SRC)) {
33-
DEBUG_CPU_SLEEP(1);
34-
k_cpu_idle();
35-
DEBUG_CPU_SLEEP(0);
36-
}
31+
while (clock_control_on(lf_clock, (void *)CLOCK_CONTROL_NRF_K32SRC)) {
32+
DEBUG_CPU_SLEEP(1);
33+
k_cpu_idle();
34+
DEBUG_CPU_SLEEP(0);
3735
}
3836
}

0 commit comments

Comments
 (0)