diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/btle/btle.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/btle/btle.cpp index 09091c8326..4cca68fec0 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/btle/btle.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/btle/btle.cpp @@ -402,10 +402,10 @@ void btle_handler(const ble_evt_t *p_ble_evt) gattServer.hwCallback(p_ble_evt); } -/*! @brief Callback when an error occurs inside the SoftDevice */ +/*! @brief Callback when an error occurs inside the SoftDevice or ASSERT in debug*/ void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name) { - ASSERT_TRUE(false, (void) 0); + error("nrf failure at %s:%d", p_file_name, line_num); } #if NRF_SD_BLE_API_VERSION >= 5 diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/README.md b/targets/TARGET_NORDIC/TARGET_NRF5x/README.md index 8c3475e479..e9b82a650d 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/README.md +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/README.md @@ -1,4 +1,4 @@ -# Nordic NRF52 +# Nordic NRF5x ## Adding New Targets Based On Nordic NRF52832 And NRF52840 MCUs @@ -144,6 +144,16 @@ Because each DMA buffer must be at least 5 bytes deep, each buffer is automatica The RTC2 ISR is set at the lowest interrupt priority to ensure that UARTE interrupts take precedence. The last 2 of the 4 RTC channels are used for decoupling UARTE ISR context from Mbed IRQ events. This ensures that any user code will only delay other user callbacks and idle flushing and puts an upper bound on the interrupt handling time for the UARTE ISR. + +#### Asserts + +The nordic asserts have been redirected to mbed error handling when building in debug mode. +The SDK file `mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h` was modified to enable the asserts when NDEBUG is not defined. + +The assert handler is defined in mbed-os/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle.cpp : assert_nrf_callback() which forwards assert failures to thye mbed error() handler. + + + #### Limitations * The UARTE hardware only supports 8-bit, None/Even parity, and 1 stop bit. diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h index 89a3a962ef..cf4a3c0805 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h @@ -48,6 +48,11 @@ #endif // Board Support +// Enable NRF Asserts when Mbed NDEBUG is not set +#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER) +#define DEBUG_NRF_USER +#endif + //========================================================== // BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE @@ -4287,6 +4292,7 @@ //========================================================== // NRF_LOG_ENABLED - Logging module for nRF5 SDK //========================================================== + #ifndef NRF_LOG_ENABLED #define NRF_LOG_ENABLED 0 #endif diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h index 393d9be522..834e199156 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h @@ -48,6 +48,11 @@ #endif // Board Support +// Enable NRF Asserts when Mbed NDEBUG is not set +#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER) +#define DEBUG_NRF_USER +#endif + //========================================================== // BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h index 67c945aa1c..2ec647c87b 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h @@ -76,10 +76,6 @@ extern "C" { void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); //lint -restore -#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER) -#define DEBUG_NRF_USER -#endif - #if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)) #define NRF_ASSERT_PRESENT 1 #else