Bluetooth: controller: split: Moved chan map helper functions

Moved Channel Map helper functions into separate file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2020-02-07 15:10:30 +05:30 committed by Carles Cufí
commit 1773274118
6 changed files with 60 additions and 32 deletions

View file

@ -21,7 +21,6 @@ zephyr_library_sources_ifdef(
if(CONFIG_BT_LL_SW_SPLIT)
zephyr_library_sources(
ll_sw/ull.c
ll_sw/lll_chan.c
)
if(CONFIG_BT_BROADCASTER)
zephyr_library_sources(
@ -61,6 +60,12 @@ if(CONFIG_BT_LL_SW_SPLIT)
)
endif()
endif()
if(CONFIG_BT_CONN OR CONFIG_BT_CTLR_ADV_PERIODIC)
zephyr_library_sources(
ll_sw/ull_chan.c
ll_sw/lll_chan.c
)
endif()
zephyr_library_sources_ifdef(
CONFIG_BT_CTLR_FILTER
ll_sw/ull_filter.c

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <zephyr/types.h>
#include "util/util.h"
static uint8_t map[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
static uint8_t count = 37U;
int ull_chan_reset(void)
{
/* initialise connection channel map */
map[0] = 0xFF;
map[1] = 0xFF;
map[2] = 0xFF;
map[3] = 0xFF;
map[4] = 0x1F;
count = 37U;
return 0;
}
uint8_t ull_chan_map_get(uint8_t *chan_map)
{
memcpy(chan_map, map, sizeof(map));
return count;
}
void ull_chan_map_set(uint8_t *chan_map)
{
memcpy(map, chan_map, sizeof(map));
count = util_ones_count_get(map, sizeof(map));
}

View file

@ -0,0 +1,9 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
int ull_chan_reset(void);
uint8_t ull_chan_map_get(uint8_t *chan_map);
void ull_chan_map_set(uint8_t *chan_map);

View file

@ -30,6 +30,7 @@
#include "ull_conn_types.h"
#include "ull_internal.h"
#include "ull_sched_internal.h"
#include "ull_chan_internal.h"
#include "ull_conn_internal.h"
#include "ull_slave_internal.h"
#include "ull_master_internal.h"
@ -154,9 +155,6 @@ static struct {
(CONFIG_BT_CTLR_TX_BUFFERS + CONN_TX_CTRL_BUFFERS)];
} mem_link_tx;
static uint8_t data_chan_map[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
static uint8_t data_chan_count = 37U;
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
static uint16_t default_tx_octets;
static uint16_t default_tx_time;
@ -631,14 +629,6 @@ int ull_conn_reset(void)
disable(handle);
}
/* initialise connection channel map */
data_chan_map[0] = 0xFF;
data_chan_map[1] = 0xFF;
data_chan_map[2] = 0xFF;
data_chan_map[3] = 0xFF;
data_chan_map[4] = 0x1F;
data_chan_count = 37U;
/* Re-initialize the Tx mfifo */
MFIFO_INIT(conn_tx);
@ -656,20 +646,6 @@ int ull_conn_reset(void)
return 0;
}
uint8_t ull_conn_chan_map_cpy(uint8_t *chan_map)
{
memcpy(chan_map, data_chan_map, sizeof(data_chan_map));
return data_chan_count;
}
void ull_conn_chan_map_set(uint8_t *chan_map)
{
memcpy(data_chan_map, chan_map, sizeof(data_chan_map));
data_chan_count = util_ones_count_get(data_chan_map,
sizeof(data_chan_map));
}
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
uint16_t ull_conn_default_tx_octets_get(void)
{
@ -6194,8 +6170,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
break;
}
memcpy(&conn->llcp.chan_map.chm[0], data_chan_map,
sizeof(conn->llcp.chan_map.chm));
ull_chan_map_get(conn->llcp.chan_map.chm);
/* conn->llcp.chan_map.instant = 0; */
conn->llcp.chan_map.initiate = 1U;

View file

@ -63,7 +63,6 @@ struct ll_conn *ll_connected_get(uint16_t handle);
void ll_tx_ack_put(uint16_t handle, struct node_tx *node_tx);
int ull_conn_init(void);
int ull_conn_reset(void);
uint8_t ull_conn_chan_map_cpy(uint8_t *chan_map);
void ull_conn_chan_map_set(uint8_t *chan_map);
uint16_t ull_conn_default_tx_octets_get(void);
uint16_t ull_conn_default_tx_time_get(void);

View file

@ -39,6 +39,7 @@
#include "ull_filter.h"
#include "ull_internal.h"
#include "ull_chan_internal.h"
#include "ull_scan_internal.h"
#include "ull_conn_internal.h"
#include "ull_master_internal.h"
@ -156,8 +157,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
conn_lll->latency_event = 0;
conn_lll->event_counter = 0;
conn_lll->data_chan_count =
ull_conn_chan_map_cpy(conn_lll->data_chan_map);
conn_lll->data_chan_count = ull_chan_map_get(conn_lll->data_chan_map);
util_rand(&hop, sizeof(uint8_t));
conn_lll->data_chan_hop = 5 + (hop % 12);
conn_lll->data_chan_sel = 0;
@ -332,7 +332,7 @@ uint8_t ll_chm_update(uint8_t *chm)
uint16_t handle;
uint8_t ret;
ull_conn_chan_map_set(chm);
ull_chan_map_set(chm);
handle = CONFIG_BT_MAX_CONN;
while (handle--) {