Bluetooth: controller: Move bt_rand into separate file

Move crypto related interface provided by the
software-based Controller bt_rand into separate file,
crypto.c.

Change-id: I9998a43fe45799b479969ca195f324199418b8c2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This commit is contained in:
Vinayak Chettimada 2017-03-15 09:06:07 +01:00 committed by Johan Hedberg
commit 32f03a42c7
3 changed files with 26 additions and 16 deletions

View file

@ -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

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2016-2017 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <soc.h>
#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;
}

View file

@ -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;