Skip to content

Commit 96f3de6

Browse files
authored
Merge pull request #13910 from marcemmers/nrf-ble-config
Update NRF ble configuration options
2 parents 7a7f6a5 + 01e56f1 commit 96f3de6

File tree

4 files changed

+26
-47
lines changed

4 files changed

+26
-47
lines changed

connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/mbed_lib.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"value": 1,
5757
"macro_name": "CHCI_TR_CUSTOM"
5858
}
59+
},
60+
"target_overrides": {
61+
"MCU_NRF52840": {
62+
"phy-coded-support": 1,
63+
"extended-advertising-size": 512
64+
}
5965
}
60-
}
66+
}

connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_MCU_NRF52840/mbed_lib.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
{
22
"name": "cordio-ll-nrf52840",
33
"config": {
4-
"phy-coded-support": {
5-
"help": "Coded PHY supported.",
6-
"value": 1
7-
},
8-
"extended-advertising-size": {
9-
"help": "Maximum extended advertising data (and scan data response) size",
10-
"value": 512
11-
},
12-
"max-acl-size": {
13-
"help": "Maximum ACL buffer size",
14-
"value": 256
15-
},
16-
"tx-buffers": {
17-
"help": "Default number of send buffers",
18-
"value": 4
19-
},
204
"cryptocell310-acceleration": {
215
"help": "Should the link layer use the Crypto Cell 310 to offload encryption.",
226
"value": 1

connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,6 @@
5555

5656
using namespace ble;
5757

58-
/*! \brief Memory that should be reserved for the stack. */
59-
#if defined(NRF52840_XXAA)
60-
61-
#undef MBED_CONF_CORDIO_LL_EXTENDED_ADVERTISING_SIZE
62-
#undef MBED_CONF_CORDIO_LL_MAX_ACL_SIZE
63-
#undef MBED_CONF_CORDIO_LL_TX_BUFFERS
64-
#undef MBED_CONF_CORDIO_LL_PHY_CODED_SUPPORT
65-
#define MBED_CONF_CORDIO_LL_EXTENDED_ADVERTISING_SIZE MBED_CONF_CORDIO_LL_NRF52840_EXTENDED_ADVERTISING_SIZE
66-
#define MBED_CONF_CORDIO_LL_MAX_ACL_SIZE MBED_CONF_CORDIO_LL_NRF52840_MAX_ACL_SIZE
67-
#define MBED_CONF_CORDIO_LL_TX_BUFFERS MBED_CONF_CORDIO_LL_NRF52840_TX_BUFFERS
68-
#define MBED_CONF_CORDIO_LL_PHY_CODED_SUPPORT MBED_CONF_CORDIO_LL_NRF52840_PHY_CODED_SUPPORT
69-
70-
#define CORDIO_LL_MEMORY_FOOTPRINT 16056UL
71-
72-
#else
73-
74-
#define CORDIO_LL_MEMORY_FOOTPRINT 12500UL
75-
76-
#endif
77-
7858
/*! \brief Typical implementation revision number (LlRtCfg_t::implRev). */
7959
#define LL_IMPL_REV 0x2303
8060

@@ -202,7 +182,7 @@ extern "C" void TIMER2_IRQHandler(void);
202182

203183
NRFCordioHCIDriver::NRFCordioHCIDriver(CordioHCITransportDriver& transport_driver) : CordioHCIDriver(transport_driver), _is_init(false), _stack_buffer(NULL)
204184
{
205-
_stack_buffer = (uint8_t*)malloc(CORDIO_LL_MEMORY_FOOTPRINT);
185+
_stack_buffer = (uint8_t*)malloc(MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE);
206186
MBED_ASSERT(_stack_buffer != NULL);
207187
}
208188

@@ -233,11 +213,7 @@ NRFCordioHCIDriver::~NRFCordioHCIDriver()
233213
ble::buf_pool_desc_t NRFCordioHCIDriver::get_buffer_pool_description()
234214
{
235215
static union {
236-
#if defined(NRF52840_XXAA)
237-
uint8_t buffer[ 4900 ];
238-
#else
239-
uint8_t buffer[ 4900 ];
240-
#endif
216+
uint8_t buffer[MBED_CONF_CORDIO_NORDIC_LL_WSF_POOL_BUFFER_SIZE];
241217
uint64_t align;
242218
};
243219
static const wsfBufPoolDesc_t pool_desc[] = {
@@ -268,7 +244,7 @@ void NRFCordioHCIDriver::do_initialize()
268244
.plSizeCfg = 4,
269245
.pLlRtCfg = &_ll_cfg,
270246
.pFreeMem = _stack_buffer,
271-
.freeMemAvail = CORDIO_LL_MEMORY_FOOTPRINT
247+
.freeMemAvail = MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE
272248
};
273249

274250
/* switch to more accurate 16 MHz crystal oscillator (system starts up using 16MHz RC oscillator) */
@@ -314,12 +290,12 @@ void NRFCordioHCIDriver::do_initialize()
314290
// WARNING
315291
// If a submodule does not have enough space to allocate its memory from buffer, it will still allocate its memory (and do a buffer overflow) and return 0 (as in 0 byte used)
316292
// however that method will still continue which will lead to undefined behaviour
317-
// So whenever a change of configuration is done, it's a good idea to set CORDIO_LL_MEMORY_FOOTPRINT to a high value and then reduce accordingly
293+
// So whenever a change of configuration is done, it's a good idea to set MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE to a high value and then reduce accordingly
318294
uint32_t mem_used = LlInitControllerInit(&ll_init_cfg);
319-
if( mem_used < CORDIO_LL_MEMORY_FOOTPRINT )
295+
if( mem_used < MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE )
320296
{
321297
// Sub-optimal, give warning
322-
DBG_WARN("NRFCordioHCIDriver: CORDIO_LL_MEMORY_FOOTPRINT can be reduced to %lu instead of %lu", mem_used, CORDIO_LL_MEMORY_FOOTPRINT);
298+
DBG_WARN("NRFCordioHCIDriver: MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE can be reduced to %lu instead of %lu", mem_used, MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE);
323299
}
324300

325301
// BD Addr

connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
"help": "messages sent between Host and Controller are passed directly without copying if enabled. WSF messages ownership is trasfered to the callee.",
66
"value": 1,
77
"macro_name": "CORDIO_ZERO_COPY_HCI"
8+
},
9+
"hci-driver-buffer-size": {
10+
"help": "Defines the memory to be allocated by the NRFCordiHciDriver.",
11+
"value": 12500
12+
},
13+
"wsf-pool-buffer-size": {
14+
"help": "Defines the memory allocated for the wsf memory pool.",
15+
"value": 4900
16+
}
17+
},
18+
"target_overrides": {
19+
"MCU_NRF52840": {
20+
"hci-driver-buffer-size": 16056
821
}
922
},
1023
"macros": [

0 commit comments

Comments
 (0)