mbed library

Dependents:   Printf

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Fri Sep 12 16:41:52 2014 +0100
Revision:
89:552587b429a1
Release 89 of the mbed library

Main changes:

- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends

Who changed what in which revision?

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