nochanges
Dependents: BLE_Acceleration_Statejudging
Fork of nRF51822 by
nordic/nrf-sdk/app_common/app_error.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) 2013 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 app_error Common application error handler |
bogdanm | 0:eff01767de02 | 16 | * @{ |
bogdanm | 0:eff01767de02 | 17 | * @ingroup app_common |
bogdanm | 0:eff01767de02 | 18 | * |
bogdanm | 0:eff01767de02 | 19 | * @brief Common application error handler and macros for utilizing a common error handler. |
bogdanm | 0:eff01767de02 | 20 | */ |
bogdanm | 0:eff01767de02 | 21 | |
bogdanm | 0:eff01767de02 | 22 | #ifndef APP_ERROR_H__ |
bogdanm | 0:eff01767de02 | 23 | #define APP_ERROR_H__ |
bogdanm | 0:eff01767de02 | 24 | |
bogdanm | 0:eff01767de02 | 25 | #include <stdint.h> |
bogdanm | 0:eff01767de02 | 26 | #include <stdbool.h> |
bogdanm | 0:eff01767de02 | 27 | #include "nordic_global.h" |
bogdanm | 0:eff01767de02 | 28 | #include "nrf_error.h" |
bogdanm | 0:eff01767de02 | 29 | |
bogdanm | 0:eff01767de02 | 30 | /**@brief Function for error handling, which is called when an error has occurred. |
bogdanm | 0:eff01767de02 | 31 | * |
bogdanm | 0:eff01767de02 | 32 | * @param[in] error_code Error code supplied to the handler. |
bogdanm | 0:eff01767de02 | 33 | * @param[in] line_num Line number where the handler is called. |
bogdanm | 0:eff01767de02 | 34 | * @param[in] p_file_name Pointer to the file name. |
bogdanm | 0:eff01767de02 | 35 | */ |
bogdanm | 0:eff01767de02 | 36 | void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); |
bogdanm | 0:eff01767de02 | 37 | |
bogdanm | 0:eff01767de02 | 38 | /**@brief Macro for calling error handler function. |
bogdanm | 0:eff01767de02 | 39 | * |
bogdanm | 0:eff01767de02 | 40 | * @param[in] ERR_CODE Error code supplied to the error handler. |
bogdanm | 0:eff01767de02 | 41 | */ |
bogdanm | 0:eff01767de02 | 42 | #define APP_ERROR_HANDLER(ERR_CODE) \ |
bogdanm | 0:eff01767de02 | 43 | do \ |
bogdanm | 0:eff01767de02 | 44 | { \ |
bogdanm | 0:eff01767de02 | 45 | app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ |
bogdanm | 0:eff01767de02 | 46 | } while (0) |
bogdanm | 0:eff01767de02 | 47 | |
bogdanm | 0:eff01767de02 | 48 | /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. |
bogdanm | 0:eff01767de02 | 49 | * |
bogdanm | 0:eff01767de02 | 50 | * @param[in] ERR_CODE Error code supplied to the error handler. |
bogdanm | 0:eff01767de02 | 51 | */ |
bogdanm | 0:eff01767de02 | 52 | #define APP_ERROR_CHECK(ERR_CODE) \ |
bogdanm | 0:eff01767de02 | 53 | do \ |
bogdanm | 0:eff01767de02 | 54 | { \ |
bogdanm | 0:eff01767de02 | 55 | const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ |
bogdanm | 0:eff01767de02 | 56 | if (LOCAL_ERR_CODE != NRF_SUCCESS) \ |
bogdanm | 0:eff01767de02 | 57 | { \ |
bogdanm | 0:eff01767de02 | 58 | APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ |
bogdanm | 0:eff01767de02 | 59 | } \ |
bogdanm | 0:eff01767de02 | 60 | } while (0) |
bogdanm | 0:eff01767de02 | 61 | |
bogdanm | 0:eff01767de02 | 62 | /**@brief Macro for calling error handler function if supplied boolean value is false. |
bogdanm | 0:eff01767de02 | 63 | * |
bogdanm | 0:eff01767de02 | 64 | * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. |
bogdanm | 0:eff01767de02 | 65 | */ |
bogdanm | 0:eff01767de02 | 66 | #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ |
bogdanm | 0:eff01767de02 | 67 | do \ |
bogdanm | 0:eff01767de02 | 68 | { \ |
bogdanm | 0:eff01767de02 | 69 | const bool LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ |
bogdanm | 0:eff01767de02 | 70 | if (!LOCAL_BOOLEAN_VALUE) \ |
bogdanm | 0:eff01767de02 | 71 | { \ |
bogdanm | 0:eff01767de02 | 72 | APP_ERROR_HANDLER(0); \ |
bogdanm | 0:eff01767de02 | 73 | } \ |
bogdanm | 0:eff01767de02 | 74 | } while (0) |
bogdanm | 0:eff01767de02 | 75 | |
bogdanm | 0:eff01767de02 | 76 | #endif // APP_ERROR_H__ |
bogdanm | 0:eff01767de02 | 77 | |
bogdanm | 0:eff01767de02 | 78 | /** @} */ |