Skip to content

Commit 67140a2

Browse files
committed
Redirect NRF asserts to mbed error() in TARGET_NRF5x and SDK 14.2
Add related details to TARGET_NRF5x Readme's
1 parent 5bb3ede commit 67140a2

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/btle/btle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ static void btle_handler(ble_evt_t *p_ble_evt)
449449
gattServer.hwCallback(p_ble_evt);
450450
}
451451

452-
/*! @brief Callback when an error occurs inside the SoftDevice */
452+
/*! @brief Callback when an error occurs inside the SoftDevice or ASSERT in debug*/
453453
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
454454
{
455-
ASSERT_TRUE(false, (void) 0);
455+
error("nrf failure at %s:%d", p_file_name, line_num);
456456
}
457457

458458
#if NRF_SD_BLE_API_VERSION >= 5

targets/TARGET_NORDIC/TARGET_NRF5x/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Nordic NRF52
1+
# Nordic NRF5x
22

33
## Adding New Targets Based On Nordic NRF52832 And NRF52840 MCUs
44

@@ -144,6 +144,16 @@ Because each DMA buffer must be at least 5 bytes deep, each buffer is automatica
144144

145145
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.
146146

147+
148+
#### Asserts
149+
150+
The nordic asserts have been redirected to mbed error handling when building in debug mode.
151+
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.
152+
153+
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.
154+
155+
156+
147157
#### Limitations
148158

149159
* The UARTE hardware only supports 8-bit, None/Even parity, and 1 stop bit.

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
#endif
4949
// <h> Board Support
5050

51+
// Enable NRF Asserts when Mbed NDEBUG is not set
52+
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
53+
#define DEBUG_NRF_USER
54+
#endif
55+
5156
//==========================================================
5257
// <q> BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE
5358

@@ -4287,6 +4292,7 @@
42874292
//==========================================================
42884293
// <e> NRF_LOG_ENABLED - Logging module for nRF5 SDK
42894294
//==========================================================
4295+
42904296
#ifndef NRF_LOG_ENABLED
42914297
#define NRF_LOG_ENABLED 0
42924298
#endif

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
#endif
4949
// <h> Board Support
5050

51+
// Enable NRF Asserts when Mbed NDEBUG is not set
52+
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
53+
#define DEBUG_NRF_USER
54+
#endif
55+
5156
//==========================================================
5257
// <q> BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE
5358

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nrf_assert.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ extern "C" {
7676
void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name);
7777
//lint -restore
7878

79-
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
80-
#define DEBUG_NRF_USER
81-
#endif
82-
8379
#if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER))
8480
#define NRF_ASSERT_PRESENT 1
8581
#else

0 commit comments

Comments
 (0)