Forked version
Fork of mbed-dev-bin by
TARGET_NRF51_MICROBIT/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components/libraries/util/app_error.h@2:a715a02d198e, 2016-06-01 (annotated)
- Committer:
- cefn
- Date:
- Wed Jun 01 17:38:31 2016 +0000
- Revision:
- 2:a715a02d198e
- Parent:
- 0:e1a608bb55e8
Temporary microbit tree for shipping lifedetector (with minor patches as agreed with @jamesadevine
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jamesadevine | 0:e1a608bb55e8 | 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. |
jamesadevine | 0:e1a608bb55e8 | 2 | * |
jamesadevine | 0:e1a608bb55e8 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
jamesadevine | 0:e1a608bb55e8 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
jamesadevine | 0:e1a608bb55e8 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
jamesadevine | 0:e1a608bb55e8 | 6 | * |
jamesadevine | 0:e1a608bb55e8 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
jamesadevine | 0:e1a608bb55e8 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
jamesadevine | 0:e1a608bb55e8 | 9 | * the file. |
jamesadevine | 0:e1a608bb55e8 | 10 | * |
jamesadevine | 0:e1a608bb55e8 | 11 | */ |
jamesadevine | 0:e1a608bb55e8 | 12 | |
jamesadevine | 0:e1a608bb55e8 | 13 | /** @file |
jamesadevine | 0:e1a608bb55e8 | 14 | * |
jamesadevine | 0:e1a608bb55e8 | 15 | * @defgroup app_error Common application error handler |
jamesadevine | 0:e1a608bb55e8 | 16 | * @{ |
jamesadevine | 0:e1a608bb55e8 | 17 | * @ingroup app_common |
jamesadevine | 0:e1a608bb55e8 | 18 | * |
jamesadevine | 0:e1a608bb55e8 | 19 | * @brief Common application error handler and macros for utilizing a common error handler. |
jamesadevine | 0:e1a608bb55e8 | 20 | */ |
jamesadevine | 0:e1a608bb55e8 | 21 | |
jamesadevine | 0:e1a608bb55e8 | 22 | #ifndef APP_ERROR_H__ |
jamesadevine | 0:e1a608bb55e8 | 23 | #define APP_ERROR_H__ |
jamesadevine | 0:e1a608bb55e8 | 24 | |
jamesadevine | 0:e1a608bb55e8 | 25 | #include <stdint.h> |
jamesadevine | 0:e1a608bb55e8 | 26 | #include <stdbool.h> |
jamesadevine | 0:e1a608bb55e8 | 27 | #include "nrf_error.h" |
jamesadevine | 0:e1a608bb55e8 | 28 | |
jamesadevine | 0:e1a608bb55e8 | 29 | #ifdef __cplusplus |
jamesadevine | 0:e1a608bb55e8 | 30 | extern "C" { |
jamesadevine | 0:e1a608bb55e8 | 31 | #endif |
jamesadevine | 0:e1a608bb55e8 | 32 | |
jamesadevine | 0:e1a608bb55e8 | 33 | /**@brief Function for error handling, which is called when an error has occurred. |
jamesadevine | 0:e1a608bb55e8 | 34 | * |
jamesadevine | 0:e1a608bb55e8 | 35 | * @param[in] error_code Error code supplied to the handler. |
jamesadevine | 0:e1a608bb55e8 | 36 | * @param[in] line_num Line number where the handler is called. |
jamesadevine | 0:e1a608bb55e8 | 37 | * @param[in] p_file_name Pointer to the file name. |
jamesadevine | 0:e1a608bb55e8 | 38 | */ |
jamesadevine | 0:e1a608bb55e8 | 39 | void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); |
jamesadevine | 0:e1a608bb55e8 | 40 | |
jamesadevine | 0:e1a608bb55e8 | 41 | #ifdef __cplusplus |
jamesadevine | 0:e1a608bb55e8 | 42 | } |
jamesadevine | 0:e1a608bb55e8 | 43 | #endif |
jamesadevine | 0:e1a608bb55e8 | 44 | |
jamesadevine | 0:e1a608bb55e8 | 45 | /**@brief Macro for calling error handler function. |
jamesadevine | 0:e1a608bb55e8 | 46 | * |
jamesadevine | 0:e1a608bb55e8 | 47 | * @param[in] ERR_CODE Error code supplied to the error handler. |
jamesadevine | 0:e1a608bb55e8 | 48 | */ |
jamesadevine | 0:e1a608bb55e8 | 49 | #ifdef DEBUG |
jamesadevine | 0:e1a608bb55e8 | 50 | #define APP_ERROR_HANDLER(ERR_CODE) \ |
jamesadevine | 0:e1a608bb55e8 | 51 | do \ |
jamesadevine | 0:e1a608bb55e8 | 52 | { \ |
jamesadevine | 0:e1a608bb55e8 | 53 | app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ |
jamesadevine | 0:e1a608bb55e8 | 54 | } while (0) |
jamesadevine | 0:e1a608bb55e8 | 55 | #else |
jamesadevine | 0:e1a608bb55e8 | 56 | #define APP_ERROR_HANDLER(ERR_CODE) \ |
jamesadevine | 0:e1a608bb55e8 | 57 | do \ |
jamesadevine | 0:e1a608bb55e8 | 58 | { \ |
jamesadevine | 0:e1a608bb55e8 | 59 | app_error_handler((ERR_CODE), 0, 0); \ |
jamesadevine | 0:e1a608bb55e8 | 60 | } while (0) |
jamesadevine | 0:e1a608bb55e8 | 61 | #endif |
jamesadevine | 0:e1a608bb55e8 | 62 | /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. |
jamesadevine | 0:e1a608bb55e8 | 63 | * |
jamesadevine | 0:e1a608bb55e8 | 64 | * @param[in] ERR_CODE Error code supplied to the error handler. |
jamesadevine | 0:e1a608bb55e8 | 65 | */ |
jamesadevine | 0:e1a608bb55e8 | 66 | #define APP_ERROR_CHECK(ERR_CODE) \ |
jamesadevine | 0:e1a608bb55e8 | 67 | do \ |
jamesadevine | 0:e1a608bb55e8 | 68 | { \ |
jamesadevine | 0:e1a608bb55e8 | 69 | const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ |
jamesadevine | 0:e1a608bb55e8 | 70 | if (LOCAL_ERR_CODE != NRF_SUCCESS) \ |
jamesadevine | 0:e1a608bb55e8 | 71 | { \ |
jamesadevine | 0:e1a608bb55e8 | 72 | APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ |
jamesadevine | 0:e1a608bb55e8 | 73 | } \ |
jamesadevine | 0:e1a608bb55e8 | 74 | } while (0) |
jamesadevine | 0:e1a608bb55e8 | 75 | |
jamesadevine | 0:e1a608bb55e8 | 76 | /**@brief Macro for calling error handler function if supplied boolean value is false. |
jamesadevine | 0:e1a608bb55e8 | 77 | * |
jamesadevine | 0:e1a608bb55e8 | 78 | * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. |
jamesadevine | 0:e1a608bb55e8 | 79 | */ |
jamesadevine | 0:e1a608bb55e8 | 80 | #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ |
jamesadevine | 0:e1a608bb55e8 | 81 | do \ |
jamesadevine | 0:e1a608bb55e8 | 82 | { \ |
jamesadevine | 0:e1a608bb55e8 | 83 | const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ |
jamesadevine | 0:e1a608bb55e8 | 84 | if (!LOCAL_BOOLEAN_VALUE) \ |
jamesadevine | 0:e1a608bb55e8 | 85 | { \ |
jamesadevine | 0:e1a608bb55e8 | 86 | APP_ERROR_HANDLER(0); \ |
jamesadevine | 0:e1a608bb55e8 | 87 | } \ |
jamesadevine | 0:e1a608bb55e8 | 88 | } while (0) |
jamesadevine | 0:e1a608bb55e8 | 89 | |
jamesadevine | 0:e1a608bb55e8 | 90 | #endif // APP_ERROR_H__ |
jamesadevine | 0:e1a608bb55e8 | 91 | |
jamesadevine | 0:e1a608bb55e8 | 92 | /** @} */ |