Nordic stack and drivers for the mbed BLE API

Dependents:   idd_hw5_bleFanProto

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_debug_assert_handler.cpp Source File

ble_debug_assert_handler.cpp

00001 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013 #include "ble_debug_assert_handler.h "
00014 #include <string.h>
00015 #include "nrf51.h"
00016 #include "ble_error_log.h "
00017 #include "nordic_common.h"
00018 
00019 #define MAX_LENGTH_FILENAME 128     /**< Max length of filename to copy for the debug error handlier. */
00020 
00021 
00022 // WARNING - DO NOT USE THIS FUNCTION IN END PRODUCT. - WARNING
00023 // WARNING -         FOR DEBUG PURPOSES ONLY.         - WARNING
00024 void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
00025 {
00026     // Copying parameters to static variables because parameters may not be accessible in debugger.
00027     static volatile uint8_t  s_file_name[MAX_LENGTH_FILENAME];
00028     static volatile uint16_t s_line_num;
00029     static volatile uint32_t s_error_code;    
00030         
00031     strncpy((char *)s_file_name, (const char *)p_file_name, MAX_LENGTH_FILENAME - 1);
00032     s_file_name[MAX_LENGTH_FILENAME - 1] = '\0';
00033     s_line_num                           = line_num;
00034     s_error_code                         = error_code;
00035     UNUSED_VARIABLE(s_file_name);
00036     UNUSED_VARIABLE(s_line_num);
00037     UNUSED_VARIABLE(s_error_code);    
00038 
00039     // WARNING: The PRIMASK register is set to disable ALL interrups during writing the error log.
00040     // 
00041     // Do not use __disable_irq() in normal operation.
00042     __disable_irq();
00043 
00044     // This function will write error code, filename, and line number to the flash.
00045     // In addition, the Cortex-M0 stack memory will also be written to the flash.
00046     //(void) ble_error_log_write(error_code, p_file_name, line_num);
00047 
00048     // For debug purposes, this function never returns.
00049     // Attach a debugger for tracing the error cause.
00050     for (;;)
00051     {
00052         // Do nothing.
00053     }
00054 }
00055