テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8468a4403fea 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8468a4403fea 2 *
jksoft 0:8468a4403fea 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:8468a4403fea 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:8468a4403fea 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:8468a4403fea 6 *
jksoft 0:8468a4403fea 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:8468a4403fea 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:8468a4403fea 9 * the file.
jksoft 0:8468a4403fea 10 *
jksoft 0:8468a4403fea 11 */
jksoft 0:8468a4403fea 12
jksoft 0:8468a4403fea 13 /** @file
jksoft 0:8468a4403fea 14 *
jksoft 0:8468a4403fea 15 * @defgroup app_error Common application error handler
jksoft 0:8468a4403fea 16 * @{
jksoft 0:8468a4403fea 17 * @ingroup app_common
jksoft 0:8468a4403fea 18 *
jksoft 0:8468a4403fea 19 * @brief Common application error handler and macros for utilizing a common error handler.
jksoft 0:8468a4403fea 20 */
jksoft 0:8468a4403fea 21
jksoft 0:8468a4403fea 22 #ifndef APP_ERROR_H__
jksoft 0:8468a4403fea 23 #define APP_ERROR_H__
jksoft 0:8468a4403fea 24
jksoft 0:8468a4403fea 25 #include <stdint.h>
jksoft 0:8468a4403fea 26 #include <stdbool.h>
jksoft 0:8468a4403fea 27 #include "nrf_error.h"
jksoft 0:8468a4403fea 28
jksoft 0:8468a4403fea 29 #ifdef __cplusplus
jksoft 0:8468a4403fea 30 extern "C" {
jksoft 0:8468a4403fea 31 #endif
jksoft 0:8468a4403fea 32
jksoft 0:8468a4403fea 33 /**@brief Function for error handling, which is called when an error has occurred.
jksoft 0:8468a4403fea 34 *
jksoft 0:8468a4403fea 35 * @param[in] error_code Error code supplied to the handler.
jksoft 0:8468a4403fea 36 * @param[in] line_num Line number where the handler is called.
jksoft 0:8468a4403fea 37 * @param[in] p_file_name Pointer to the file name.
jksoft 0:8468a4403fea 38 */
jksoft 0:8468a4403fea 39 void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
jksoft 0:8468a4403fea 40
jksoft 0:8468a4403fea 41 #ifdef __cplusplus
jksoft 0:8468a4403fea 42 }
jksoft 0:8468a4403fea 43 #endif
jksoft 0:8468a4403fea 44
jksoft 0:8468a4403fea 45 /**@brief Macro for calling error handler function.
jksoft 0:8468a4403fea 46 *
jksoft 0:8468a4403fea 47 * @param[in] ERR_CODE Error code supplied to the error handler.
jksoft 0:8468a4403fea 48 */
jksoft 0:8468a4403fea 49 #define APP_ERROR_HANDLER(ERR_CODE) \
jksoft 0:8468a4403fea 50 do \
jksoft 0:8468a4403fea 51 { \
jksoft 0:8468a4403fea 52 app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \
jksoft 0:8468a4403fea 53 } while (0)
jksoft 0:8468a4403fea 54
jksoft 0:8468a4403fea 55 /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
jksoft 0:8468a4403fea 56 *
jksoft 0:8468a4403fea 57 * @param[in] ERR_CODE Error code supplied to the error handler.
jksoft 0:8468a4403fea 58 */
jksoft 0:8468a4403fea 59 #define APP_ERROR_CHECK(ERR_CODE) \
jksoft 0:8468a4403fea 60 do \
jksoft 0:8468a4403fea 61 { \
jksoft 0:8468a4403fea 62 const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \
jksoft 0:8468a4403fea 63 if (LOCAL_ERR_CODE != NRF_SUCCESS) \
jksoft 0:8468a4403fea 64 { \
jksoft 0:8468a4403fea 65 APP_ERROR_HANDLER(LOCAL_ERR_CODE); \
jksoft 0:8468a4403fea 66 } \
jksoft 0:8468a4403fea 67 } while (0)
jksoft 0:8468a4403fea 68
jksoft 0:8468a4403fea 69 /**@brief Macro for calling error handler function if supplied boolean value is false.
jksoft 0:8468a4403fea 70 *
jksoft 0:8468a4403fea 71 * @param[in] BOOLEAN_VALUE Boolean value to be evaluated.
jksoft 0:8468a4403fea 72 */
jksoft 0:8468a4403fea 73 #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \
jksoft 0:8468a4403fea 74 do \
jksoft 0:8468a4403fea 75 { \
jksoft 0:8468a4403fea 76 const bool LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
jksoft 0:8468a4403fea 77 if (!LOCAL_BOOLEAN_VALUE) \
jksoft 0:8468a4403fea 78 { \
jksoft 0:8468a4403fea 79 APP_ERROR_HANDLER(0); \
jksoft 0:8468a4403fea 80 } \
jksoft 0:8468a4403fea 81 } while (0)
jksoft 0:8468a4403fea 82
jksoft 0:8468a4403fea 83 #endif // APP_ERROR_H__
jksoft 0:8468a4403fea 84
jksoft 0:8468a4403fea 85 /** @} */