diff --git a/subsys/bluetooth/controller/ll_sw/Makefile b/subsys/bluetooth/controller/ll_sw/Makefile index c60465a75cc..00f29c77488 100644 --- a/subsys/bluetooth/controller/ll_sw/Makefile +++ b/subsys/bluetooth/controller/ll_sw/Makefile @@ -2,3 +2,4 @@ ccflags-$(CONFIG_BLUETOOTH_LL_SW) += -I$(srctree)/subsys/bluetooth/controller/in ccflags-$(CONFIG_BLUETOOTH_LL_SW) += -I$(srctree)/subsys/bluetooth/controller obj-$(CONFIG_BLUETOOTH_LL_SW) += ctrl.o obj-$(CONFIG_BLUETOOTH_LL_SW) += ll.o +obj-$(CONFIG_BLUETOOTH_LL_SW) += crypto.o diff --git a/subsys/bluetooth/controller/ll_sw/crypto.c b/subsys/bluetooth/controller/ll_sw/crypto.c new file mode 100644 index 00000000000..3fdb1617c21 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/crypto.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016-2017 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "hal/cpu.h" +#include "hal/rand.h" + +K_MUTEX_DEFINE(mutex_rand); + +int bt_rand(void *buf, size_t len) +{ + while (len) { + k_mutex_lock(&mutex_rand, K_FOREVER); + len = rand_get(len, buf); + k_mutex_unlock(&mutex_rand); + if (len) { + cpu_sleep(); + } + } + + return 0; +} diff --git a/subsys/bluetooth/controller/ll_sw/ll.c b/subsys/bluetooth/controller/ll_sw/ll.c index 9deacc891b0..df304a193cc 100644 --- a/subsys/bluetooth/controller/ll_sw/ll.c +++ b/subsys/bluetooth/controller/ll_sw/ll.c @@ -46,8 +46,6 @@ static uint8_t MALIGN(4) _ticker_user_ops[RADIO_TICKER_USER_OPS] [TICKER_USER_OP_T_SIZE]; static uint8_t MALIGN(4) _radio[LL_MEM_TOTAL]; -K_MUTEX_DEFINE(mutex_rand); - static struct k_sem *sem_recv; static struct { @@ -74,20 +72,6 @@ static struct { uint8_t filter_policy:1; } _ll_scan_params; -int bt_rand(void *buf, size_t len) -{ - while (len) { - k_mutex_lock(&mutex_rand, K_FOREVER); - len = rand_get(len, buf); - k_mutex_unlock(&mutex_rand); - if (len) { - cpu_sleep(); - } - } - - return 0; -} - void mayfly_enable_cb(uint8_t caller_id, uint8_t callee_id, uint8_t enable) { (void)caller_id;