Copy of nRF51822 library
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_error_log.h@37:c29c330d942c, 2014-07-07 (annotated)
- Committer:
- Rohit Grover
- Date:
- Mon Jul 07 13:43:31 2014 +0100
- Revision:
- 37:c29c330d942c
- Parent:
- 0:eff01767de02
changes required to upgrade to V7 of the soft-device
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:eff01767de02 | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
bogdanm | 0:eff01767de02 | 2 | * |
bogdanm | 0:eff01767de02 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
bogdanm | 0:eff01767de02 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
bogdanm | 0:eff01767de02 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
bogdanm | 0:eff01767de02 | 6 | * |
bogdanm | 0:eff01767de02 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
bogdanm | 0:eff01767de02 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
bogdanm | 0:eff01767de02 | 9 | * the file. |
bogdanm | 0:eff01767de02 | 10 | * |
bogdanm | 0:eff01767de02 | 11 | */ |
bogdanm | 0:eff01767de02 | 12 | |
bogdanm | 0:eff01767de02 | 13 | /** @file |
bogdanm | 0:eff01767de02 | 14 | * |
bogdanm | 0:eff01767de02 | 15 | * @defgroup ble_error_log_module Error Log Module |
bogdanm | 0:eff01767de02 | 16 | * @{ |
bogdanm | 0:eff01767de02 | 17 | * @ingroup ble_sdk_lib |
bogdanm | 0:eff01767de02 | 18 | * @brief Module for writing error and stack to flash memory. |
bogdanm | 0:eff01767de02 | 19 | * |
bogdanm | 0:eff01767de02 | 20 | * @details It contains functions for writing an error code, line number, filename/message and |
bogdanm | 0:eff01767de02 | 21 | * the stack to the flash during an error, e.g. in the assert handler. |
bogdanm | 0:eff01767de02 | 22 | * |
bogdanm | 0:eff01767de02 | 23 | */ |
bogdanm | 0:eff01767de02 | 24 | #ifndef BLE_ERROR_LOG_H__ |
bogdanm | 0:eff01767de02 | 25 | #define BLE_ERROR_LOG_H__ |
bogdanm | 0:eff01767de02 | 26 | |
bogdanm | 0:eff01767de02 | 27 | #include <stdint.h> |
bogdanm | 0:eff01767de02 | 28 | #include <stdbool.h> |
bogdanm | 0:eff01767de02 | 29 | #include "ble_flash.h" |
bogdanm | 0:eff01767de02 | 30 | |
bogdanm | 0:eff01767de02 | 31 | #define ERROR_MESSAGE_LENGTH 128 /**< Length of error message to stored. */ |
bogdanm | 0:eff01767de02 | 32 | #define STACK_DUMP_LENGTH 256 /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */ |
bogdanm | 0:eff01767de02 | 33 | #define FLASH_PAGE_ERROR_LOG (BLE_FLASH_PAGE_END - 2) /**< Address in flash where stack trace can be stored. */ |
bogdanm | 0:eff01767de02 | 34 | |
bogdanm | 0:eff01767de02 | 35 | /**@brief Error Log Data structure. |
bogdanm | 0:eff01767de02 | 36 | * |
bogdanm | 0:eff01767de02 | 37 | * @details The structure contains the error, message/filename, line number as well as the current |
bogdanm | 0:eff01767de02 | 38 | * stack, at the time where an error occured. |
bogdanm | 0:eff01767de02 | 39 | */ |
bogdanm | 0:eff01767de02 | 40 | typedef struct |
bogdanm | 0:eff01767de02 | 41 | { |
bogdanm | 0:eff01767de02 | 42 | uint16_t failure; /**< Indication that a major failure has occurred during last execution of the application. */ |
bogdanm | 0:eff01767de02 | 43 | uint16_t line_number; /**< Line number indicating at which line the failure occurred. */ |
bogdanm | 0:eff01767de02 | 44 | uint32_t err_code; /**< Error code when failure occurred. */ |
bogdanm | 0:eff01767de02 | 45 | uint8_t message[ERROR_MESSAGE_LENGTH]; /**< Will just use the first 128 bytes of filename to store for debugging purposes. */ |
bogdanm | 0:eff01767de02 | 46 | uint32_t stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */ |
bogdanm | 0:eff01767de02 | 47 | } ble_error_log_data_t; |
bogdanm | 0:eff01767de02 | 48 | |
bogdanm | 0:eff01767de02 | 49 | |
bogdanm | 0:eff01767de02 | 50 | /**@brief Function for writing the file name/message, line number, and current program stack |
bogdanm | 0:eff01767de02 | 51 | * to flash. |
bogdanm | 0:eff01767de02 | 52 | * |
bogdanm | 0:eff01767de02 | 53 | * @note This function will force the writing to flash, and disregard any radio communication. |
bogdanm | 0:eff01767de02 | 54 | * USE THIS FUNCTION WITH CARE. |
bogdanm | 0:eff01767de02 | 55 | * |
bogdanm | 0:eff01767de02 | 56 | * @param[in] err_code Error code to be logged. |
bogdanm | 0:eff01767de02 | 57 | * @param[in] p_message Message to be written to the flash together with stack dump, usually |
bogdanm | 0:eff01767de02 | 58 | * the file name where the error occured. |
bogdanm | 0:eff01767de02 | 59 | * @param[in] line_number Line number where the error occured. |
bogdanm | 0:eff01767de02 | 60 | * |
bogdanm | 0:eff01767de02 | 61 | * @return NRF_SUCCESS on successful writing of the error log. |
bogdanm | 0:eff01767de02 | 62 | * |
bogdanm | 0:eff01767de02 | 63 | */ |
bogdanm | 0:eff01767de02 | 64 | uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number); |
bogdanm | 0:eff01767de02 | 65 | |
bogdanm | 0:eff01767de02 | 66 | |
bogdanm | 0:eff01767de02 | 67 | #endif /* BLE_ERROR_LOG_H__ */ |
bogdanm | 0:eff01767de02 | 68 | |
bogdanm | 0:eff01767de02 | 69 | /** @} */ |