Merge pull request #6022 from andrewleech/nrf_asserts_error

nrf5x: Enable asserts -> mbed_error
pull/7067/head
Anna Bridge 2018-06-04 12:24:58 +01:00 committed by GitHub
commit 2d0e5f04b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 12 deletions

View File

@ -254,10 +254,10 @@ void btle_handler(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);
}
/*!

View File

@ -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

View File

@ -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.

View File

@ -92,8 +92,9 @@ void nrf_drv_adc_uninit(void)
void nrf_drv_adc_channel_enable(nrf_drv_adc_channel_t * const p_channel)
{
ASSERT(mp_state == NRF_DRV_STATE_INITIALIZED);
ASSERT(!is_address_from_stack(p_channel));
ASSERT(m_cb.state == NRF_DRV_STATE_INITIALIZED);
// This assert has been removed as it requires non-existent symbols from linker
//ASSERT(!is_address_from_stack(p_channel));
p_channel->p_next = NULL;
if (m_cb.p_head == NULL)
@ -114,7 +115,7 @@ void nrf_drv_adc_channel_enable(nrf_drv_adc_channel_t * const p_channel)
void nrf_drv_adc_channel_disable(nrf_drv_adc_channel_t * const p_channel)
{
ASSERT(mp_state == NRF_DRV_STATE_INITIALIZED);
ASSERT(m_cb.state == NRF_DRV_STATE_INITIALIZED);
ASSERT(m_cb.p_head);
nrf_drv_adc_channel_t * p_curr_channel = m_cb.p_head;
@ -137,7 +138,7 @@ void nrf_drv_adc_channel_disable(nrf_drv_adc_channel_t * const p_channel)
void nrf_drv_adc_sample(void)
{
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
ASSERT(!nrf_adc_is_busy());
nrf_adc_start();
}
@ -145,7 +146,7 @@ void nrf_drv_adc_sample(void)
ret_code_t nrf_drv_adc_sample_convert(nrf_drv_adc_channel_t const * const p_channel,
nrf_adc_value_t * p_value)
{
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
if(m_cb.state == NRF_DRV_STATE_POWERED_ON)
{
return NRF_ERROR_BUSY;
@ -212,7 +213,7 @@ static bool adc_sample_process()
ret_code_t nrf_drv_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size)
{
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
if(m_cb.state == NRF_DRV_STATE_POWERED_ON)
{
return NRF_ERROR_BUSY;
@ -250,7 +251,7 @@ ret_code_t nrf_drv_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size)
bool nrf_drv_adc_is_busy(void)
{
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
return (m_cb.state == NRF_DRV_STATE_POWERED_ON) ? true : false;
}

View File

@ -48,6 +48,11 @@
#endif
// <h> Board Support
// Enable NRF Asserts when Mbed NDEBUG is not set
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
#define DEBUG_NRF_USER
#endif
//==========================================================
// <q> BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE
@ -4287,6 +4292,7 @@
//==========================================================
// <e> NRF_LOG_ENABLED - Logging module for nRF5 SDK
//==========================================================
#ifndef NRF_LOG_ENABLED
#define NRF_LOG_ENABLED 0
#endif

View File

@ -48,6 +48,11 @@
#endif
// <h> Board Support
// Enable NRF Asserts when Mbed NDEBUG is not set
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
#define DEBUG_NRF_USER
#endif
//==========================================================
// <q> BSP_BTN_BLE_ENABLED - bsp_btn_ble - Button Control for BLE

View File

@ -52,6 +52,10 @@
extern "C" {
#endif
#if !defined(NDEBUG) && !defined(DEBUG_NRF_USER)
#define DEBUG_NRF_USER
#endif
#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)
/** @brief Function for handling assertions.