Copy of nRF51822 library
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_error_log.h@0:eff01767de02, 2014-03-26 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Mar 26 14:38:17 2014 +0000
- Revision:
- 0:eff01767de02
- Child:
- 37:c29c330d942c
Initial import of the nRF51822 code
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 | #include "nordic_global.h" |
bogdanm | 0:eff01767de02 | 31 | |
bogdanm | 0:eff01767de02 | 32 | #define ERROR_MESSAGE_LENGTH 128 /**< Length of error message to stored. */ |
bogdanm | 0:eff01767de02 | 33 | #define STACK_DUMP_LENGTH 256 /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */ |
bogdanm | 0:eff01767de02 | 34 | #define FLASH_PAGE_ERROR_LOG (BLE_FLASH_PAGE_END - 2) /**< Address in flash where stack trace can be stored. */ |
bogdanm | 0:eff01767de02 | 35 | |
bogdanm | 0:eff01767de02 | 36 | /**@brief Error Log Data structure. |
bogdanm | 0:eff01767de02 | 37 | * |
bogdanm | 0:eff01767de02 | 38 | * @details The structure contains the error, message/filename, line number as well as the current |
bogdanm | 0:eff01767de02 | 39 | * stack, at the time where an error occured. |
bogdanm | 0:eff01767de02 | 40 | */ |
bogdanm | 0:eff01767de02 | 41 | typedef struct |
bogdanm | 0:eff01767de02 | 42 | { |
bogdanm | 0:eff01767de02 | 43 | uint16_t failure; /**< Indication that a major failure has occurred during last execution of the application. */ |
bogdanm | 0:eff01767de02 | 44 | uint16_t line_number; /**< Line number indicating at which line the failure occurred. */ |
bogdanm | 0:eff01767de02 | 45 | uint32_t err_code; /**< Error code when failure occurred. */ |
bogdanm | 0:eff01767de02 | 46 | uint8_t message[ERROR_MESSAGE_LENGTH]; /**< Will just use the first 128 bytes of filename to store for debugging purposes. */ |
bogdanm | 0:eff01767de02 | 47 | uint32_t stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */ |
bogdanm | 0:eff01767de02 | 48 | } ble_error_log_data_t; |
bogdanm | 0:eff01767de02 | 49 | |
bogdanm | 0:eff01767de02 | 50 | |
bogdanm | 0:eff01767de02 | 51 | /**@brief Function for writing the file name/message, line number, and current program stack |
bogdanm | 0:eff01767de02 | 52 | * to flash. |
bogdanm | 0:eff01767de02 | 53 | * |
bogdanm | 0:eff01767de02 | 54 | * @note This function will force the writing to flash, and disregard any radio communication. |
bogdanm | 0:eff01767de02 | 55 | * USE THIS FUNCTION WITH CARE. |
bogdanm | 0:eff01767de02 | 56 | * |
bogdanm | 0:eff01767de02 | 57 | * @param[in] err_code Error code to be logged. |
bogdanm | 0:eff01767de02 | 58 | * @param[in] p_message Message to be written to the flash together with stack dump, usually |
bogdanm | 0:eff01767de02 | 59 | * the file name where the error occured. |
bogdanm | 0:eff01767de02 | 60 | * @param[in] line_number Line number where the error occured. |
bogdanm | 0:eff01767de02 | 61 | * |
bogdanm | 0:eff01767de02 | 62 | * @return NRF_SUCCESS on successful writing of the error log. |
bogdanm | 0:eff01767de02 | 63 | * |
bogdanm | 0:eff01767de02 | 64 | */ |
bogdanm | 0:eff01767de02 | 65 | uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number); |
bogdanm | 0:eff01767de02 | 66 | |
bogdanm | 0:eff01767de02 | 67 | |
bogdanm | 0:eff01767de02 | 68 | #endif /* BLE_ERROR_LOG_H__ */ |
bogdanm | 0:eff01767de02 | 69 | |
bogdanm | 0:eff01767de02 | 70 | /** @} */ |