Lancaster University fork of the Nordic nrf51-SDK repository, which actually lives on github: https://github.com/lancaster-university/nrf51-sdk
app_error.h
00001 /* 00002 * Copyright (c) Nordic Semiconductor ASA 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 00016 * contributors to this software may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00024 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /** @file 00034 * 00035 * @defgroup app_error Common application error handler 00036 * @{ 00037 * @ingroup app_common 00038 * 00039 * @brief Common application error handler and macros for utilizing a common error handler. 00040 */ 00041 00042 #ifndef APP_ERROR_H__ 00043 #define APP_ERROR_H__ 00044 00045 #include <stdint.h> 00046 #include <stdbool.h> 00047 #include "nrf_error.h" 00048 00049 /**@brief Function for error handling, which is called when an error has occurred. 00050 * 00051 * @param[in] error_code Error code supplied to the handler. 00052 * @param[in] line_num Line number where the handler is called. 00053 * @param[in] p_file_name Pointer to the file name. 00054 */ 00055 void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); 00056 00057 /**@brief Macro for calling error handler function. 00058 * 00059 * @param[in] ERR_CODE Error code supplied to the error handler. 00060 */ 00061 #ifdef DEBUG 00062 #define APP_ERROR_HANDLER(ERR_CODE) \ 00063 do \ 00064 { \ 00065 app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ 00066 } while (0) 00067 #else 00068 #define APP_ERROR_HANDLER(ERR_CODE) \ 00069 do \ 00070 { \ 00071 app_error_handler((ERR_CODE), 0, 0); \ 00072 } while (0) 00073 #endif 00074 /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. 00075 * 00076 * @param[in] ERR_CODE Error code supplied to the error handler. 00077 */ 00078 #define APP_ERROR_CHECK(ERR_CODE) \ 00079 do \ 00080 { \ 00081 const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ 00082 if (LOCAL_ERR_CODE != NRF_SUCCESS) \ 00083 { \ 00084 APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ 00085 } \ 00086 } while (0) 00087 00088 /**@brief Macro for calling error handler function if supplied boolean value is false. 00089 * 00090 * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. 00091 */ 00092 #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ 00093 do \ 00094 { \ 00095 const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ 00096 if (!LOCAL_BOOLEAN_VALUE) \ 00097 { \ 00098 APP_ERROR_HANDLER(0); \ 00099 } \ 00100 } while (0) 00101 00102 #endif // APP_ERROR_H__ 00103 00104 /** @} */
Generated on Tue Jul 12 2022 15:07:13 by 1.7.2