diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/mbed_lib.json b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/mbed_lib.json index 6f82ad050d..6693c854f0 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/mbed_lib.json +++ b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/mbed_lib.json @@ -56,5 +56,11 @@ "value": 1, "macro_name": "CHCI_TR_CUSTOM" } + }, + "target_overrides": { + "MCU_NRF52840": { + "phy-coded-support": 1, + "extended-advertising-size": 512 + } } -} \ No newline at end of file +} diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_MCU_NRF52840/mbed_lib.json b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_MCU_NRF52840/mbed_lib.json index 23b0bbba6d..9e0745c38e 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_MCU_NRF52840/mbed_lib.json +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_MCU_NRF52840/mbed_lib.json @@ -1,22 +1,6 @@ { "name": "cordio-ll-nrf52840", "config": { - "phy-coded-support": { - "help": "Coded PHY supported.", - "value": 1 - }, - "extended-advertising-size": { - "help": "Maximum extended advertising data (and scan data response) size", - "value": 512 - }, - "max-acl-size": { - "help": "Maximum ACL buffer size", - "value": 256 - }, - "tx-buffers": { - "help": "Default number of send buffers", - "value": 4 - }, "cryptocell310-acceleration": { "help": "Should the link layer use the Crypto Cell 310 to offload encryption.", "value": 1 diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp index 2b64190341..5a059c3332 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp @@ -55,26 +55,6 @@ using namespace ble; -/*! \brief Memory that should be reserved for the stack. */ -#if defined(NRF52840_XXAA) - -#undef MBED_CONF_CORDIO_LL_EXTENDED_ADVERTISING_SIZE -#undef MBED_CONF_CORDIO_LL_MAX_ACL_SIZE -#undef MBED_CONF_CORDIO_LL_TX_BUFFERS -#undef MBED_CONF_CORDIO_LL_PHY_CODED_SUPPORT -#define MBED_CONF_CORDIO_LL_EXTENDED_ADVERTISING_SIZE MBED_CONF_CORDIO_LL_NRF52840_EXTENDED_ADVERTISING_SIZE -#define MBED_CONF_CORDIO_LL_MAX_ACL_SIZE MBED_CONF_CORDIO_LL_NRF52840_MAX_ACL_SIZE -#define MBED_CONF_CORDIO_LL_TX_BUFFERS MBED_CONF_CORDIO_LL_NRF52840_TX_BUFFERS -#define MBED_CONF_CORDIO_LL_PHY_CODED_SUPPORT MBED_CONF_CORDIO_LL_NRF52840_PHY_CODED_SUPPORT - -#define CORDIO_LL_MEMORY_FOOTPRINT 16056UL - -#else - -#define CORDIO_LL_MEMORY_FOOTPRINT 12500UL - -#endif - /*! \brief Typical implementation revision number (LlRtCfg_t::implRev). */ #define LL_IMPL_REV 0x2303 @@ -202,7 +182,7 @@ extern "C" void TIMER2_IRQHandler(void); NRFCordioHCIDriver::NRFCordioHCIDriver(CordioHCITransportDriver& transport_driver) : CordioHCIDriver(transport_driver), _is_init(false), _stack_buffer(NULL) { - _stack_buffer = (uint8_t*)malloc(CORDIO_LL_MEMORY_FOOTPRINT); + _stack_buffer = (uint8_t*)malloc(MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE); MBED_ASSERT(_stack_buffer != NULL); } @@ -233,11 +213,7 @@ NRFCordioHCIDriver::~NRFCordioHCIDriver() ble::buf_pool_desc_t NRFCordioHCIDriver::get_buffer_pool_description() { static union { - #if defined(NRF52840_XXAA) - uint8_t buffer[ 4900 ]; - #else - uint8_t buffer[ 4900 ]; - #endif + uint8_t buffer[MBED_CONF_CORDIO_NORDIC_LL_WSF_POOL_BUFFER_SIZE]; uint64_t align; }; static const wsfBufPoolDesc_t pool_desc[] = { @@ -268,7 +244,7 @@ void NRFCordioHCIDriver::do_initialize() .plSizeCfg = 4, .pLlRtCfg = &_ll_cfg, .pFreeMem = _stack_buffer, - .freeMemAvail = CORDIO_LL_MEMORY_FOOTPRINT + .freeMemAvail = MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE }; /* switch to more accurate 16 MHz crystal oscillator (system starts up using 16MHz RC oscillator) */ @@ -314,12 +290,12 @@ void NRFCordioHCIDriver::do_initialize() // WARNING // 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) // however that method will still continue which will lead to undefined behaviour - // 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 + // 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 uint32_t mem_used = LlInitControllerInit(&ll_init_cfg); - if( mem_used < CORDIO_LL_MEMORY_FOOTPRINT ) + if( mem_used < MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE ) { // Sub-optimal, give warning - DBG_WARN("NRFCordioHCIDriver: CORDIO_LL_MEMORY_FOOTPRINT can be reduced to %lu instead of %lu", mem_used, CORDIO_LL_MEMORY_FOOTPRINT); + 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); } // BD Addr diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json index d642cc0364..05e5a45eee 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json @@ -5,6 +5,19 @@ "help": "messages sent between Host and Controller are passed directly without copying if enabled. WSF messages ownership is trasfered to the callee.", "value": 1, "macro_name": "CORDIO_ZERO_COPY_HCI" + }, + "hci-driver-buffer-size": { + "help": "Defines the memory to be allocated by the NRFCordiHciDriver.", + "value": 12500 + }, + "wsf-pool-buffer-size": { + "help": "Defines the memory allocated for the wsf memory pool.", + "value": 4900 + } + }, + "target_overrides": { + "MCU_NRF52840": { + "hci-driver-buffer-size": 16056 } }, "macros": [