konashi/SBBLEのテスト

Dependencies:   BLE_API mbed

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers app_error.h Source File

app_error.h

Go to the documentation of this file.
00001 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * Terms and conditions of usage are described in detail in NORDIC
00004  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00005  *
00006  * Licensees are granted free, non-transferable use of the information. NO
00007  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00008  * the file.
00009  *
00010  */
00011 
00012 /** @file
00013  *
00014  * @defgroup app_error Common application error handler
00015  * @{
00016  * @ingroup app_common
00017  *
00018  * @brief Common application error handler and macros for utilizing a common error handler.
00019  */
00020 
00021 #ifndef APP_ERROR_H__
00022 #define APP_ERROR_H__
00023 
00024 #include <stdint.h>
00025 #include <stdbool.h>
00026 #include "nrf_error.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /**@brief Function for error handling, which is called when an error has occurred.
00033  *
00034  * @param[in] error_code  Error code supplied to the handler.
00035  * @param[in] line_num    Line number where the handler is called.
00036  * @param[in] p_file_name Pointer to the file name.
00037  */
00038 void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
00039 
00040 #ifdef __cplusplus
00041 }
00042 #endif
00043 
00044 /**@brief Macro for calling error handler function.
00045  *
00046  * @param[in] ERR_CODE Error code supplied to the error handler.
00047  */
00048 #define APP_ERROR_HANDLER(ERR_CODE)                         \
00049     do                                                      \
00050     {                                                       \
00051         app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__);  \
00052     } while (0)
00053 
00054 /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
00055  *
00056  * @param[in] ERR_CODE Error code supplied to the error handler.
00057  */
00058 #define APP_ERROR_CHECK(ERR_CODE)                           \
00059     do                                                      \
00060     {                                                       \
00061         const uint32_t LOCAL_ERR_CODE = (ERR_CODE);         \
00062         if (LOCAL_ERR_CODE != NRF_SUCCESS)                  \
00063         {                                                   \
00064             APP_ERROR_HANDLER(LOCAL_ERR_CODE);              \
00065         }                                                   \
00066     } while (0)
00067 
00068 /**@brief Macro for calling error handler function if supplied boolean value is false.
00069  *
00070  * @param[in] BOOLEAN_VALUE Boolean value to be evaluated.
00071  */
00072 #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE)                 \
00073     do                                                      \
00074     {                                                       \
00075         const bool LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE);   \
00076         if (!LOCAL_BOOLEAN_VALUE)                           \
00077         {                                                   \
00078             APP_ERROR_HANDLER(0);                           \
00079         }                                                   \
00080     } while (0)
00081 
00082 #endif // APP_ERROR_H__
00083 
00084 /** @} */