SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_error_log.h Source File

ble_error_log.h

Go to the documentation of this file.
00001 /* Copyright (c) 2012 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 /** @file
00014  *
00015  * @defgroup ble_error_log_module Error Log Module
00016  * @{
00017  * @ingroup ble_sdk_lib
00018  * @brief Module for writing error and stack to flash memory.
00019  *
00020  * @details It contains functions for writing an error code, line number, filename/message and
00021  *          the stack to the flash during an error, e.g. in the assert handler.
00022  *
00023  */
00024 #ifndef BLE_ERROR_LOG_H__
00025 #define BLE_ERROR_LOG_H__
00026 
00027 #include <stdint.h>
00028 #include <stdbool.h>
00029 #include "ble_flash.h "
00030 
00031 #define ERROR_MESSAGE_LENGTH  128                                /**< Length of error message to stored. */
00032 #define STACK_DUMP_LENGTH     256                                /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */
00033 #define FLASH_PAGE_ERROR_LOG  (BLE_FLASH_PAGE_END - 2)           /**< Address in flash where stack trace can be stored. */
00034 
00035 /**@brief Error Log Data structure.
00036  *
00037  * @details The structure contains the error, message/filename, line number as well as the current
00038  *          stack, at the time where an error occured.
00039  */
00040 typedef struct
00041 {
00042     uint16_t                  failure;                           /**< Indication that a major failure has occurred during last execution of the application. */
00043     uint16_t                  line_number;                       /**< Line number indicating at which line the failure occurred. */
00044     uint32_t                  err_code;                          /**< Error code when failure occurred. */
00045     uint8_t                   message[ERROR_MESSAGE_LENGTH];     /**< Will just use the first 128 bytes of filename to store for debugging purposes. */
00046     uint32_t                  stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */
00047 } ble_error_log_data_t;
00048 
00049 
00050 /**@brief Function for writing the file name/message, line number, and current program stack
00051  *        to flash.
00052  * 
00053  * @note This function will force the writing to flash, and disregard any radio communication.
00054  *       USE THIS FUNCTION WITH CARE.
00055  *
00056  * @param[in]   err_code    Error code to be logged.
00057  * @param[in]   p_message   Message to be written to the flash together with stack dump, usually
00058  *                          the file name where the error occured.
00059  * @param[in]   line_number Line number where the error occured.
00060  *
00061  * @return      NRF_SUCCESS on successful writing of the error log.
00062  *
00063  */
00064 uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number);
00065 
00066 
00067 #endif /* BLE_ERROR_LOG_H__ */
00068 
00069 /** @} */