123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #ifndef APP_ERROR_H__
- #define APP_ERROR_H__
- #include <stdint.h>
- #include <stdio.h>
- #include <stdbool.h>
- #include "nrf.h"
- #include "sdk_errors.h"
- #include "nordic_common.h"
- #include "app_error_weak.h"
- #ifdef ANT_STACK_SUPPORT_REQD
- #include "ant_error.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRF_FAULT_ID_SDK_RANGE_START (0x00004000)
- #define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1)
- #define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2)
- typedef struct
- {
- uint32_t line_num;
- uint8_t const * p_file_name;
- uint32_t err_code;
- } error_info_t;
- typedef struct
- {
- uint32_t line_num;
- uint8_t const * p_file_name;
- } assert_info_t;
- #define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num))
- #define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name))
- #define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code))
- #define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t))
- #define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \
- ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t))
- void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
- void app_error_handler_bare(ret_code_t error_code);
- void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info);
- void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info);
- #ifdef DEBUG
- #define APP_ERROR_HANDLER(ERR_CODE) \
- do \
- { \
- app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \
- } while (0)
- #else
- #define APP_ERROR_HANDLER(ERR_CODE) \
- do \
- { \
- app_error_handler_bare((ERR_CODE)); \
- } while (0)
- #endif
- #define APP_ERROR_CHECK(ERR_CODE) \
- do \
- { \
- const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \
- if (LOCAL_ERR_CODE != NRF_SUCCESS) \
- { \
- APP_ERROR_HANDLER(LOCAL_ERR_CODE); \
- } \
- } while (0)
- #define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \
- do \
- { \
- const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
- if (!LOCAL_BOOLEAN_VALUE) \
- { \
- APP_ERROR_HANDLER(0); \
- } \
- } while (0)
- #ifdef __cplusplus
- }
- #endif
- #endif
|