test

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Committer:
ommpy
Date:
Wed Aug 26 14:26:27 2020 +0530
Revision:
11:32eeb052cda5
Parent:
0:d383e2dee0f7
added temp sensor in code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ommpy 0:d383e2dee0f7 1 /** \addtogroup platform */
ommpy 0:d383e2dee0f7 2 /** @{*/
ommpy 0:d383e2dee0f7 3 /**
ommpy 0:d383e2dee0f7 4 * \defgroup platform_error Error functions
ommpy 0:d383e2dee0f7 5 * @{
ommpy 0:d383e2dee0f7 6 */
ommpy 0:d383e2dee0f7 7 /* mbed Microcontroller Library
ommpy 0:d383e2dee0f7 8 * Copyright (c) 2006-2013 ARM Limited
ommpy 0:d383e2dee0f7 9 * SPDX-License-Identifier: Apache-2.0
ommpy 0:d383e2dee0f7 10 *
ommpy 0:d383e2dee0f7 11 * Licensed under the Apache License, Version 2.0 (the "License");
ommpy 0:d383e2dee0f7 12 * you may not use this file except in compliance with the License.
ommpy 0:d383e2dee0f7 13 * You may obtain a copy of the License at
ommpy 0:d383e2dee0f7 14 *
ommpy 0:d383e2dee0f7 15 * http://www.apache.org/licenses/LICENSE-2.0
ommpy 0:d383e2dee0f7 16 *
ommpy 0:d383e2dee0f7 17 * Unless required by applicable law or agreed to in writing, software
ommpy 0:d383e2dee0f7 18 * distributed under the License is distributed on an "AS IS" BASIS,
ommpy 0:d383e2dee0f7 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ommpy 0:d383e2dee0f7 20 * See the License for the specific language governing permissions and
ommpy 0:d383e2dee0f7 21 * limitations under the License.
ommpy 0:d383e2dee0f7 22 */
ommpy 0:d383e2dee0f7 23 #ifndef MBED_ERROR_H
ommpy 0:d383e2dee0f7 24 #define MBED_ERROR_H
ommpy 0:d383e2dee0f7 25
ommpy 0:d383e2dee0f7 26 #include "platform/mbed_retarget.h"
ommpy 0:d383e2dee0f7 27 #include "platform/mbed_toolchain.h"
ommpy 0:d383e2dee0f7 28
ommpy 0:d383e2dee0f7 29 #ifdef __cplusplus
ommpy 0:d383e2dee0f7 30 extern "C" {
ommpy 0:d383e2dee0f7 31 #endif
ommpy 0:d383e2dee0f7 32
ommpy 0:d383e2dee0f7 33 /** Define this macro to include filenames in error context. For release builds, do not include filename to save memory.
ommpy 0:d383e2dee0f7 34 * MBED_PLATFORM_CONF_ERROR_FILENAME_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 35 */
ommpy 0:d383e2dee0f7 36
ommpy 0:d383e2dee0f7 37 /** Define this macro to enable error history
ommpy 0:d383e2dee0f7 38 * MBED_PLATFORM_CONF_ERROR_HIST_ENABLED
ommpy 0:d383e2dee0f7 39 */
ommpy 0:d383e2dee0f7 40
ommpy 0:d383e2dee0f7 41 #ifndef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN
ommpy 0:d383e2dee0f7 42 #define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16
ommpy 0:d383e2dee0f7 43 #else //MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN
ommpy 0:d383e2dee0f7 44 #if MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN > 64
ommpy 0:d383e2dee0f7 45 //We have to limit this to 64 bytes since we use mbed_error_printf for error reporting
ommpy 0:d383e2dee0f7 46 //and mbed_error_vprintf uses 128bytes internal buffer which may not be sufficient for anything
ommpy 0:d383e2dee0f7 47 //longer that 64 bytes with the current implementation.
ommpy 0:d383e2dee0f7 48 #error "Unsupported error filename buffer length detected, max supported length is 64 chars. Please change MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN or max-error-filename-len in configuration."
ommpy 0:d383e2dee0f7 49 #endif
ommpy 0:d383e2dee0f7 50 #endif
ommpy 0:d383e2dee0f7 51
ommpy 0:d383e2dee0f7 52 #define MBED_ERROR_STATUS_CODE_MASK (0x0000FFFF)
ommpy 0:d383e2dee0f7 53 #define MBED_ERROR_STATUS_CODE_POS (0)
ommpy 0:d383e2dee0f7 54 #define MBED_ERROR_STATUS_CODE_FIELD_SIZE (16)
ommpy 0:d383e2dee0f7 55
ommpy 0:d383e2dee0f7 56 #define MBED_ERROR_STATUS_MODULE_MASK (0x00FF0000)
ommpy 0:d383e2dee0f7 57 #define MBED_ERROR_STATUS_MODULE_POS (16)
ommpy 0:d383e2dee0f7 58 #define MBED_ERROR_STATUS_MODULE_FIELD_SIZE (8)
ommpy 0:d383e2dee0f7 59
ommpy 0:d383e2dee0f7 60 #define MBED_ERROR_STATUS_TYPE_MASK (0x60000000)
ommpy 0:d383e2dee0f7 61 #define MBED_ERROR_STATUS_TYPE_POS (29)
ommpy 0:d383e2dee0f7 62 #define MBED_ERROR_STATUS_TYPE_FIELD_SIZE (2)
ommpy 0:d383e2dee0f7 63
ommpy 0:d383e2dee0f7 64 /* mbed_error_status_t Status Encoding */
ommpy 0:d383e2dee0f7 65 //|31(1 bit) Always Negative|30-29(2 bits) |28-24 | 23-16(8 bits) | 15-0(16 bits) |
ommpy 0:d383e2dee0f7 66 //|-1 |TYPE |(unused/reserved) | MODULE TYPE | ERROR CODE |
ommpy 0:d383e2dee0f7 67
ommpy 0:d383e2dee0f7 68 #define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \
ommpy 0:d383e2dee0f7 69 ((0x80000000) | \
ommpy 0:d383e2dee0f7 70 (MBED_ERROR_STATUS_CODE_MASK & (error_code << MBED_ERROR_STATUS_CODE_POS)) | \
ommpy 0:d383e2dee0f7 71 (MBED_ERROR_STATUS_MODULE_MASK & (module << MBED_ERROR_STATUS_MODULE_POS)) | \
ommpy 0:d383e2dee0f7 72 (MBED_ERROR_STATUS_TYPE_MASK & (type << MBED_ERROR_STATUS_TYPE_POS)))
ommpy 0:d383e2dee0f7 73
ommpy 0:d383e2dee0f7 74 #define MBED_GET_ERROR_TYPE( error_status ) ((error_status & MBED_ERROR_STATUS_TYPE_MASK) >> MBED_ERROR_STATUS_TYPE_POS)
ommpy 0:d383e2dee0f7 75 #define MBED_GET_ERROR_MODULE( error_status ) ((error_status & MBED_ERROR_STATUS_MODULE_MASK) >> MBED_ERROR_STATUS_MODULE_POS)
ommpy 0:d383e2dee0f7 76 #define MBED_GET_ERROR_CODE( error_status ) (int)((MBED_GET_ERROR_TYPE( error_status ) == MBED_ERROR_TYPE_POSIX)?(-error_status):((error_status & MBED_ERROR_STATUS_CODE_MASK) >> MBED_ERROR_STATUS_CODE_POS))
ommpy 0:d383e2dee0f7 77
ommpy 0:d383e2dee0f7 78 /** mbed_error_status_t description
ommpy 0:d383e2dee0f7 79 *
ommpy 0:d383e2dee0f7 80 * mbed_error_status_t type represents the error status values under MbedOS. mbed_error_status_t values are signed integers and always be negative.\n
ommpy 0:d383e2dee0f7 81 * Internally its encoded as below with bit-fields representing error type, module and error code:\n\n
ommpy 0:d383e2dee0f7 82 * mbed_error_status_t Status Encoding:\n
ommpy 0:d383e2dee0f7 83 *
ommpy 0:d383e2dee0f7 84 \verbatim
ommpy 0:d383e2dee0f7 85 | 31 Always Negative | 30-29(2 bits) | 28-24 | 23-16(8 bits) | 15-0(16 bits) |
ommpy 0:d383e2dee0f7 86 | -1 | TYPE | (unused/reserved) | MODULE TYPE | ERROR CODE |
ommpy 0:d383e2dee0f7 87 \endverbatim
ommpy 0:d383e2dee0f7 88 *
ommpy 0:d383e2dee0f7 89 * The error status value range for each error type is as follows:\n
ommpy 0:d383e2dee0f7 90 * POSIX Error Status-es - 0xFFFFFFFF to 0xFFFFFF01(-1 -255) - This corresponds to POSIX error codes represented as negative.\n
ommpy 0:d383e2dee0f7 91 * System Error Status-es - 0x80XX0100 to 0x80XX0FFF - This corresponds to System error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n
ommpy 0:d383e2dee0f7 92 * Custom Error Status-es - 0xA0XX1000 to 0xA0XXFFFF - This corresponds to Custom error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n\n
ommpy 0:d383e2dee0f7 93 *
ommpy 0:d383e2dee0f7 94 * The ERROR CODE(values encoded into ERROR CODE bit-field in mbed_error_status_t) value range for each error type is also separated as below:\n
ommpy 0:d383e2dee0f7 95 * POSIX Error Codes - 1 to 255.\n
ommpy 0:d383e2dee0f7 96 * System Error Codes - 256 to 4095.\n
ommpy 0:d383e2dee0f7 97 * Custom Error Codes - 4096 to 65535.\n
ommpy 0:d383e2dee0f7 98 *
ommpy 0:d383e2dee0f7 99 * @note POSIX error codes are always encoded as negative of their actual value. For example, EPERM is encoded as -EPERM.
ommpy 0:d383e2dee0f7 100 * And, the MODULE TYPE for POSIX error codes are always encoded as MBED_MODULE_UNKNOWN.\n
ommpy 0:d383e2dee0f7 101 * This is to enable easy injection of POSIX error codes into MbedOS error handling system without altering the actual POSIX error values.\n
ommpy 0:d383e2dee0f7 102 * Accordingly, POSIX error codes are represented as -1 to -255 under MbedOS error status representation.
ommpy 0:d383e2dee0f7 103 */
ommpy 0:d383e2dee0f7 104 typedef int mbed_error_status_t;
ommpy 0:d383e2dee0f7 105
ommpy 0:d383e2dee0f7 106 /**
ommpy 0:d383e2dee0f7 107 * Macro for defining a POSIX error status. This macro is mainly used to define POSIX error values in mbed_error_code_t enumeration.
ommpy 0:d383e2dee0f7 108 * @param error_name Name of the error without the ERROR_ prefix
ommpy 0:d383e2dee0f7 109 * @param error_code Error code value to be used, must be between 1 and 255(inclusive).
ommpy 0:d383e2dee0f7 110 *
ommpy 0:d383e2dee0f7 111 */
ommpy 0:d383e2dee0f7 112 #define MBED_DEFINE_POSIX_ERROR( error_name, error_code ) \
ommpy 0:d383e2dee0f7 113 MBED_ERROR_CODE_##error_name = error_code, \
ommpy 0:d383e2dee0f7 114 MBED_ERROR_##error_name = -(MBED_POSIX_ERROR_BASE + error_code)
ommpy 0:d383e2dee0f7 115
ommpy 0:d383e2dee0f7 116 /**
ommpy 0:d383e2dee0f7 117 * Macro for defining a System error status. This macro is used to define System error values in mbed_error_code_t enumeration.
ommpy 0:d383e2dee0f7 118 * @param error_name Name of the error without the ERROR_ prefix
ommpy 0:d383e2dee0f7 119 * @param error_code Error code value to be used, must be between 256 and 4096(inclusive).
ommpy 0:d383e2dee0f7 120 *
ommpy 0:d383e2dee0f7 121 */
ommpy 0:d383e2dee0f7 122 #define MBED_DEFINE_SYSTEM_ERROR( error_name, error_code ) \
ommpy 0:d383e2dee0f7 123 MBED_ERROR_CODE_##error_name = MBED_SYSTEM_ERROR_BASE + error_code, \
ommpy 0:d383e2dee0f7 124 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name)
ommpy 0:d383e2dee0f7 125
ommpy 0:d383e2dee0f7 126 /**
ommpy 0:d383e2dee0f7 127 * Macro for defining a Custom error status. This macro is used to define custom error values in mbed_error_code_t enumeration.
ommpy 0:d383e2dee0f7 128 * @param error_name Name of the error without the ERROR_ prefix
ommpy 0:d383e2dee0f7 129 * @param error_code Error code value to be used, must be between 4097 and 65535(inclusive).
ommpy 0:d383e2dee0f7 130 *
ommpy 0:d383e2dee0f7 131 */
ommpy 0:d383e2dee0f7 132 #define MBED_DEFINE_CUSTOM_ERROR( error_name, error_code ) \
ommpy 0:d383e2dee0f7 133 MBED_ERROR_CODE_##error_name = MBED_CUSTOM_ERROR_BASE + error_code, \
ommpy 0:d383e2dee0f7 134 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name)
ommpy 0:d383e2dee0f7 135
ommpy 0:d383e2dee0f7 136
ommpy 0:d383e2dee0f7 137 /**
ommpy 0:d383e2dee0f7 138 * Macros for setting a system warning. These macros will log the error, Its a wrapper for calling mbed_warning API.
ommpy 0:d383e2dee0f7 139 * There are 2 versions of this macro. MBED_WARNING takes status and message. MBED_WARNING1 takes an additional context specific argument
ommpy 0:d383e2dee0f7 140 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
ommpy 0:d383e2dee0f7 141 * @param error_msg The error message to be printed out to STDIO/Serial.
ommpy 0:d383e2dee0f7 142 * @param error_value Value associated with the error status. This would depend on error code/error scenario.
ommpy 0:d383e2dee0f7 143 *
ommpy 0:d383e2dee0f7 144 * @code
ommpy 0:d383e2dee0f7 145 *
ommpy 0:d383e2dee0f7 146 * MBED_WARNING( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read" )
ommpy 0:d383e2dee0f7 147 * MBED_WARNING1( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read", size_val )
ommpy 0:d383e2dee0f7 148 *
ommpy 0:d383e2dee0f7 149 * @endcode
ommpy 0:d383e2dee0f7 150 * @note The macro calls mbed_warning API with filename and line number info without caller explicitly passing them.
ommpy 0:d383e2dee0f7 151 * Since this macro is a wrapper for mbed_warning API callers should process the return value from this macro which is the return value from calling mbed_error API.
ommpy 0:d383e2dee0f7 152 *
ommpy 0:d383e2dee0f7 153 */
ommpy 0:d383e2dee0f7 154 #ifdef NDEBUG
ommpy 0:d383e2dee0f7 155 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 )
ommpy 0:d383e2dee0f7 156 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 )
ommpy 0:d383e2dee0f7 157 #else //NDEBUG
ommpy 0:d383e2dee0f7 158 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 159 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
ommpy 0:d383e2dee0f7 160 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ )
ommpy 0:d383e2dee0f7 161 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 162 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
ommpy 0:d383e2dee0f7 163 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 )
ommpy 0:d383e2dee0f7 164 #endif
ommpy 0:d383e2dee0f7 165 #endif
ommpy 0:d383e2dee0f7 166
ommpy 0:d383e2dee0f7 167 /**
ommpy 0:d383e2dee0f7 168 * Macros for setting a fatal system error. These macros will log the error, prints the error report and halts the system. Its a wrapper for calling mbed_error API.
ommpy 0:d383e2dee0f7 169 * There are 2 versions of this macro. MBED_ERROR takes status and message. MBED_ERROR1 takes an additional context specific argument
ommpy 0:d383e2dee0f7 170 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
ommpy 0:d383e2dee0f7 171 * @param error_msg The error message to be printed out to STDIO/Serial.
ommpy 0:d383e2dee0f7 172 * @param error_value Value associated with the error status. This would depend on error code/error scenario. Only available with MBED_ERROR1
ommpy 0:d383e2dee0f7 173 * @return Does not return
ommpy 0:d383e2dee0f7 174 *
ommpy 0:d383e2dee0f7 175 * @code
ommpy 0:d383e2dee0f7 176 *
ommpy 0:d383e2dee0f7 177 * MBED_ERROR( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex" )
ommpy 0:d383e2dee0f7 178 * MBED_ERROR1( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex", &my_mutex )
ommpy 0:d383e2dee0f7 179 *
ommpy 0:d383e2dee0f7 180 * @endcode
ommpy 0:d383e2dee0f7 181 * @note The macro calls mbed_error API with filename and line number info without caller explicitly passing them.
ommpy 0:d383e2dee0f7 182 * Since this macro is a wrapper for mbed_error API callers should process the return value from this macro which is the return value from calling mbed_error API.
ommpy 0:d383e2dee0f7 183 *
ommpy 0:d383e2dee0f7 184 */
ommpy 0:d383e2dee0f7 185 #ifdef NDEBUG
ommpy 0:d383e2dee0f7 186 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 )
ommpy 0:d383e2dee0f7 187 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 )
ommpy 0:d383e2dee0f7 188 #else //NDEBUG
ommpy 0:d383e2dee0f7 189 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 190 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
ommpy 0:d383e2dee0f7 191 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ )
ommpy 0:d383e2dee0f7 192 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 193 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
ommpy 0:d383e2dee0f7 194 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 )
ommpy 0:d383e2dee0f7 195 #endif
ommpy 0:d383e2dee0f7 196 #endif
ommpy 0:d383e2dee0f7 197
ommpy 0:d383e2dee0f7 198 //Error Type definition
ommpy 0:d383e2dee0f7 199 /** mbed_error_type_t definition
ommpy 0:d383e2dee0f7 200 * @note
ommpy 0:d383e2dee0f7 201 * This enumeration defines the Error types supported. The value of these enum values will be encoded into mbed_error_status_t TYPE field.\n
ommpy 0:d383e2dee0f7 202 * See mbed_error_status_t description for more info.\n
ommpy 0:d383e2dee0f7 203 * MBED_ERROR_TYPE_SYSTEM - Used to indicate that the error status is of System defined Error type.\n
ommpy 0:d383e2dee0f7 204 * MBED_ERROR_TYPE_CUSTOM - Used to indicate that the error status is of Custom defined Error type.\n
ommpy 0:d383e2dee0f7 205 * MBED_ERROR_TYPE_POSIX - Used to indicate that the error status is of POSIX error type.\n
ommpy 0:d383e2dee0f7 206 *
ommpy 0:d383e2dee0f7 207 */
ommpy 0:d383e2dee0f7 208 typedef enum _mbed_error_type_t {
ommpy 0:d383e2dee0f7 209 MBED_ERROR_TYPE_SYSTEM = 0,
ommpy 0:d383e2dee0f7 210 MBED_ERROR_TYPE_CUSTOM = 1,
ommpy 0:d383e2dee0f7 211 //2 is reserved
ommpy 0:d383e2dee0f7 212 //Use 3 for POSIX because we are mapping -1 to -255 to POSIX error codes
ommpy 0:d383e2dee0f7 213 //and thus we must use 3 to match the type bits in error status representation which are from 0xFFFFFFFF to 0xFFFFFF00
ommpy 0:d383e2dee0f7 214 MBED_ERROR_TYPE_POSIX = 3
ommpy 0:d383e2dee0f7 215 } mbed_error_type_t;
ommpy 0:d383e2dee0f7 216
ommpy 0:d383e2dee0f7 217 //Module type/id definitions
ommpy 0:d383e2dee0f7 218 /** mbed_module_type_t definition
ommpy 0:d383e2dee0f7 219 * @note
ommpy 0:d383e2dee0f7 220 * This enumeration defines the module types. The value of these enum values will be encoded into mbed_error_status_t MODULE field.\n\n
ommpy 0:d383e2dee0f7 221 * See mbed_error_status_t description for more info.\n
ommpy 0:d383e2dee0f7 222 * MBED_MODULE_UNKNOWN - This module type can be used if caller of the mbed_error/mbed_warning doesn't know who is the actual originator of the error.\n
ommpy 0:d383e2dee0f7 223 * Other module values can be used to provide more info on who/where the error originated from.\n\n
ommpy 0:d383e2dee0f7 224 * For example, if I2C driver is the component originating the error you can use MBED_MODULE_DRIVER_I2C to provide more info.\n
ommpy 0:d383e2dee0f7 225 * Its used in call to MBED_MAKE_ERROR/MBED_MAKE_SYSTEM_ERROR/MBED_MAKE_CUSTOM_ERROR macros.\n
ommpy 0:d383e2dee0f7 226 *
ommpy 0:d383e2dee0f7 227 * @code
ommpy 0:d383e2dee0f7 228 * Example: mbed_error_status_t i2c_driver_error = MBED_MAKE_ERROR( MBED_MODULE_DRIVER_I2C, MBED_ERROR_CONFIG_UNSUPPORTED );
ommpy 0:d383e2dee0f7 229 * @endcode
ommpy 0:d383e2dee0f7 230 *
ommpy 0:d383e2dee0f7 231 * @note
ommpy 0:d383e2dee0f7 232 * \n Below are the module code mappings:\n
ommpy 0:d383e2dee0f7 233 \verbatim
ommpy 0:d383e2dee0f7 234 MBED_MODULE_APPLICATION 0 Application
ommpy 0:d383e2dee0f7 235 MBED_MODULE_PLATFORM 1 Platform
ommpy 0:d383e2dee0f7 236 MBED_MODULE_KERNEL 2 RTX Kernel
ommpy 0:d383e2dee0f7 237 MBED_MODULE_NETWORK_STACK 3 Network stack
ommpy 0:d383e2dee0f7 238 MBED_MODULE_HAL 4 HAL - Hardware Abstraction Layer
ommpy 0:d383e2dee0f7 239 MBED_MODULE_MEMORY_SUBSYSTEM 5 Memory Subsystem
ommpy 0:d383e2dee0f7 240 MBED_MODULE_FILESYSTEM 6 Filesystem
ommpy 0:d383e2dee0f7 241 MBED_MODULE_BLOCK_DEVICE 7 Block device
ommpy 0:d383e2dee0f7 242 MBED_MODULE_DRIVER 8 Driver
ommpy 0:d383e2dee0f7 243 MBED_MODULE_DRIVER_SERIAL 9 Serial Driver
ommpy 0:d383e2dee0f7 244 MBED_MODULE_DRIVER_RTC 10 RTC Driver
ommpy 0:d383e2dee0f7 245 MBED_MODULE_DRIVER_I2C 11 I2C Driver
ommpy 0:d383e2dee0f7 246 MBED_MODULE_DRIVER_SPI 12 SPI Driver
ommpy 0:d383e2dee0f7 247 MBED_MODULE_DRIVER_GPIO 13 GPIO Driver
ommpy 0:d383e2dee0f7 248 MBED_MODULE_DRIVER_ANALOG 14 Analog Driver
ommpy 0:d383e2dee0f7 249 MBED_MODULE_DRIVER_DIGITAL 15 DigitalIO Driver
ommpy 0:d383e2dee0f7 250 MBED_MODULE_DRIVER_CAN 16 CAN Driver
ommpy 0:d383e2dee0f7 251 MBED_MODULE_DRIVER_ETHERNET 17 Ethernet Driver
ommpy 0:d383e2dee0f7 252 MBED_MODULE_DRIVER_CRC 18 CRC Module
ommpy 0:d383e2dee0f7 253 MBED_MODULE_DRIVER_PWM 19 PWM Driver
ommpy 0:d383e2dee0f7 254 MBED_MODULE_DRIVER_QSPI 20 QSPI Driver
ommpy 0:d383e2dee0f7 255 MBED_MODULE_DRIVER_USB 21 USB Driver
ommpy 0:d383e2dee0f7 256 MBED_MODULE_TARGET_SDK 22 SDK
ommpy 0:d383e2dee0f7 257 MBED_MODULE_BLE 23 BLE
ommpy 0:d383e2dee0f7 258 MBED_MODULE_NETWORK_STATS 24 Network Statistics
ommpy 0:d383e2dee0f7 259
ommpy 0:d383e2dee0f7 260 MBED_MODULE_UNKNOWN 255 Unknown module
ommpy 0:d383e2dee0f7 261 \endverbatim
ommpy 0:d383e2dee0f7 262 *
ommpy 0:d383e2dee0f7 263 */
ommpy 0:d383e2dee0f7 264 typedef enum _mbed_module_type {
ommpy 0:d383e2dee0f7 265 MBED_MODULE_APPLICATION = 0,
ommpy 0:d383e2dee0f7 266 MBED_MODULE_PLATFORM,
ommpy 0:d383e2dee0f7 267 MBED_MODULE_KERNEL,
ommpy 0:d383e2dee0f7 268 MBED_MODULE_NETWORK_STACK,
ommpy 0:d383e2dee0f7 269 MBED_MODULE_HAL,
ommpy 0:d383e2dee0f7 270 MBED_MODULE_MEMORY_SUBSYSTEM,
ommpy 0:d383e2dee0f7 271 MBED_MODULE_FILESYSTEM,
ommpy 0:d383e2dee0f7 272 MBED_MODULE_BLOCK_DEVICE,
ommpy 0:d383e2dee0f7 273 MBED_MODULE_DRIVER,
ommpy 0:d383e2dee0f7 274 MBED_MODULE_DRIVER_SERIAL,
ommpy 0:d383e2dee0f7 275 MBED_MODULE_DRIVER_RTC,
ommpy 0:d383e2dee0f7 276 MBED_MODULE_DRIVER_I2C,
ommpy 0:d383e2dee0f7 277 MBED_MODULE_DRIVER_SPI,
ommpy 0:d383e2dee0f7 278 MBED_MODULE_DRIVER_GPIO,
ommpy 0:d383e2dee0f7 279 MBED_MODULE_DRIVER_ANALOG,
ommpy 0:d383e2dee0f7 280 MBED_MODULE_DRIVER_DIGITAL,
ommpy 0:d383e2dee0f7 281 MBED_MODULE_DRIVER_CAN,
ommpy 0:d383e2dee0f7 282 MBED_MODULE_DRIVER_ETHERNET,
ommpy 0:d383e2dee0f7 283 MBED_MODULE_DRIVER_CRC,
ommpy 0:d383e2dee0f7 284 MBED_MODULE_DRIVER_PWM,
ommpy 0:d383e2dee0f7 285 MBED_MODULE_DRIVER_QSPI,
ommpy 0:d383e2dee0f7 286 MBED_MODULE_DRIVER_USB,
ommpy 0:d383e2dee0f7 287 MBED_MODULE_TARGET_SDK,
ommpy 0:d383e2dee0f7 288 MBED_MODULE_BLE,
ommpy 0:d383e2dee0f7 289 MBED_MODULE_NETWORK_STATS,
ommpy 0:d383e2dee0f7 290 /* Add More entities here as required */
ommpy 0:d383e2dee0f7 291
ommpy 0:d383e2dee0f7 292 MBED_MODULE_UNKNOWN = 255,
ommpy 0:d383e2dee0f7 293 MBED_MODULE_MAX = MBED_MODULE_UNKNOWN
ommpy 0:d383e2dee0f7 294 } mbed_module_type_t;
ommpy 0:d383e2dee0f7 295
ommpy 0:d383e2dee0f7 296 //Use MBED_SUCCESS(=0) or any positive number for successful returns
ommpy 0:d383e2dee0f7 297 #define MBED_SUCCESS 0
ommpy 0:d383e2dee0f7 298
ommpy 0:d383e2dee0f7 299 #define MBED_POSIX_ERROR_BASE 0
ommpy 0:d383e2dee0f7 300 #define MBED_SYSTEM_ERROR_BASE 256
ommpy 0:d383e2dee0f7 301 #define MBED_CUSTOM_ERROR_BASE 4096
ommpy 0:d383e2dee0f7 302
ommpy 0:d383e2dee0f7 303 //Error Code definitions
ommpy 0:d383e2dee0f7 304 /** mbed_error_code_t definition
ommpy 0:d383e2dee0f7 305 *
ommpy 0:d383e2dee0f7 306 * mbed_error_code_t enumeration defines the Error codes and Error status values for MBED_MODULE_UNKNOWN.\n
ommpy 0:d383e2dee0f7 307 * It defines all of POSIX Error Codes/Statuses and Mbed System Error Codes/Statuses.\n\n
ommpy 0:d383e2dee0f7 308 *
ommpy 0:d383e2dee0f7 309 * @note
ommpy 0:d383e2dee0f7 310 * POSIX Error codes are defined using the macro MBED_DEFINE_POSIX_ERROR\n
ommpy 0:d383e2dee0f7 311 * For example MBED_DEFINE_POSIX_ERROR( EPERM, EPERM ). This effectively defines the following values:\n
ommpy 0:d383e2dee0f7 312 * ERROR_CODE_EPERM = EPERM\n
ommpy 0:d383e2dee0f7 313 * ERROR_EPERM = -EPERM\n
ommpy 0:d383e2dee0f7 314 *
ommpy 0:d383e2dee0f7 315 * POSIX Error codes are defined using the macro MBED_DEFINE_POSIX_ERROR\n
ommpy 0:d383e2dee0f7 316 * For example MBED_DEFINE_POSIX_ERROR( EPERM, EPERM ). This macro defines the following values:\n
ommpy 0:d383e2dee0f7 317 * ERROR_CODE_EPERM = MBED_POSIX_ERROR_BASE+EPERM\n
ommpy 0:d383e2dee0f7 318 * ERROR_EPERM = -(MBED_POSIX_ERROR_BASE+EPERM)\n
ommpy 0:d383e2dee0f7 319 * Its effectively equivalent to:\n
ommpy 0:d383e2dee0f7 320 * ERROR_CODE_EPERM = 1\n
ommpy 0:d383e2dee0f7 321 * ERROR_EPERM = -1\n
ommpy 0:d383e2dee0f7 322 * All POSIX error codes currently supported by MbedOS(defined in mbed_retarget.h) are defined using the MBED_DEFINE_POSIX_ERROR macro.\n\n
ommpy 0:d383e2dee0f7 323 * Below are the POSIX error codes and the description:\n
ommpy 0:d383e2dee0f7 324 * \verbatim
ommpy 0:d383e2dee0f7 325 EPERM 1 Operation not permitted
ommpy 0:d383e2dee0f7 326 ENOENT 2 No such file or directory
ommpy 0:d383e2dee0f7 327 ESRCH 3 No such process
ommpy 0:d383e2dee0f7 328 EINTR 4 Interrupted system call
ommpy 0:d383e2dee0f7 329 EIO 5 I/O error
ommpy 0:d383e2dee0f7 330 ENXIO 6 No such device or address
ommpy 0:d383e2dee0f7 331 E2BIG 7 Argument list too long
ommpy 0:d383e2dee0f7 332 ENOEXEC 8 Exec format error
ommpy 0:d383e2dee0f7 333 EBADF 9 Bad file number
ommpy 0:d383e2dee0f7 334 ECHILD 10 No child processes
ommpy 0:d383e2dee0f7 335 EAGAIN 11 Try again
ommpy 0:d383e2dee0f7 336 ENOMEM 12 Out of memory
ommpy 0:d383e2dee0f7 337 EACCES 13 Permission denied
ommpy 0:d383e2dee0f7 338 EFAULT 14 Bad address
ommpy 0:d383e2dee0f7 339 ENOTBLK 15 Block device required
ommpy 0:d383e2dee0f7 340 EBUSY 16 Device or resource busy
ommpy 0:d383e2dee0f7 341 EEXIST 17 File exists
ommpy 0:d383e2dee0f7 342 EXDEV 18 Cross-device link
ommpy 0:d383e2dee0f7 343 ENODEV 19 No such device
ommpy 0:d383e2dee0f7 344 ENOTDIR 20 Not a directory
ommpy 0:d383e2dee0f7 345 EISDIR 21 Is a directory
ommpy 0:d383e2dee0f7 346 EINVAL 22 Invalid argument
ommpy 0:d383e2dee0f7 347 ENFILE 23 File table overflow
ommpy 0:d383e2dee0f7 348 EMFILE 24 Too many open files
ommpy 0:d383e2dee0f7 349 ENOTTY 25 Not a typewriter
ommpy 0:d383e2dee0f7 350 ETXTBSY 26 Text file busy
ommpy 0:d383e2dee0f7 351 EFBIG 27 File too large
ommpy 0:d383e2dee0f7 352 ENOSPC 28 No space left on device
ommpy 0:d383e2dee0f7 353 ESPIPE 29 Illegal seek
ommpy 0:d383e2dee0f7 354 EROFS 30 Read-only file system
ommpy 0:d383e2dee0f7 355 EMLINK 31 Too many links
ommpy 0:d383e2dee0f7 356 EPIPE 32 Broken pipe
ommpy 0:d383e2dee0f7 357 EDOM 33 Math argument out of domain of func
ommpy 0:d383e2dee0f7 358 ERANGE 34 Math result not representable
ommpy 0:d383e2dee0f7 359 EDEADLK 35 Resource deadlock would occur
ommpy 0:d383e2dee0f7 360 ENAMETOOLONG 36 File name too long
ommpy 0:d383e2dee0f7 361 ENOLCK 37 No record locks available
ommpy 0:d383e2dee0f7 362 ENOSYS 38 Function not implemented
ommpy 0:d383e2dee0f7 363 ENOTEMPTY 39 Directory not empty
ommpy 0:d383e2dee0f7 364 ELOOP 40 Too many symbolic links encountered
ommpy 0:d383e2dee0f7 365 EWOULDBLOCK EAGAIN Operation would block
ommpy 0:d383e2dee0f7 366 ENOMSG 42 No message of desired type
ommpy 0:d383e2dee0f7 367 EIDRM 43 Identifier removed
ommpy 0:d383e2dee0f7 368 ECHRNG 44 Channel number out of range
ommpy 0:d383e2dee0f7 369 EL2NSYNC 45 Level 2 not synchronized
ommpy 0:d383e2dee0f7 370 EL3HLT 46 Level 3 halted
ommpy 0:d383e2dee0f7 371 EL3RST 47 Level 3 reset
ommpy 0:d383e2dee0f7 372 ELNRNG 48 Link number out of range
ommpy 0:d383e2dee0f7 373 EUNATCH 49 Protocol driver not attached
ommpy 0:d383e2dee0f7 374 ENOCSI 50 No CSI structure available
ommpy 0:d383e2dee0f7 375 EL2HLT 51 Level 2 halted
ommpy 0:d383e2dee0f7 376 EBADE 52 Invalid exchange
ommpy 0:d383e2dee0f7 377 EBADR 53 Invalid request descriptor
ommpy 0:d383e2dee0f7 378 EXFULL 54 Exchange full
ommpy 0:d383e2dee0f7 379 ENOANO 55 No anode
ommpy 0:d383e2dee0f7 380 EBADRQC 56 Invalid request code
ommpy 0:d383e2dee0f7 381 EBADSLT 57 Invalid slot
ommpy 0:d383e2dee0f7 382 EDEADLOCK EDEADLK Resource deadlock would occur
ommpy 0:d383e2dee0f7 383 EBFONT 59 Bad font file format
ommpy 0:d383e2dee0f7 384 ENOSTR 60 Device not a stream
ommpy 0:d383e2dee0f7 385 ENODATA 61 No data available
ommpy 0:d383e2dee0f7 386 ETIME 62 Timer expired
ommpy 0:d383e2dee0f7 387 ENOSR 63 Out of streams resources
ommpy 0:d383e2dee0f7 388 ENONET 64 Machine is not on the network
ommpy 0:d383e2dee0f7 389 ENOPKG 65 Package not installed
ommpy 0:d383e2dee0f7 390 EREMOTE 66 Object is remote
ommpy 0:d383e2dee0f7 391 ENOLINK 67 Link has been severed
ommpy 0:d383e2dee0f7 392 EADV 68 Advertise error
ommpy 0:d383e2dee0f7 393 ESRMNT 69 Srmount error
ommpy 0:d383e2dee0f7 394 ECOMM 70 Communication error on send
ommpy 0:d383e2dee0f7 395 EPROTO 71 Protocol error
ommpy 0:d383e2dee0f7 396 EMULTIHOP 72 Multihop attempted
ommpy 0:d383e2dee0f7 397 EDOTDOT 73 RFS specific error
ommpy 0:d383e2dee0f7 398 EBADMSG 74 Not a data message
ommpy 0:d383e2dee0f7 399 EOVERFLOW 75 Value too large for defined data type
ommpy 0:d383e2dee0f7 400 ENOTUNIQ 76 Name not unique on network
ommpy 0:d383e2dee0f7 401 EBADFD 77 File descriptor in bad state
ommpy 0:d383e2dee0f7 402 EREMCHG 78 Remote address changed
ommpy 0:d383e2dee0f7 403 ELIBACC 79 Can not access a needed shared library
ommpy 0:d383e2dee0f7 404 ELIBBAD 80 Accessing a corrupted shared library
ommpy 0:d383e2dee0f7 405 ELIBSCN 81 .lib section in a.out corrupted
ommpy 0:d383e2dee0f7 406 ELIBMAX 82 Attempting to link in too many shared libraries
ommpy 0:d383e2dee0f7 407 ELIBEXEC 83 Cannot exec a shared library directly
ommpy 0:d383e2dee0f7 408 EILSEQ 84 Illegal byte sequence
ommpy 0:d383e2dee0f7 409 ERESTART 85 Interrupted system call should be restarted
ommpy 0:d383e2dee0f7 410 ESTRPIPE 86 Streams pipe error
ommpy 0:d383e2dee0f7 411 EUSERS 87 Too many users
ommpy 0:d383e2dee0f7 412 ENOTSOCK 88 Socket operation on non-socket
ommpy 0:d383e2dee0f7 413 EDESTADDRREQ 89 Destination address required
ommpy 0:d383e2dee0f7 414 EMSGSIZE 90 Message too long
ommpy 0:d383e2dee0f7 415 EPROTOTYPE 91 Protocol wrong type for socket
ommpy 0:d383e2dee0f7 416 ENOPROTOOPT 92 Protocol not available
ommpy 0:d383e2dee0f7 417 EPROTONOSUPPORT 93 Protocol not supported
ommpy 0:d383e2dee0f7 418 ESOCKTNOSUPPORT 94 Socket type not supported
ommpy 0:d383e2dee0f7 419 EOPNOTSUPP 95 Operation not supported on transport endpoint
ommpy 0:d383e2dee0f7 420 EPFNOSUPPORT 96 Protocol family not supported
ommpy 0:d383e2dee0f7 421 EAFNOSUPPORT 97 Address family not supported by protocol
ommpy 0:d383e2dee0f7 422 EADDRINUSE 98 Address already in use
ommpy 0:d383e2dee0f7 423 EADDRNOTAVAIL 99 Cannot assign requested address
ommpy 0:d383e2dee0f7 424 ENETDOWN 100 Network is down
ommpy 0:d383e2dee0f7 425 ENETUNREACH 101 Network is unreachable
ommpy 0:d383e2dee0f7 426 ENETRESET 102 Network dropped connection because of reset
ommpy 0:d383e2dee0f7 427 ECONNABORTED 103 Software caused connection abort
ommpy 0:d383e2dee0f7 428 ECONNRESET 104 Connection reset by peer
ommpy 0:d383e2dee0f7 429 ENOBUFS 105 No buffer space available
ommpy 0:d383e2dee0f7 430 EISCONN 106 Transport endpoint is already connected
ommpy 0:d383e2dee0f7 431 ENOTCONN 107 Transport endpoint is not connected
ommpy 0:d383e2dee0f7 432 ESHUTDOWN 108 Cannot send after transport endpoint shutdown
ommpy 0:d383e2dee0f7 433 ETOOMANYREFS 109 Too many references: cannot splice
ommpy 0:d383e2dee0f7 434 ETIMEDOUT 110 Connection timed out
ommpy 0:d383e2dee0f7 435 ECONNREFUSED 111 Connection refused
ommpy 0:d383e2dee0f7 436 EHOSTDOWN 112 Host is down
ommpy 0:d383e2dee0f7 437 EHOSTUNREACH 113 No route to host
ommpy 0:d383e2dee0f7 438 EALREADY 114 Operation already in progress
ommpy 0:d383e2dee0f7 439 EINPROGRESS 115 Operation now in progress
ommpy 0:d383e2dee0f7 440 ESTALE 116 Stale NFS file handle
ommpy 0:d383e2dee0f7 441 EUCLEAN 117 Structure needs cleaning
ommpy 0:d383e2dee0f7 442 ENOTNAM 118 Not a XENIX named type file
ommpy 0:d383e2dee0f7 443 ENAVAIL 119 No XENIX semaphores available
ommpy 0:d383e2dee0f7 444 EISNAM 120 Is a named type file
ommpy 0:d383e2dee0f7 445 EREMOTEIO 121 Remote I/O error
ommpy 0:d383e2dee0f7 446 EDQUOT 122 Quota exceeded
ommpy 0:d383e2dee0f7 447 ENOMEDIUM 123 No medium found
ommpy 0:d383e2dee0f7 448 EMEDIUMTYPE 124 Wrong medium type
ommpy 0:d383e2dee0f7 449 ECANCELED 125 Operation Canceled
ommpy 0:d383e2dee0f7 450 ENOKEY 126 Required key not available
ommpy 0:d383e2dee0f7 451 EKEYEXPIRED 127 Key has expired
ommpy 0:d383e2dee0f7 452 EKEYREVOKED 128 Key has been revoked
ommpy 0:d383e2dee0f7 453 EKEYREJECTED 129 Key was rejected by service
ommpy 0:d383e2dee0f7 454 EOWNERDEAD 130 Owner died
ommpy 0:d383e2dee0f7 455 ENOTRECOVERABLE 131 State not recoverable
ommpy 0:d383e2dee0f7 456 \endverbatim
ommpy 0:d383e2dee0f7 457 *
ommpy 0:d383e2dee0f7 458 * @note
ommpy 0:d383e2dee0f7 459 * MbedOS System Error codes are defined using the macro MBED_DEFINE_SYSTEM_ERROR\n
ommpy 0:d383e2dee0f7 460 * For example MBED_DEFINE_SYSTEM_ERROR( INVALID_ARGUMENT ,1 ) macro defines the following values:\n
ommpy 0:d383e2dee0f7 461 * ERROR_CODE_INVALID_ARGUMENT = MBED_SYSTEM_ERROR_BASE+1\n
ommpy 0:d383e2dee0f7 462 * ERROR_INVALID_ARGUMENT = MAKE_MBED_ERROR(ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, ERROR_CODE_INVALID_ARGUMENT)\n
ommpy 0:d383e2dee0f7 463 * Its effectively equivalent to:\n
ommpy 0:d383e2dee0f7 464 * ERROR_CODE_INVALID_ARGUMENT = 1\n
ommpy 0:d383e2dee0f7 465 * ERROR_INVALID_ARGUMENT = 0x80FF0001\n (Note that MODULE field is set to MBED_MODULE_UNKNOWN)
ommpy 0:d383e2dee0f7 466 * New System Error codes should be defined using MBED_DEFINE_SYSTEM_ERROR macro and must have an unique error code value\n
ommpy 0:d383e2dee0f7 467 * passed as the second argument in the MBED_DEFINE_SYSTEM_ERROR macro.\n\n
ommpy 0:d383e2dee0f7 468 * Below are the Mbed System error codes and the description:
ommpy 0:d383e2dee0f7 469 * \verbatim
ommpy 0:d383e2dee0f7 470 UNKNOWN 256 Unknown error
ommpy 0:d383e2dee0f7 471 INVALID_ARGUMENT 257 Invalid Argument
ommpy 0:d383e2dee0f7 472 INVALID_DATA 258 Invalid data
ommpy 0:d383e2dee0f7 473 INVALID_FORMAT 259 Invalid format
ommpy 0:d383e2dee0f7 474 INVALID_INDEX 260 Invalid Index
ommpy 0:d383e2dee0f7 475 INVALID_SIZE 261 Invalid Size
ommpy 0:d383e2dee0f7 476 INVALID_OPERATION 262 Invalid Operation
ommpy 0:d383e2dee0f7 477 NOT_FOUND 263 Not Found
ommpy 0:d383e2dee0f7 478 ACCESS_DENIED 264 Access Denied
ommpy 0:d383e2dee0f7 479 NOT_SUPPORTED 265 Not supported
ommpy 0:d383e2dee0f7 480 BUFFER_FULL 266 Buffer Full
ommpy 0:d383e2dee0f7 481 MEDIA_FULL 267 Media/Disk Full
ommpy 0:d383e2dee0f7 482 ALREADY_IN_USE 268 Already in use
ommpy 0:d383e2dee0f7 483 TIMEOUT 269 Timeout error
ommpy 0:d383e2dee0f7 484 NOT_READY 270 Not Ready
ommpy 0:d383e2dee0f7 485 FAILED_OPERATION 271 Requested Operation failed
ommpy 0:d383e2dee0f7 486 OPERATION_PROHIBITED 272 Operation prohibited
ommpy 0:d383e2dee0f7 487 OPERATION_ABORTED 273 Operation failed
ommpy 0:d383e2dee0f7 488 WRITE_PROTECTED 274 Attempt to write to write-protected resource
ommpy 0:d383e2dee0f7 489 NO_RESPONSE 275 No response
ommpy 0:d383e2dee0f7 490 SEMAPHORE_LOCK_FAILED 276 Semaphore lock failed
ommpy 0:d383e2dee0f7 491 MUTEX_LOCK_FAILED 277 Mutex lock failed
ommpy 0:d383e2dee0f7 492 SEMAPHORE_UNLOCK_FAILED 278 Semaphore unlock failed
ommpy 0:d383e2dee0f7 493 MUTEX_UNLOCK_FAILED 279 Mutex unlock failed
ommpy 0:d383e2dee0f7 494 CRC_ERROR 280 CRC error or mismatch
ommpy 0:d383e2dee0f7 495 OPEN_FAILED 281 Open failed
ommpy 0:d383e2dee0f7 496 CLOSE_FAILED 282 Close failed
ommpy 0:d383e2dee0f7 497 READ_FAILED 283 Read failed
ommpy 0:d383e2dee0f7 498 WRITE_FAILED 284 Write failed
ommpy 0:d383e2dee0f7 499 INITIALIZATION_FAILED 285 Initialization failed
ommpy 0:d383e2dee0f7 500 BOOT_FAILURE 286 Boot failure
ommpy 0:d383e2dee0f7 501 OUT_OF_MEMORY 287 Out of memory
ommpy 0:d383e2dee0f7 502 OUT_OF_RESOURCES 288 Out of resources
ommpy 0:d383e2dee0f7 503 ALLOC_FAILED 289 Alloc failed
ommpy 0:d383e2dee0f7 504 FREE_FAILED 290 Free failed
ommpy 0:d383e2dee0f7 505 OVERFLOW 291 Overflow error
ommpy 0:d383e2dee0f7 506 UNDERFLOW 292 Underflow error
ommpy 0:d383e2dee0f7 507 STACK_OVERFLOW 293 Stack overflow error
ommpy 0:d383e2dee0f7 508 ISR_QUEUE_OVERFLOW 294 ISR queue overflow
ommpy 0:d383e2dee0f7 509 TIMER_QUEUE_OVERFLOW 295 Timer Queue overflow
ommpy 0:d383e2dee0f7 510 CLIB_SPACE_UNAVAILABLE 296 Standard library error - Space unavailable
ommpy 0:d383e2dee0f7 511 CLIB_EXCEPTION 297 Standard library error - Exception
ommpy 0:d383e2dee0f7 512 CLIB_MUTEX_INIT_FAILURE 298 Standard library error - Mutex Init failure
ommpy 0:d383e2dee0f7 513 CREATE_FAILED 299 Create failed
ommpy 0:d383e2dee0f7 514 DELETE_FAILED 300 Delete failed
ommpy 0:d383e2dee0f7 515 THREAD_CREATE_FAILED 301 Thread Create failed
ommpy 0:d383e2dee0f7 516 THREAD_DELETE_FAILED 302 Thread Delete failed
ommpy 0:d383e2dee0f7 517 PROHIBITED_IN_ISR_CONTEXT 303 Operation Prohibited in ISR context
ommpy 0:d383e2dee0f7 518 PINMAP_INVALID 304 Pinmap Invalid
ommpy 0:d383e2dee0f7 519 RTOS_EVENT 305 Unknown Rtos Error
ommpy 0:d383e2dee0f7 520 RTOS_THREAD_EVENT 306 Rtos Thread Error
ommpy 0:d383e2dee0f7 521 RTOS_MUTEX_EVENT 307 Rtos Mutex Error
ommpy 0:d383e2dee0f7 522 RTOS_SEMAPHORE_EVENT 308 Rtos Semaphore Error
ommpy 0:d383e2dee0f7 523 RTOS_MEMORY_POOL_EVENT 309 Rtos Memory Pool Error
ommpy 0:d383e2dee0f7 524 RTOS_TIMER_EVENT 310 Rtos Timer Error
ommpy 0:d383e2dee0f7 525 RTOS_EVENT_FLAGS_EVENT 311 Rtos Event flags Error
ommpy 0:d383e2dee0f7 526 RTOS_MESSAGE_QUEUE_EVENT 312 Rtos Message queue Error
ommpy 0:d383e2dee0f7 527 DEVICE_BUSY 313 Device Busy
ommpy 0:d383e2dee0f7 528 CONFIG_UNSUPPORTED 314 Configuration not supported
ommpy 0:d383e2dee0f7 529 CONFIG_MISMATCH 315 Configuration mismatch
ommpy 0:d383e2dee0f7 530 ALREADY_INITIALIZED 316 Already initialized
ommpy 0:d383e2dee0f7 531 HARDFAULT_EXCEPTION 317 HardFault exception
ommpy 0:d383e2dee0f7 532 MEMMANAGE_EXCEPTION 318 MemManage exception
ommpy 0:d383e2dee0f7 533 BUSFAULT_EXCEPTION 319 BusFault exception
ommpy 0:d383e2dee0f7 534 USAGEFAULT_EXCEPTION 320 UsageFault exception
ommpy 0:d383e2dee0f7 535 BLE_NO_FRAME_INITIALIZED, 321 BLE No frame initialized
ommpy 0:d383e2dee0f7 536 BLE_BACKEND_CREATION_FAILED 322 BLE Backend creation failed
ommpy 0:d383e2dee0f7 537 BLE_BACKEND_NOT_INITIALIZED 323 BLE Backend not initialized
ommpy 0:d383e2dee0f7 538 ASSERTION_FAILED 324 Assertion Failed
ommpy 0:d383e2dee0f7 539 AUTHENTICATION_FAILED 325 Authentication Failed
ommpy 0:d383e2dee0f7 540 RBP_AUTHENTICATION_FAILED 326 Rollback Protect Authentication Failed
ommpy 0:d383e2dee0f7 541 \endverbatim
ommpy 0:d383e2dee0f7 542 *
ommpy 0:d383e2dee0f7 543 * @note
ommpy 0:d383e2dee0f7 544 * Custom Error codes can be defined using the macro DEFINE_CUSTOM_ERROR\n
ommpy 0:d383e2dee0f7 545 * This is mainly meant to capture non-generic error codes specific to a device.
ommpy 0:d383e2dee0f7 546 * For example DEFINE_CUSTOM_ERROR( MY_CUSTOM_ERROR ,1 ) macro defines the following values:\n
ommpy 0:d383e2dee0f7 547 * ERROR_CODE_MY_CUSTOM_ERROR = MBED_CUSTOM_ERROR_BASE+1\n
ommpy 0:d383e2dee0f7 548 * ERROR_MY_CUSTOM_ERROR = MAKE_MBED_ERROR(ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, ERROR_CODE_MY_CUSTOM_ERROR)\n
ommpy 0:d383e2dee0f7 549 * Its effectively equivalent to:\n
ommpy 0:d383e2dee0f7 550 * ERROR_CODE_MY_CUSTOM_ERROR = 4097\n
ommpy 0:d383e2dee0f7 551 * ERROR_MY_CUSTOM_ERROR = 0xA0FF1001\n (Note that MODULE field is set to MBED_MODULE_UNKNOWN) \n\n
ommpy 0:d383e2dee0f7 552 *
ommpy 0:d383e2dee0f7 553 * @note
ommpy 0:d383e2dee0f7 554 * **Using error codes:** \n
ommpy 0:d383e2dee0f7 555 * POSIX error codes may be used in modules/functions currently using POSIX error codes and switching them to Mbed-OS error codes
ommpy 0:d383e2dee0f7 556 * may cause interoperability issues. For example, some of the filesystem, network stack implementations may need to use
ommpy 0:d383e2dee0f7 557 * POSIX error codes in order to keep them compatible with other modules interfacing with them, and may continue to use POSIX error codes.
ommpy 0:d383e2dee0f7 558 *
ommpy 0:d383e2dee0f7 559 * In all other cases, like for any native development of Mbed-OS modules Mbed-OS error codes should be used.
ommpy 0:d383e2dee0f7 560 * This makes it easy to use Mbed-OS error reporting/logging infrastructure and makes debugging error scenarios
ommpy 0:d383e2dee0f7 561 * much more efficient.
ommpy 0:d383e2dee0f7 562 *
ommpy 0:d383e2dee0f7 563 * @note
ommpy 0:d383e2dee0f7 564 * **Searching for error codes in mbed-os source tree:** \n
ommpy 0:d383e2dee0f7 565 * If you get an error report as below which you want to search for in mbed-os source tree, first take note of "Error Code" number. \n
ommpy 0:d383e2dee0f7 566 * For example, the below error report has an error code of \b 259. Find the error name associated with the error code and in this case its \b INVALID_FORMAT. \n
ommpy 0:d383e2dee0f7 567 * Use that error name(\b INVALID_FORMAT) to search the source tree for code locations setting that specific error code. \n
ommpy 0:d383e2dee0f7 568 * If the Error module reported is not 255(which indicates unknown module), you can also use that to narrow down to the specific component reporting the error.
ommpy 0:d383e2dee0f7 569 * See mbed_module_type_t enum above for module mapping. \n
ommpy 0:d383e2dee0f7 570 *
ommpy 0:d383e2dee0f7 571 * \verbatim
ommpy 0:d383e2dee0f7 572 ++ MbedOS Error Info ++
ommpy 0:d383e2dee0f7 573 Error Status: 0x80FF013D Code: 317 Module: 255
ommpy 0:d383e2dee0f7 574 Error Message: Fault exception
ommpy 0:d383e2dee0f7 575 Location: 0x5CD1
ommpy 0:d383e2dee0f7 576 Error Value: 0x4A2A
ommpy 0:d383e2dee0f7 577 Current Thread: Id: 0x20001E80 Entry: 0x5EB1 StackSize: 0x1000 StackMem: 0x20000E80 SP: 0x2002FF90
ommpy 0:d383e2dee0f7 578 For more info, visit: https://mbed.com/s/error?error=0x80FF013D&mbedos=999999&core=0x410FC241&compile=1&ver=5060528
ommpy 0:d383e2dee0f7 579 -- MbedOS Error Info --
ommpy 0:d383e2dee0f7 580 \endverbatim
ommpy 0:d383e2dee0f7 581 */
ommpy 0:d383e2dee0f7 582
ommpy 0:d383e2dee0f7 583 typedef enum _mbed_error_code {
ommpy 0:d383e2dee0f7 584 //Below are POSIX ERROR CODE definitions, which starts at MBED_POSIX_ERROR_BASE(=0)
ommpy 0:d383e2dee0f7 585 //POSIX ERROR CODE definitions starts at offset 0(MBED_POSIX_ERROR_BASE) to align them with actual POSIX Error Code
ommpy 0:d383e2dee0f7 586 //defintions in mbed_retarget.h
ommpy 0:d383e2dee0f7 587 // Error Name Error Code
ommpy 0:d383e2dee0f7 588 MBED_DEFINE_POSIX_ERROR(EPERM, EPERM), /* 1 Operation not permitted */
ommpy 0:d383e2dee0f7 589 MBED_DEFINE_POSIX_ERROR(ENOENT, ENOENT), /* 2 No such file or directory */
ommpy 0:d383e2dee0f7 590 MBED_DEFINE_POSIX_ERROR(ESRCH, ESRCH), /* 3 No such process */
ommpy 0:d383e2dee0f7 591 MBED_DEFINE_POSIX_ERROR(EINTR, EINTR), /* 4 Interrupted system call */
ommpy 0:d383e2dee0f7 592 MBED_DEFINE_POSIX_ERROR(EIO, EIO), /* 5 I/O error */
ommpy 0:d383e2dee0f7 593 MBED_DEFINE_POSIX_ERROR(ENXIO, ENXIO), /* 6 No such device or address */
ommpy 0:d383e2dee0f7 594 MBED_DEFINE_POSIX_ERROR(E2BIG, E2BIG), /* 7 Argument list too long */
ommpy 0:d383e2dee0f7 595 MBED_DEFINE_POSIX_ERROR(ENOEXEC, ENOEXEC), /* 8 Exec format error */
ommpy 0:d383e2dee0f7 596 MBED_DEFINE_POSIX_ERROR(EBADF, EBADF), /* 9 Bad file number */
ommpy 0:d383e2dee0f7 597 MBED_DEFINE_POSIX_ERROR(ECHILD, ECHILD), /* 10 No child processes */
ommpy 0:d383e2dee0f7 598 MBED_DEFINE_POSIX_ERROR(EAGAIN, EAGAIN), /* 11 Try again */
ommpy 0:d383e2dee0f7 599 MBED_DEFINE_POSIX_ERROR(ENOMEM, ENOMEM), /* 12 Out of memory */
ommpy 0:d383e2dee0f7 600 MBED_DEFINE_POSIX_ERROR(EACCES, EACCES), /* 13 Permission denied */
ommpy 0:d383e2dee0f7 601 MBED_DEFINE_POSIX_ERROR(EFAULT, EFAULT), /* 14 Bad address */
ommpy 0:d383e2dee0f7 602 MBED_DEFINE_POSIX_ERROR(ENOTBLK, ENOTBLK), /* 15 Block device required */
ommpy 0:d383e2dee0f7 603 MBED_DEFINE_POSIX_ERROR(EBUSY, EBUSY), /* 16 Device or resource busy */
ommpy 0:d383e2dee0f7 604 MBED_DEFINE_POSIX_ERROR(EEXIST, EEXIST), /* 17 File exists */
ommpy 0:d383e2dee0f7 605 MBED_DEFINE_POSIX_ERROR(EXDEV, EXDEV), /* 18 Cross-device link */
ommpy 0:d383e2dee0f7 606 MBED_DEFINE_POSIX_ERROR(ENODEV, ENODEV), /* 19 No such device */
ommpy 0:d383e2dee0f7 607 MBED_DEFINE_POSIX_ERROR(ENOTDIR, ENOTDIR), /* 20 Not a directory */
ommpy 0:d383e2dee0f7 608 MBED_DEFINE_POSIX_ERROR(EISDIR, EISDIR), /* 21 Is a directory */
ommpy 0:d383e2dee0f7 609 MBED_DEFINE_POSIX_ERROR(EINVAL, EINVAL), /* 22 Invalid argument */
ommpy 0:d383e2dee0f7 610 MBED_DEFINE_POSIX_ERROR(ENFILE, ENFILE), /* 23 File table overflow */
ommpy 0:d383e2dee0f7 611 MBED_DEFINE_POSIX_ERROR(EMFILE, EMFILE), /* 24 Too many open files */
ommpy 0:d383e2dee0f7 612 MBED_DEFINE_POSIX_ERROR(ENOTTY, ENOTTY), /* 25 Not a typewriter */
ommpy 0:d383e2dee0f7 613 MBED_DEFINE_POSIX_ERROR(ETXTBSY, ETXTBSY), /* 26 Text file busy */
ommpy 0:d383e2dee0f7 614 MBED_DEFINE_POSIX_ERROR(EFBIG, EFBIG), /* 27 File too large */
ommpy 0:d383e2dee0f7 615 MBED_DEFINE_POSIX_ERROR(ENOSPC, ENOSPC), /* 28 No space left on device */
ommpy 0:d383e2dee0f7 616 MBED_DEFINE_POSIX_ERROR(ESPIPE, ESPIPE), /* 29 Illegal seek */
ommpy 0:d383e2dee0f7 617 MBED_DEFINE_POSIX_ERROR(EROFS, EROFS), /* 30 Read-only file system */
ommpy 0:d383e2dee0f7 618 MBED_DEFINE_POSIX_ERROR(EMLINK, EMLINK), /* 31 Too many links */
ommpy 0:d383e2dee0f7 619 MBED_DEFINE_POSIX_ERROR(EPIPE, EPIPE), /* 32 Broken pipe */
ommpy 0:d383e2dee0f7 620 MBED_DEFINE_POSIX_ERROR(EDOM, EDOM), /* 33 Math argument out of domain of func */
ommpy 0:d383e2dee0f7 621 MBED_DEFINE_POSIX_ERROR(ERANGE, ERANGE), /* 34 Math result not representable */
ommpy 0:d383e2dee0f7 622 MBED_DEFINE_POSIX_ERROR(EDEADLK, EDEADLK), /* 35 Resource deadlock would occur */
ommpy 0:d383e2dee0f7 623 MBED_DEFINE_POSIX_ERROR(ENAMETOOLONG, ENAMETOOLONG), /* 36 File name too long */
ommpy 0:d383e2dee0f7 624 MBED_DEFINE_POSIX_ERROR(ENOLCK, ENOLCK), /* 37 No record locks available */
ommpy 0:d383e2dee0f7 625 MBED_DEFINE_POSIX_ERROR(ENOSYS, ENOSYS), /* 38 Function not implemented */
ommpy 0:d383e2dee0f7 626 MBED_DEFINE_POSIX_ERROR(ENOTEMPTY, ENOTEMPTY), /* 39 Directory not empty */
ommpy 0:d383e2dee0f7 627 MBED_DEFINE_POSIX_ERROR(ELOOP, ELOOP), /* 40 Too many symbolic links encountered */
ommpy 0:d383e2dee0f7 628 MBED_DEFINE_POSIX_ERROR(EWOULDBLOCK, EAGAIN), /* EAGAIN Operation would block */
ommpy 0:d383e2dee0f7 629 MBED_DEFINE_POSIX_ERROR(ENOMSG, ENOMSG), /* 42 No message of desired type */
ommpy 0:d383e2dee0f7 630 MBED_DEFINE_POSIX_ERROR(EIDRM, EIDRM), /* 43 Identifier removed */
ommpy 0:d383e2dee0f7 631 MBED_DEFINE_POSIX_ERROR(ECHRNG, ECHRNG), /* 44 Channel number out of range */
ommpy 0:d383e2dee0f7 632 MBED_DEFINE_POSIX_ERROR(EL2NSYNC, EL2NSYNC), /* 45 Level 2 not synchronized */
ommpy 0:d383e2dee0f7 633 MBED_DEFINE_POSIX_ERROR(EL3HLT, EL3HLT), /* 46 Level 3 halted */
ommpy 0:d383e2dee0f7 634 MBED_DEFINE_POSIX_ERROR(EL3RST, EL3RST), /* 47 Level 3 reset */
ommpy 0:d383e2dee0f7 635 MBED_DEFINE_POSIX_ERROR(ELNRNG, ELNRNG), /* 48 Link number out of range */
ommpy 0:d383e2dee0f7 636 MBED_DEFINE_POSIX_ERROR(EUNATCH, EUNATCH), /* 49 Protocol driver not attached */
ommpy 0:d383e2dee0f7 637 MBED_DEFINE_POSIX_ERROR(ENOCSI, ENOCSI), /* 50 No CSI structure available */
ommpy 0:d383e2dee0f7 638 MBED_DEFINE_POSIX_ERROR(EL2HLT, EL2HLT), /* 51 Level 2 halted */
ommpy 0:d383e2dee0f7 639 MBED_DEFINE_POSIX_ERROR(EBADE, EBADE), /* 52 Invalid exchange */
ommpy 0:d383e2dee0f7 640 MBED_DEFINE_POSIX_ERROR(EBADR, EBADR), /* 53 Invalid request descriptor */
ommpy 0:d383e2dee0f7 641 MBED_DEFINE_POSIX_ERROR(EXFULL, EXFULL), /* 54 Exchange full */
ommpy 0:d383e2dee0f7 642 MBED_DEFINE_POSIX_ERROR(ENOANO, ENOANO), /* 55 No anode */
ommpy 0:d383e2dee0f7 643 MBED_DEFINE_POSIX_ERROR(EBADRQC, EBADRQC), /* 56 Invalid request code */
ommpy 0:d383e2dee0f7 644 MBED_DEFINE_POSIX_ERROR(EBADSLT, EBADSLT), /* 57 Invalid slot */
ommpy 0:d383e2dee0f7 645 MBED_DEFINE_POSIX_ERROR(EDEADLOCK, EDEADLK), /* EDEADLK Resource deadlock would occur */
ommpy 0:d383e2dee0f7 646 MBED_DEFINE_POSIX_ERROR(EBFONT, EBFONT), /* 59 Bad font file format */
ommpy 0:d383e2dee0f7 647 MBED_DEFINE_POSIX_ERROR(ENOSTR, ENOSTR), /* 60 Device not a stream */
ommpy 0:d383e2dee0f7 648 MBED_DEFINE_POSIX_ERROR(ENODATA, ENODATA), /* 61 No data available */
ommpy 0:d383e2dee0f7 649 MBED_DEFINE_POSIX_ERROR(ETIME, ETIME), /* 62 Timer expired */
ommpy 0:d383e2dee0f7 650 MBED_DEFINE_POSIX_ERROR(ENOSR, ENOSR), /* 63 Out of streams resources */
ommpy 0:d383e2dee0f7 651 MBED_DEFINE_POSIX_ERROR(ENONET, ENONET), /* 64 Machine is not on the network */
ommpy 0:d383e2dee0f7 652 MBED_DEFINE_POSIX_ERROR(ENOPKG, ENOPKG), /* 65 Package not installed */
ommpy 0:d383e2dee0f7 653 MBED_DEFINE_POSIX_ERROR(EREMOTE, EREMOTE), /* 66 Object is remote */
ommpy 0:d383e2dee0f7 654 MBED_DEFINE_POSIX_ERROR(ENOLINK, ENOLINK), /* 67 Link has been severed */
ommpy 0:d383e2dee0f7 655 MBED_DEFINE_POSIX_ERROR(EADV, EADV), /* 68 Advertise error */
ommpy 0:d383e2dee0f7 656 MBED_DEFINE_POSIX_ERROR(ESRMNT, ESRMNT), /* 69 Srmount error */
ommpy 0:d383e2dee0f7 657 MBED_DEFINE_POSIX_ERROR(ECOMM, ECOMM), /* 70 Communication error on send */
ommpy 0:d383e2dee0f7 658 MBED_DEFINE_POSIX_ERROR(EPROTO, EPROTO), /* 71 Protocol error */
ommpy 0:d383e2dee0f7 659 MBED_DEFINE_POSIX_ERROR(EMULTIHOP, EMULTIHOP), /* 72 Multihop attempted */
ommpy 0:d383e2dee0f7 660 MBED_DEFINE_POSIX_ERROR(EDOTDOT, EDOTDOT), /* 73 RFS specific error */
ommpy 0:d383e2dee0f7 661 MBED_DEFINE_POSIX_ERROR(EBADMSG, EBADMSG), /* 74 Not a data message */
ommpy 0:d383e2dee0f7 662 MBED_DEFINE_POSIX_ERROR(EOVERFLOW, EOVERFLOW), /* 75 Value too large for defined data type */
ommpy 0:d383e2dee0f7 663 MBED_DEFINE_POSIX_ERROR(ENOTUNIQ, ENOTUNIQ), /* 76 Name not unique on network */
ommpy 0:d383e2dee0f7 664 MBED_DEFINE_POSIX_ERROR(EBADFD, EBADFD), /* 77 File descriptor in bad state */
ommpy 0:d383e2dee0f7 665 MBED_DEFINE_POSIX_ERROR(EREMCHG, EREMCHG), /* 78 Remote address changed */
ommpy 0:d383e2dee0f7 666 MBED_DEFINE_POSIX_ERROR(ELIBACC, ELIBACC), /* 79 Can not access a needed shared library */
ommpy 0:d383e2dee0f7 667 MBED_DEFINE_POSIX_ERROR(ELIBBAD, ELIBBAD), /* 80 Accessing a corrupted shared library */
ommpy 0:d383e2dee0f7 668 MBED_DEFINE_POSIX_ERROR(ELIBSCN, ELIBSCN), /* 81 .lib section in a.out corrupted */
ommpy 0:d383e2dee0f7 669 MBED_DEFINE_POSIX_ERROR(ELIBMAX, ELIBMAX), /* 82 Attempting to link in too many shared libraries */
ommpy 0:d383e2dee0f7 670 MBED_DEFINE_POSIX_ERROR(ELIBEXEC, ELIBEXEC), /* 83 Cannot exec a shared library directly */
ommpy 0:d383e2dee0f7 671 MBED_DEFINE_POSIX_ERROR(EILSEQ, EILSEQ), /* 84 Illegal byte sequence */
ommpy 0:d383e2dee0f7 672 MBED_DEFINE_POSIX_ERROR(ERESTART, ERESTART), /* 85 Interrupted system call should be restarted */
ommpy 0:d383e2dee0f7 673 MBED_DEFINE_POSIX_ERROR(ESTRPIPE, ESTRPIPE), /* 86 Streams pipe error */
ommpy 0:d383e2dee0f7 674 MBED_DEFINE_POSIX_ERROR(EUSERS, EUSERS), /* 87 Too many users */
ommpy 0:d383e2dee0f7 675 MBED_DEFINE_POSIX_ERROR(ENOTSOCK, ENOTSOCK), /* 88 Socket operation on non-socket */
ommpy 0:d383e2dee0f7 676 MBED_DEFINE_POSIX_ERROR(EDESTADDRREQ, EDESTADDRREQ), /* 89 Destination address required */
ommpy 0:d383e2dee0f7 677 MBED_DEFINE_POSIX_ERROR(EMSGSIZE, EMSGSIZE), /* 90 Message too long */
ommpy 0:d383e2dee0f7 678 MBED_DEFINE_POSIX_ERROR(EPROTOTYPE, EPROTOTYPE), /* 91 Protocol wrong type for socket */
ommpy 0:d383e2dee0f7 679 MBED_DEFINE_POSIX_ERROR(ENOPROTOOPT, ENOPROTOOPT), /* 92 Protocol not available */
ommpy 0:d383e2dee0f7 680 MBED_DEFINE_POSIX_ERROR(EPROTONOSUPPORT, EPROTONOSUPPORT), /* 93 Protocol not supported */
ommpy 0:d383e2dee0f7 681 MBED_DEFINE_POSIX_ERROR(ESOCKTNOSUPPORT, ESOCKTNOSUPPORT), /* 94 Socket type not supported */
ommpy 0:d383e2dee0f7 682 MBED_DEFINE_POSIX_ERROR(EOPNOTSUPP, EOPNOTSUPP), /* 95 Operation not supported on transport endpoint */
ommpy 0:d383e2dee0f7 683 MBED_DEFINE_POSIX_ERROR(EPFNOSUPPORT, EPFNOSUPPORT), /* 96 Protocol family not supported */
ommpy 0:d383e2dee0f7 684 MBED_DEFINE_POSIX_ERROR(EAFNOSUPPORT, EAFNOSUPPORT), /* 97 Address family not supported by protocol */
ommpy 0:d383e2dee0f7 685 MBED_DEFINE_POSIX_ERROR(EADDRINUSE, EADDRINUSE), /* 98 Address already in use */
ommpy 0:d383e2dee0f7 686 MBED_DEFINE_POSIX_ERROR(EADDRNOTAVAIL, EADDRNOTAVAIL), /* 99 Cannot assign requested address */
ommpy 0:d383e2dee0f7 687 MBED_DEFINE_POSIX_ERROR(ENETDOWN, ENETDOWN), /* 100 Network is down */
ommpy 0:d383e2dee0f7 688 MBED_DEFINE_POSIX_ERROR(ENETUNREACH, ENETUNREACH), /* 101 Network is unreachable */
ommpy 0:d383e2dee0f7 689 MBED_DEFINE_POSIX_ERROR(ENETRESET, ENETRESET), /* 102 Network dropped connection because of reset */
ommpy 0:d383e2dee0f7 690 MBED_DEFINE_POSIX_ERROR(ECONNABORTED, ECONNABORTED), /* 103 Software caused connection abort */
ommpy 0:d383e2dee0f7 691 MBED_DEFINE_POSIX_ERROR(ECONNRESET, ECONNRESET), /* 104 Connection reset by peer */
ommpy 0:d383e2dee0f7 692 MBED_DEFINE_POSIX_ERROR(ENOBUFS, ENOBUFS), /* 105 No buffer space available */
ommpy 0:d383e2dee0f7 693 MBED_DEFINE_POSIX_ERROR(EISCONN, EISCONN), /* 106 Transport endpoint is already connected */
ommpy 0:d383e2dee0f7 694 MBED_DEFINE_POSIX_ERROR(ENOTCONN, ENOTCONN), /* 107 Transport endpoint is not connected */
ommpy 0:d383e2dee0f7 695 MBED_DEFINE_POSIX_ERROR(ESHUTDOWN, ESHUTDOWN), /* 108 Cannot send after transport endpoint shutdown */
ommpy 0:d383e2dee0f7 696 MBED_DEFINE_POSIX_ERROR(ETOOMANYREFS, ETOOMANYREFS), /* 109 Too many references: cannot splice */
ommpy 0:d383e2dee0f7 697 MBED_DEFINE_POSIX_ERROR(ETIMEDOUT, ETIMEDOUT), /* 110 Connection timed out */
ommpy 0:d383e2dee0f7 698 MBED_DEFINE_POSIX_ERROR(ECONNREFUSED, ECONNREFUSED), /* 111 Connection refused */
ommpy 0:d383e2dee0f7 699 MBED_DEFINE_POSIX_ERROR(EHOSTDOWN, EHOSTDOWN), /* 112 Host is down */
ommpy 0:d383e2dee0f7 700 MBED_DEFINE_POSIX_ERROR(EHOSTUNREACH, EHOSTUNREACH), /* 113 No route to host */
ommpy 0:d383e2dee0f7 701 MBED_DEFINE_POSIX_ERROR(EALREADY, EALREADY), /* 114 Operation already in progress */
ommpy 0:d383e2dee0f7 702 MBED_DEFINE_POSIX_ERROR(EINPROGRESS, EINPROGRESS), /* 115 Operation now in progress */
ommpy 0:d383e2dee0f7 703 MBED_DEFINE_POSIX_ERROR(ESTALE, ESTALE), /* 116 Stale NFS file handle */
ommpy 0:d383e2dee0f7 704 MBED_DEFINE_POSIX_ERROR(EUCLEAN, EUCLEAN), /* 117 Structure needs cleaning */
ommpy 0:d383e2dee0f7 705 MBED_DEFINE_POSIX_ERROR(ENOTNAM, ENOTNAM), /* 118 Not a XENIX named type file */
ommpy 0:d383e2dee0f7 706 MBED_DEFINE_POSIX_ERROR(ENAVAIL, ENAVAIL), /* 119 No XENIX semaphores available */
ommpy 0:d383e2dee0f7 707 MBED_DEFINE_POSIX_ERROR(EISNAM, EISNAM), /* 120 Is a named type file */
ommpy 0:d383e2dee0f7 708 MBED_DEFINE_POSIX_ERROR(EREMOTEIO, EREMOTEIO), /* 121 Remote I/O error */
ommpy 0:d383e2dee0f7 709 MBED_DEFINE_POSIX_ERROR(EDQUOT, EDQUOT), /* 122 Quota exceeded */
ommpy 0:d383e2dee0f7 710 MBED_DEFINE_POSIX_ERROR(ENOMEDIUM, ENOMEDIUM), /* 123 No medium found */
ommpy 0:d383e2dee0f7 711 MBED_DEFINE_POSIX_ERROR(EMEDIUMTYPE, EMEDIUMTYPE), /* 124 Wrong medium type */
ommpy 0:d383e2dee0f7 712 MBED_DEFINE_POSIX_ERROR(ECANCELED, ECANCELED), /* 125 Operation Canceled */
ommpy 0:d383e2dee0f7 713 MBED_DEFINE_POSIX_ERROR(ENOKEY, ENOKEY), /* 126 Required key not available */
ommpy 0:d383e2dee0f7 714 MBED_DEFINE_POSIX_ERROR(EKEYEXPIRED, EKEYEXPIRED), /* 127 Key has expired */
ommpy 0:d383e2dee0f7 715 MBED_DEFINE_POSIX_ERROR(EKEYREVOKED, EKEYREVOKED), /* 128 Key has been revoked */
ommpy 0:d383e2dee0f7 716 MBED_DEFINE_POSIX_ERROR(EKEYREJECTED, EKEYREJECTED), /* 129 Key was rejected by service */
ommpy 0:d383e2dee0f7 717 MBED_DEFINE_POSIX_ERROR(EOWNERDEAD, EOWNERDEAD), /* 130 Owner died */
ommpy 0:d383e2dee0f7 718 MBED_DEFINE_POSIX_ERROR(ENOTRECOVERABLE, ENOTRECOVERABLE), /* 131 State not recoverable */
ommpy 0:d383e2dee0f7 719
ommpy 0:d383e2dee0f7 720 //Below are MBED SYSTEM ERROR CODE definitions
ommpy 0:d383e2dee0f7 721 //MBED SYSTEM ERROR CODE definitions starts at offset MBED_SYSTEM_ERROR_BASE, see above.
ommpy 0:d383e2dee0f7 722 // Error Name Error Offset Error Code
ommpy 0:d383e2dee0f7 723 MBED_DEFINE_SYSTEM_ERROR(UNKNOWN, 0), /* 256 Unknown error */
ommpy 0:d383e2dee0f7 724 MBED_DEFINE_SYSTEM_ERROR(INVALID_ARGUMENT, 1), /* 257 Invalid Argument */
ommpy 0:d383e2dee0f7 725 MBED_DEFINE_SYSTEM_ERROR(INVALID_DATA_DETECTED, 2), /* 258 Invalid data detected */
ommpy 0:d383e2dee0f7 726 MBED_DEFINE_SYSTEM_ERROR(INVALID_FORMAT, 3), /* 259 Invalid format */
ommpy 0:d383e2dee0f7 727 MBED_DEFINE_SYSTEM_ERROR(INVALID_INDEX, 4), /* 260 Invalid Index */
ommpy 0:d383e2dee0f7 728 MBED_DEFINE_SYSTEM_ERROR(INVALID_SIZE, 5), /* 261 Invalid Size */
ommpy 0:d383e2dee0f7 729 MBED_DEFINE_SYSTEM_ERROR(INVALID_OPERATION, 6), /* 262 Invalid Operation */
ommpy 0:d383e2dee0f7 730 MBED_DEFINE_SYSTEM_ERROR(ITEM_NOT_FOUND, 7), /* 263 Item Not Found */
ommpy 0:d383e2dee0f7 731 MBED_DEFINE_SYSTEM_ERROR(ACCESS_DENIED, 8), /* 264 Access Denied */
ommpy 0:d383e2dee0f7 732 MBED_DEFINE_SYSTEM_ERROR(UNSUPPORTED, 9), /* 265 Unsupported */
ommpy 0:d383e2dee0f7 733 MBED_DEFINE_SYSTEM_ERROR(BUFFER_FULL, 10), /* 266 Buffer Full */
ommpy 0:d383e2dee0f7 734 MBED_DEFINE_SYSTEM_ERROR(MEDIA_FULL, 11), /* 267 Media/Disk Full */
ommpy 0:d383e2dee0f7 735 MBED_DEFINE_SYSTEM_ERROR(ALREADY_IN_USE, 12), /* 268 Already in use */
ommpy 0:d383e2dee0f7 736 MBED_DEFINE_SYSTEM_ERROR(TIME_OUT, 13), /* 269 Timeout error */
ommpy 0:d383e2dee0f7 737 MBED_DEFINE_SYSTEM_ERROR(NOT_READY, 14), /* 270 Not Ready */
ommpy 0:d383e2dee0f7 738 MBED_DEFINE_SYSTEM_ERROR(FAILED_OPERATION, 15), /* 271 Requested Operation failed */
ommpy 0:d383e2dee0f7 739 MBED_DEFINE_SYSTEM_ERROR(OPERATION_PROHIBITED, 16), /* 272 Operation prohibited */
ommpy 0:d383e2dee0f7 740 MBED_DEFINE_SYSTEM_ERROR(OPERATION_ABORTED, 17), /* 273 Operation failed */
ommpy 0:d383e2dee0f7 741 MBED_DEFINE_SYSTEM_ERROR(WRITE_PROTECTED, 18), /* 274 Attempt to write to write-protected resource */
ommpy 0:d383e2dee0f7 742 MBED_DEFINE_SYSTEM_ERROR(NO_RESPONSE, 19), /* 275 No response */
ommpy 0:d383e2dee0f7 743 MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_LOCK_FAILED, 20), /* 276 Semaphore lock failed */
ommpy 0:d383e2dee0f7 744 MBED_DEFINE_SYSTEM_ERROR(MUTEX_LOCK_FAILED, 21), /* 277 Mutex lock failed */
ommpy 0:d383e2dee0f7 745 MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_UNLOCK_FAILED, 22), /* 278 Semaphore unlock failed */
ommpy 0:d383e2dee0f7 746 MBED_DEFINE_SYSTEM_ERROR(MUTEX_UNLOCK_FAILED, 23), /* 279 Mutex unlock failed */
ommpy 0:d383e2dee0f7 747 MBED_DEFINE_SYSTEM_ERROR(CRC_ERROR, 24), /* 280 CRC error or mismatch */
ommpy 0:d383e2dee0f7 748 MBED_DEFINE_SYSTEM_ERROR(OPEN_FAILED, 25), /* 281 Open failed */
ommpy 0:d383e2dee0f7 749 MBED_DEFINE_SYSTEM_ERROR(CLOSE_FAILED, 26), /* 282 Close failed */
ommpy 0:d383e2dee0f7 750 MBED_DEFINE_SYSTEM_ERROR(READ_FAILED, 27), /* 283 Read failed */
ommpy 0:d383e2dee0f7 751 MBED_DEFINE_SYSTEM_ERROR(WRITE_FAILED, 28), /* 284 Write failed */
ommpy 0:d383e2dee0f7 752 MBED_DEFINE_SYSTEM_ERROR(INITIALIZATION_FAILED, 29), /* 285 Initialization failed */
ommpy 0:d383e2dee0f7 753 MBED_DEFINE_SYSTEM_ERROR(BOOT_FAILURE, 30), /* 286 Boot failure */
ommpy 0:d383e2dee0f7 754 MBED_DEFINE_SYSTEM_ERROR(OUT_OF_MEMORY, 31), /* 287 Out of memory */
ommpy 0:d383e2dee0f7 755 MBED_DEFINE_SYSTEM_ERROR(OUT_OF_RESOURCES, 32), /* 288 Out of resources */
ommpy 0:d383e2dee0f7 756 MBED_DEFINE_SYSTEM_ERROR(ALLOC_FAILED, 33), /* 289 Alloc failed */
ommpy 0:d383e2dee0f7 757 MBED_DEFINE_SYSTEM_ERROR(FREE_FAILED, 34), /* 290 Free failed */
ommpy 0:d383e2dee0f7 758 MBED_DEFINE_SYSTEM_ERROR(OVERFLOW, 35), /* 291 Overflow error */
ommpy 0:d383e2dee0f7 759 MBED_DEFINE_SYSTEM_ERROR(UNDERFLOW, 36), /* 292 Underflow error */
ommpy 0:d383e2dee0f7 760 MBED_DEFINE_SYSTEM_ERROR(STACK_OVERFLOW, 37), /* 293 Stack overflow error */
ommpy 0:d383e2dee0f7 761 MBED_DEFINE_SYSTEM_ERROR(ISR_QUEUE_OVERFLOW, 38), /* 294 ISR queue overflow */
ommpy 0:d383e2dee0f7 762 MBED_DEFINE_SYSTEM_ERROR(TIMER_QUEUE_OVERFLOW, 39), /* 295 Timer Queue overflow */
ommpy 0:d383e2dee0f7 763 MBED_DEFINE_SYSTEM_ERROR(CLIB_SPACE_UNAVAILABLE, 40), /* 296 Standard library error - Space unavailable */
ommpy 0:d383e2dee0f7 764 MBED_DEFINE_SYSTEM_ERROR(CLIB_EXCEPTION, 41), /* 297 Standard library error - Exception */
ommpy 0:d383e2dee0f7 765 MBED_DEFINE_SYSTEM_ERROR(CLIB_MUTEX_INIT_FAILURE, 42), /* 298 Standard library error - Mutex Init failure */
ommpy 0:d383e2dee0f7 766 MBED_DEFINE_SYSTEM_ERROR(CREATE_FAILED, 43), /* 299 Create failed */
ommpy 0:d383e2dee0f7 767 MBED_DEFINE_SYSTEM_ERROR(DELETE_FAILED, 44), /* 300 Delete failed */
ommpy 0:d383e2dee0f7 768 MBED_DEFINE_SYSTEM_ERROR(THREAD_CREATE_FAILED, 45), /* 301 Thread Create failed */
ommpy 0:d383e2dee0f7 769 MBED_DEFINE_SYSTEM_ERROR(THREAD_DELETE_FAILED, 46), /* 302 Thread Delete failed */
ommpy 0:d383e2dee0f7 770 MBED_DEFINE_SYSTEM_ERROR(PROHIBITED_IN_ISR_CONTEXT, 47), /* 303 Operation Prohibited in ISR context */
ommpy 0:d383e2dee0f7 771 MBED_DEFINE_SYSTEM_ERROR(PINMAP_INVALID, 48), /* 304 Pinmap Invalid */
ommpy 0:d383e2dee0f7 772 MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT, 49), /* 305 Unknown Rtos Error */
ommpy 0:d383e2dee0f7 773 MBED_DEFINE_SYSTEM_ERROR(RTOS_THREAD_EVENT, 50), /* 306 Rtos Thread Error */
ommpy 0:d383e2dee0f7 774 MBED_DEFINE_SYSTEM_ERROR(RTOS_MUTEX_EVENT, 51), /* 307 Rtos Mutex Error */
ommpy 0:d383e2dee0f7 775 MBED_DEFINE_SYSTEM_ERROR(RTOS_SEMAPHORE_EVENT, 52), /* 308 Rtos Semaphore Error */
ommpy 0:d383e2dee0f7 776 MBED_DEFINE_SYSTEM_ERROR(RTOS_MEMORY_POOL_EVENT, 53), /* 309 Rtos Memory Pool Error */
ommpy 0:d383e2dee0f7 777 MBED_DEFINE_SYSTEM_ERROR(RTOS_TIMER_EVENT, 54), /* 310 Rtos Timer Error */
ommpy 0:d383e2dee0f7 778 MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT_FLAGS_EVENT, 55), /* 311 Rtos Event flags Error */
ommpy 0:d383e2dee0f7 779 MBED_DEFINE_SYSTEM_ERROR(RTOS_MESSAGE_QUEUE_EVENT, 56), /* 312 Rtos Message queue Error */
ommpy 0:d383e2dee0f7 780 MBED_DEFINE_SYSTEM_ERROR(DEVICE_BUSY, 57), /* 313 Device Busy */
ommpy 0:d383e2dee0f7 781 MBED_DEFINE_SYSTEM_ERROR(CONFIG_UNSUPPORTED, 58), /* 314 Configuration not supported */
ommpy 0:d383e2dee0f7 782 MBED_DEFINE_SYSTEM_ERROR(CONFIG_MISMATCH, 59), /* 315 Configuration mismatch */
ommpy 0:d383e2dee0f7 783 MBED_DEFINE_SYSTEM_ERROR(ALREADY_INITIALIZED, 60), /* 316 Already initialized */
ommpy 0:d383e2dee0f7 784 MBED_DEFINE_SYSTEM_ERROR(HARDFAULT_EXCEPTION, 61), /* 317 HardFault exception */
ommpy 0:d383e2dee0f7 785 MBED_DEFINE_SYSTEM_ERROR(MEMMANAGE_EXCEPTION, 62), /* 318 MemManage exception */
ommpy 0:d383e2dee0f7 786 MBED_DEFINE_SYSTEM_ERROR(BUSFAULT_EXCEPTION, 63), /* 319 BusFault exception */
ommpy 0:d383e2dee0f7 787 MBED_DEFINE_SYSTEM_ERROR(USAGEFAULT_EXCEPTION, 64), /* 320 UsageFault exception*/
ommpy 0:d383e2dee0f7 788 MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */
ommpy 0:d383e2dee0f7 789 MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
ommpy 0:d383e2dee0f7 790 MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */
ommpy 0:d383e2dee0f7 791 MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */
ommpy 0:d383e2dee0f7 792 MBED_DEFINE_SYSTEM_ERROR(AUTHENTICATION_FAILED, 69), /* 325 Authentication Failed */
ommpy 0:d383e2dee0f7 793 MBED_DEFINE_SYSTEM_ERROR(RBP_AUTHENTICATION_FAILED, 70), /* 326 Rollback Protection Authentication Failed */
ommpy 0:d383e2dee0f7 794 MBED_DEFINE_SYSTEM_ERROR(BLE_USE_INCOMPATIBLE_API, 71), /* 327 Concurrent use of incompatible versions of a BLE API */
ommpy 0:d383e2dee0f7 795 MBED_DEFINE_SYSTEM_ERROR(BLE_ILLEGAL_STATE, 72), /* 328 BLE stack entered illegal state */
ommpy 0:d383e2dee0f7 796
ommpy 0:d383e2dee0f7 797 //Everytime you add a new system error code, you must update
ommpy 0:d383e2dee0f7 798 //Error documentation under Handbook to capture the info on
ommpy 0:d383e2dee0f7 799 //the new error status/codes
ommpy 0:d383e2dee0f7 800
ommpy 0:d383e2dee0f7 801 //MBED CUSTOM ERROR CODE definitions starts at offset MBED_CUSTOM_ERROR_BASE, see above.
ommpy 0:d383e2dee0f7 802 /* Add More/Custom Error Codes here, See example below */
ommpy 0:d383e2dee0f7 803 //DEFINE_CUSTOM_ERROR( MY_CUSTOM_ERROR , 1 ),
ommpy 0:d383e2dee0f7 804
ommpy 0:d383e2dee0f7 805 } mbed_error_code_t;
ommpy 0:d383e2dee0f7 806
ommpy 0:d383e2dee0f7 807 /** mbed_error_ctx struct
ommpy 0:d383e2dee0f7 808 *
ommpy 0:d383e2dee0f7 809 * This struct captures the context information at the time of error.\n
ommpy 0:d383e2dee0f7 810 * It primarily contains information about the thread where the error originated,\n
ommpy 0:d383e2dee0f7 811 * filename/line number of the source file where the error occurred, a context specific error value(error_value)\n
ommpy 0:d383e2dee0f7 812 * and the address where the error originated.\n
ommpy 0:d383e2dee0f7 813 *
ommpy 0:d383e2dee0f7 814 * @note
ommpy 0:d383e2dee0f7 815 * Below are the members of mbed_error_ctx struct\n
ommpy 0:d383e2dee0f7 816 * error_status mbed_error_status_t value for this error\n
ommpy 0:d383e2dee0f7 817 * error_function_address Address where the error occurred\n
ommpy 0:d383e2dee0f7 818 * thread_id ID of the thread which generated the error\n
ommpy 0:d383e2dee0f7 819 * thread_entry_address Entry function of the thread which generated the error\n
ommpy 0:d383e2dee0f7 820 * thread_stack_size Stack Size of the thread which generated the error\n
ommpy 0:d383e2dee0f7 821 * thread_stack_mem Stack Top of the thread which generated the error\n
ommpy 0:d383e2dee0f7 822 * thread_current_sp Current Stack Pointer of the thread which generated the error\n
ommpy 0:d383e2dee0f7 823 * error_value A context/error specific value associated with this error\n
ommpy 0:d383e2dee0f7 824 * error_filename Filename where the error originated\n
ommpy 0:d383e2dee0f7 825 * error_line_number Line number in error_filename where the error originated\n
ommpy 0:d383e2dee0f7 826 */
ommpy 0:d383e2dee0f7 827 typedef struct _mbed_error_ctx {
ommpy 0:d383e2dee0f7 828 mbed_error_status_t error_status;
ommpy 0:d383e2dee0f7 829 uint32_t error_address;
ommpy 0:d383e2dee0f7 830 uint32_t error_value;
ommpy 0:d383e2dee0f7 831 uint32_t thread_id;
ommpy 0:d383e2dee0f7 832 uint32_t thread_entry_address;
ommpy 0:d383e2dee0f7 833 uint32_t thread_stack_size;
ommpy 0:d383e2dee0f7 834 uint32_t thread_stack_mem;
ommpy 0:d383e2dee0f7 835 uint32_t thread_current_sp;
ommpy 0:d383e2dee0f7 836 #ifdef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN
ommpy 0:d383e2dee0f7 837 char error_filename[MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN];
ommpy 0:d383e2dee0f7 838 uint32_t error_line_number;
ommpy 0:d383e2dee0f7 839 #endif
ommpy 0:d383e2dee0f7 840 #if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
ommpy 0:d383e2dee0f7 841 int32_t error_reboot_count;//everytime we write this struct we increment this value by 1, irrespective of time between reboots. Note that the data itself might change, but everytime we reboot due to error we update this count by 1
ommpy 0:d383e2dee0f7 842 int32_t is_error_processed;//once this error is processed set this value to 1
ommpy 0:d383e2dee0f7 843 uint32_t crc_error_ctx;//crc_error_ctx should always be the last member in this struct
ommpy 0:d383e2dee0f7 844 #endif
ommpy 0:d383e2dee0f7 845 } mbed_error_ctx;
ommpy 0:d383e2dee0f7 846
ommpy 0:d383e2dee0f7 847 /** To generate a fatal compile-time error, you can use the pre-processor #error directive.
ommpy 0:d383e2dee0f7 848 *
ommpy 0:d383e2dee0f7 849 * @param format C string that contains data stream to be printed.
ommpy 0:d383e2dee0f7 850 * Code snippets below show valid format.
ommpy 0:d383e2dee0f7 851 *
ommpy 0:d383e2dee0f7 852 * @code
ommpy 0:d383e2dee0f7 853 * #error "That shouldn't have happened!"
ommpy 0:d383e2dee0f7 854 * @endcode
ommpy 0:d383e2dee0f7 855 *
ommpy 0:d383e2dee0f7 856 * If the compiler evaluates this line, it will report the error and stop the compile.
ommpy 0:d383e2dee0f7 857 *
ommpy 0:d383e2dee0f7 858 * For example, you could use this to check some user-defined compile-time variables:
ommpy 0:d383e2dee0f7 859 *
ommpy 0:d383e2dee0f7 860 * @code
ommpy 0:d383e2dee0f7 861 * #define NUM_PORTS 7
ommpy 0:d383e2dee0f7 862 * #if (NUM_PORTS > 4)
ommpy 0:d383e2dee0f7 863 * #error "NUM_PORTS must be less than 4"
ommpy 0:d383e2dee0f7 864 * #endif
ommpy 0:d383e2dee0f7 865 * @endcode
ommpy 0:d383e2dee0f7 866 *
ommpy 0:d383e2dee0f7 867 * Reporting Run-Time Errors:
ommpy 0:d383e2dee0f7 868 * To generate a fatal run-time error, you can use the mbed error() function.
ommpy 0:d383e2dee0f7 869 *
ommpy 0:d383e2dee0f7 870 * @code
ommpy 0:d383e2dee0f7 871 * error("That shouldn't have happened!");
ommpy 0:d383e2dee0f7 872 * @endcode
ommpy 0:d383e2dee0f7 873 *
ommpy 0:d383e2dee0f7 874 * If the mbed running the program executes this function, it will print the
ommpy 0:d383e2dee0f7 875 * message via the USB serial port, and then die with the blue lights of death!
ommpy 0:d383e2dee0f7 876 *
ommpy 0:d383e2dee0f7 877 * The message can use printf-style formatting, so you can report variables in the
ommpy 0:d383e2dee0f7 878 * message too. For example, you could use this to check a run-time condition:
ommpy 0:d383e2dee0f7 879 *
ommpy 0:d383e2dee0f7 880 * @code
ommpy 0:d383e2dee0f7 881 * if(x >= 5) {
ommpy 0:d383e2dee0f7 882 * error("expected x to be less than 5, but got %d", x);
ommpy 0:d383e2dee0f7 883 * }
ommpy 0:d383e2dee0f7 884 * @endcode
ommpy 0:d383e2dee0f7 885 *
ommpy 0:d383e2dee0f7 886 *
ommpy 0:d383e2dee0f7 887 */
ommpy 0:d383e2dee0f7 888
ommpy 0:d383e2dee0f7 889 MBED_NORETURN void error(const char *format, ...) MBED_PRINTF(1, 2);
ommpy 0:d383e2dee0f7 890
ommpy 0:d383e2dee0f7 891 /**
ommpy 0:d383e2dee0f7 892 * Call this Macro to generate a mbed_error_status_t value for a System error
ommpy 0:d383e2dee0f7 893 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types.
ommpy 0:d383e2dee0f7 894 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes.
ommpy 0:d383e2dee0f7 895 *
ommpy 0:d383e2dee0f7 896 * @code
ommpy 0:d383e2dee0f7 897 *
ommpy 0:d383e2dee0f7 898 * mbed_error_status_t driver_error = MBED_MAKE_SYSTEM_ERROR( MODULE_DRIVER_USB, MBED_ERROR_CODE_INITIALIZATION_FAILED )
ommpy 0:d383e2dee0f7 899 *
ommpy 0:d383e2dee0f7 900 * @endcode
ommpy 0:d383e2dee0f7 901 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_SYSTEM
ommpy 0:d383e2dee0f7 902 *
ommpy 0:d383e2dee0f7 903 */
ommpy 0:d383e2dee0f7 904 #define MBED_MAKE_SYSTEM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, module, error_code)
ommpy 0:d383e2dee0f7 905
ommpy 0:d383e2dee0f7 906 /**
ommpy 0:d383e2dee0f7 907 * Call this Macro to generate a mbed_error_status_t value for a Custom error
ommpy 0:d383e2dee0f7 908 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types.
ommpy 0:d383e2dee0f7 909 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes.
ommpy 0:d383e2dee0f7 910 *
ommpy 0:d383e2dee0f7 911 * @code
ommpy 0:d383e2dee0f7 912 *
ommpy 0:d383e2dee0f7 913 * mbed_error_status_t custom_error = MBED_MAKE_CUSTOM_ERROR( MBED_MODULE_APPLICATION, 0xDEAD//16-bit custom error code )
ommpy 0:d383e2dee0f7 914 *
ommpy 0:d383e2dee0f7 915 * @endcode
ommpy 0:d383e2dee0f7 916 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_CUSTOM
ommpy 0:d383e2dee0f7 917 *
ommpy 0:d383e2dee0f7 918 */
ommpy 0:d383e2dee0f7 919 #define MBED_MAKE_CUSTOM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, module, error_code)
ommpy 0:d383e2dee0f7 920
ommpy 0:d383e2dee0f7 921 /**
ommpy 0:d383e2dee0f7 922 * Call this Macro to generate a mbed_error_status_t value for a System error
ommpy 0:d383e2dee0f7 923 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types.
ommpy 0:d383e2dee0f7 924 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes.
ommpy 0:d383e2dee0f7 925 *
ommpy 0:d383e2dee0f7 926 * @code
ommpy 0:d383e2dee0f7 927 *
ommpy 0:d383e2dee0f7 928 * mbed_error_status_t new_error = MBED_MAKE_ERROR( MODULE_DRIVER_USB, MBED_ERROR_INITIALIZATION_FAILED )
ommpy 0:d383e2dee0f7 929 *
ommpy 0:d383e2dee0f7 930 * @endcode
ommpy 0:d383e2dee0f7 931 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_SYSTEM
ommpy 0:d383e2dee0f7 932 *
ommpy 0:d383e2dee0f7 933 */
ommpy 0:d383e2dee0f7 934 #define MBED_MAKE_ERROR(module, error_code) MBED_MAKE_SYSTEM_ERROR(module, error_code)
ommpy 0:d383e2dee0f7 935
ommpy 0:d383e2dee0f7 936 /**
ommpy 0:d383e2dee0f7 937 * Callback/Error hook function prototype. Applications needing a callback when an error is reported can use mbed_set_error_hook function
ommpy 0:d383e2dee0f7 938 * to register a callback/error hook function using the following prototype. When an error happens in the system error handling
ommpy 0:d383e2dee0f7 939 * implementation will invoke this callback with the mbed_error_status_t reported and the error context at the time of error.
ommpy 0:d383e2dee0f7 940 * @param error_ctx Error context structure associated with this error.
ommpy 0:d383e2dee0f7 941 * @return void
ommpy 0:d383e2dee0f7 942 *
ommpy 0:d383e2dee0f7 943 */
ommpy 0:d383e2dee0f7 944 typedef void (*mbed_error_hook_t)(const mbed_error_ctx *error_ctx);
ommpy 0:d383e2dee0f7 945
ommpy 0:d383e2dee0f7 946
ommpy 0:d383e2dee0f7 947 /**
ommpy 0:d383e2dee0f7 948 * Callback function for reporting error context during boot up. When MbedOS error handling system detects a fatal error
ommpy 0:d383e2dee0f7 949 * it will auto-reboot the system(if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled) after capturing the
ommpy 0:d383e2dee0f7 950 * error info in special crash data RAM region. Once rebooted, MbedOS initialization routines will call this function with a pointer to
ommpy 0:d383e2dee0f7 951 * the captured mbed_error_ctx structure. If application implementation needs to receive this callback, mbed_error_reboot_callback
ommpy 0:d383e2dee0f7 952 * function should be overridden with custom implementation. By default it's defined as a WEAK function in mbed_error.c.
ommpy 0:d383e2dee0f7 953 * Note that this callback will be invoked before the system starts executing main() function. So the implementation of
ommpy 0:d383e2dee0f7 954 * the callback should be aware any resource limitations/availability of resources which are yet to be initialized by application main().
ommpy 0:d383e2dee0f7 955 *
ommpy 0:d383e2dee0f7 956 * @param error_ctx Error context structure associated with this error.
ommpy 0:d383e2dee0f7 957 * @return void
ommpy 0:d383e2dee0f7 958 *
ommpy 0:d383e2dee0f7 959 */
ommpy 0:d383e2dee0f7 960 void mbed_error_reboot_callback(mbed_error_ctx *error_context);
ommpy 0:d383e2dee0f7 961
ommpy 0:d383e2dee0f7 962 /**
ommpy 0:d383e2dee0f7 963 * Initialize error handling system, this is called by the mbed-os boot sequence. This is not required to be called by Application unless the boot sequence is overridden by the system implementation.
ommpy 0:d383e2dee0f7 964 * NOTE: If MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled and if the current reboot count exceeds MBED_CONF_PLATFORM_ERROR_REBOOT_MAX the system will halt when this function is called,
ommpy 0:d383e2dee0f7 965 * and in such cases the caller will not get the control back. Also note that calling this function may trigger mbed_error_reboot_callback() if application side overides mbed_error_reboot_callback().
ommpy 0:d383e2dee0f7 966 * @return MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 967 *
ommpy 0:d383e2dee0f7 968 */
ommpy 0:d383e2dee0f7 969
ommpy 0:d383e2dee0f7 970 mbed_error_status_t mbed_error_initialize(void);
ommpy 0:d383e2dee0f7 971
ommpy 0:d383e2dee0f7 972 /**
ommpy 0:d383e2dee0f7 973 * Call this function to retrieve the error context after a fatal error which triggered a system reboot. The function retrieves the error context stored in crash-report ram area which is preserved over reboot.
ommpy 0:d383e2dee0f7 974 * @param error_info Pointer to mbed_error_ctx struct allocated by the caller. This is the mbed_error_ctx info captured as part of the fatal error which triggered the reboot.
ommpy 0:d383e2dee0f7 975 * @return 0 or MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 976 * MBED_ERROR_INVALID_ARGUMENT in case of invalid error_info pointer
ommpy 0:d383e2dee0f7 977 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
ommpy 0:d383e2dee0f7 978 *
ommpy 0:d383e2dee0f7 979 */
ommpy 0:d383e2dee0f7 980 mbed_error_status_t mbed_get_reboot_error_info(mbed_error_ctx *error_info);
ommpy 0:d383e2dee0f7 981
ommpy 0:d383e2dee0f7 982 /**
ommpy 0:d383e2dee0f7 983 * Calling this function resets the current reboot context captured by the system(stored in special crash data RAM region).
ommpy 0:d383e2dee0f7 984 * @return MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 985 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
ommpy 0:d383e2dee0f7 986 */
ommpy 0:d383e2dee0f7 987 mbed_error_status_t mbed_reset_reboot_error_info(void);
ommpy 0:d383e2dee0f7 988
ommpy 0:d383e2dee0f7 989 /**
ommpy 0:d383e2dee0f7 990 * Calling this function resets the current reboot count stored as part of error context captured in special crash data RAM region.
ommpy 0:d383e2dee0f7 991 * The function will also update the CRC value stored as part of error context accordingly.
ommpy 0:d383e2dee0f7 992 * @return MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 993 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
ommpy 0:d383e2dee0f7 994 */
ommpy 0:d383e2dee0f7 995 mbed_error_status_t mbed_reset_reboot_count(void);
ommpy 0:d383e2dee0f7 996
ommpy 0:d383e2dee0f7 997 /**
ommpy 0:d383e2dee0f7 998 * Call this function to set a system error/warning. This function will log the error status with the context info and return to caller.
ommpy 0:d383e2dee0f7 999 *
ommpy 0:d383e2dee0f7 1000 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
ommpy 0:d383e2dee0f7 1001 * @param error_msg The error message to be printed out to STDIO/Serial.
ommpy 0:d383e2dee0f7 1002 * @param error_value Value associated with the error status. This would depend on error code/error scenario.
ommpy 0:d383e2dee0f7 1003 * @param filename Name of the source file originating the error( Most callers can pass __FILE__ here ).
ommpy 0:d383e2dee0f7 1004 * @param line_number The line number of the source file originating the error( Most callers can pass __LINE__ here ) .
ommpy 0:d383e2dee0f7 1005 * @return 0 or MBED_SUCCESS.
ommpy 0:d383e2dee0f7 1006 * MBED_ERROR_INVALID_ARGUMENT if called with invalid error status/codes
ommpy 0:d383e2dee0f7 1007 *
ommpy 0:d383e2dee0f7 1008 * @code
ommpy 0:d383e2dee0f7 1009 *
ommpy 0:d383e2dee0f7 1010 * mbed_error( ERROR_OUT_OF_MEMORY, "Out of memory error", 0, __FILE__, __LINE__ )
ommpy 0:d383e2dee0f7 1011 *
ommpy 0:d383e2dee0f7 1012 * @endcode
ommpy 0:d383e2dee0f7 1013 *
ommpy 0:d383e2dee0f7 1014 * @note See MBED_WARNING/MBED_ERROR macros which provides a wrapper on this API
ommpy 0:d383e2dee0f7 1015 */
ommpy 0:d383e2dee0f7 1016 mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number);
ommpy 0:d383e2dee0f7 1017
ommpy 0:d383e2dee0f7 1018 /**
ommpy 0:d383e2dee0f7 1019 * Returns the first system error reported.
ommpy 0:d383e2dee0f7 1020 * @return mbed_error_status_t code logged for the first error or MBED_SUCCESS if no errors are logged.
ommpy 0:d383e2dee0f7 1021 *
ommpy 0:d383e2dee0f7 1022 */
ommpy 0:d383e2dee0f7 1023 mbed_error_status_t mbed_get_first_error(void);
ommpy 0:d383e2dee0f7 1024
ommpy 0:d383e2dee0f7 1025 /**
ommpy 0:d383e2dee0f7 1026 * Returns the most recent system error reported.
ommpy 0:d383e2dee0f7 1027 * @return mbed_error_status_t code logged for the last error or MBED_SUCCESS if no errors are logged.
ommpy 0:d383e2dee0f7 1028 *
ommpy 0:d383e2dee0f7 1029 */
ommpy 0:d383e2dee0f7 1030 mbed_error_status_t mbed_get_last_error(void);
ommpy 0:d383e2dee0f7 1031
ommpy 0:d383e2dee0f7 1032 /**
ommpy 0:d383e2dee0f7 1033 * Returns the number of system errors reported after boot.
ommpy 0:d383e2dee0f7 1034 * @return int Number of errors reported.
ommpy 0:d383e2dee0f7 1035 *
ommpy 0:d383e2dee0f7 1036 */
ommpy 0:d383e2dee0f7 1037 int mbed_get_error_count(void);
ommpy 0:d383e2dee0f7 1038
ommpy 0:d383e2dee0f7 1039 /**
ommpy 0:d383e2dee0f7 1040 * Call this function to set a fatal system error and halt the system. This function will log the fatal error with the context info and prints the error report and halts the system.
ommpy 0:d383e2dee0f7 1041 *
ommpy 0:d383e2dee0f7 1042 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
ommpy 0:d383e2dee0f7 1043 * @param error_msg The error message to be printed out to STDIO/Serial.
ommpy 0:d383e2dee0f7 1044 * @param error_value Value associated with the error status. This would depend on error code/error scenario.
ommpy 0:d383e2dee0f7 1045 * @param filename Name of the source file originating the error( Most callers can pass __FILE__ here ).
ommpy 0:d383e2dee0f7 1046 * @param line_number The line number of the source file originating the error( Most callers can pass __LINE__ here ) .
ommpy 0:d383e2dee0f7 1047 * @return Does not return.
ommpy 0:d383e2dee0f7 1048 *
ommpy 0:d383e2dee0f7 1049 * @code
ommpy 0:d383e2dee0f7 1050 *
ommpy 0:d383e2dee0f7 1051 * mbed_error( MBED_ERROR_PROHIBITED_OPERATION, "Prohibited operation tried", 0, __FILE__, __LINE__ )
ommpy 0:d383e2dee0f7 1052 *
ommpy 0:d383e2dee0f7 1053 * @endcode
ommpy 0:d383e2dee0f7 1054 *
ommpy 0:d383e2dee0f7 1055 * @note See MBED_WARNING/MBED_ERROR macros which provides a wrapper on this API
ommpy 0:d383e2dee0f7 1056 */
ommpy 0:d383e2dee0f7 1057 MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number);
ommpy 0:d383e2dee0f7 1058
ommpy 0:d383e2dee0f7 1059 /**
ommpy 0:d383e2dee0f7 1060 * Registers an application defined error callback with the error handling system.
ommpy 0:d383e2dee0f7 1061 * This function will be called with error context info whenever system handles a mbed_error/mbed_warning call
ommpy 0:d383e2dee0f7 1062 * NOTE: This function should be implemented for re-entrancy as multiple threads may invoke mbed_error which may cause error hook to be called.
ommpy 0:d383e2dee0f7 1063 * @param custom_error_hook mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
ommpy 0:d383e2dee0f7 1064 * @return 0 or MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 1065 * MBED_ERROR_INVALID_ARGUMENT in case of NULL for custom_error_hook
ommpy 0:d383e2dee0f7 1066 *
ommpy 0:d383e2dee0f7 1067 * @code
ommpy 0:d383e2dee0f7 1068 *
ommpy 0:d383e2dee0f7 1069 * mbed_error_status_t my_custom_error_hook(mbed_error_status_t error_status, const mbed_error_ctx *error_ctx) {
ommpy 0:d383e2dee0f7 1070 * //Do something with the error_status or error_ctx
ommpy 0:d383e2dee0f7 1071 * }
ommpy 0:d383e2dee0f7 1072 *
ommpy 0:d383e2dee0f7 1073 * mbed_set_error_hook( my_custom_error_hook )
ommpy 0:d383e2dee0f7 1074 *
ommpy 0:d383e2dee0f7 1075 * @endcode
ommpy 0:d383e2dee0f7 1076 * @note The erro hook function implementation should be re-entrant.
ommpy 0:d383e2dee0f7 1077 *
ommpy 0:d383e2dee0f7 1078 */
ommpy 0:d383e2dee0f7 1079 mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t custom_error_hook);
ommpy 0:d383e2dee0f7 1080
ommpy 0:d383e2dee0f7 1081 /**
ommpy 0:d383e2dee0f7 1082 * Reads the first error context information captured.
ommpy 0:d383e2dee0f7 1083 * @param error_info This is the mbed_error_context info captured as part of the first mbed_error call. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
ommpy 0:d383e2dee0f7 1084 * @return 0 or MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 1085 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index
ommpy 0:d383e2dee0f7 1086 *
ommpy 0:d383e2dee0f7 1087 */
ommpy 0:d383e2dee0f7 1088 mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info);
ommpy 0:d383e2dee0f7 1089
ommpy 0:d383e2dee0f7 1090 /**
ommpy 0:d383e2dee0f7 1091 * Reads the last error context information captured.
ommpy 0:d383e2dee0f7 1092 * @param error_info This is the mbed_error_context info captured as part of the last mbed_error call. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
ommpy 0:d383e2dee0f7 1093 * @return 0 or MBED_ERROR_SUCCESS on success.
ommpy 0:d383e2dee0f7 1094 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index
ommpy 0:d383e2dee0f7 1095 *
ommpy 0:d383e2dee0f7 1096 */
ommpy 0:d383e2dee0f7 1097 mbed_error_status_t mbed_get_last_error_info(mbed_error_ctx *error_info);
ommpy 0:d383e2dee0f7 1098
ommpy 0:d383e2dee0f7 1099 /**
ommpy 0:d383e2dee0f7 1100 * Clears the last error, first error, error count and all entries in the error history.
ommpy 0:d383e2dee0f7 1101 * @return 0 or MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 1102 *
ommpy 0:d383e2dee0f7 1103 */
ommpy 0:d383e2dee0f7 1104 mbed_error_status_t mbed_clear_all_errors(void);
ommpy 0:d383e2dee0f7 1105
ommpy 0:d383e2dee0f7 1106 /**
ommpy 0:d383e2dee0f7 1107 * Generates a mbed_error_status_t value based on passed in values for type, module and error code.
ommpy 0:d383e2dee0f7 1108 * @param error_type Error type based on mbed_error_type_t enum.
ommpy 0:d383e2dee0f7 1109 * @param module Module type based on mbed_module_type_t enum.
ommpy 0:d383e2dee0f7 1110 * @param error_code Error codes defined by mbed_error_code_t enum
ommpy 0:d383e2dee0f7 1111 * @return 0 or MBED_ERROR_SUCCESS on success.
ommpy 0:d383e2dee0f7 1112 *
ommpy 0:d383e2dee0f7 1113 */
ommpy 0:d383e2dee0f7 1114 mbed_error_status_t mbed_make_error(mbed_error_type_t error_type, mbed_module_type_t module, mbed_error_code_t error_code);
ommpy 0:d383e2dee0f7 1115
ommpy 0:d383e2dee0f7 1116 /**
ommpy 0:d383e2dee0f7 1117 * Returns the current number of entries in the error history, if there has been more than max number of errors logged the number returned will be max depth of error history.
ommpy 0:d383e2dee0f7 1118 * @return Current number of entries in the error history.
ommpy 0:d383e2dee0f7 1119 *
ommpy 0:d383e2dee0f7 1120 */
ommpy 0:d383e2dee0f7 1121 int mbed_get_error_hist_count(void);
ommpy 0:d383e2dee0f7 1122
ommpy 0:d383e2dee0f7 1123 /**
ommpy 0:d383e2dee0f7 1124 * Reads the error context information for a specific error from error history, specified by the index.
ommpy 0:d383e2dee0f7 1125 *
ommpy 0:d383e2dee0f7 1126 * @param index index of the error context entry in the history to be retrieved.\n
ommpy 0:d383e2dee0f7 1127 * The number of entries in the error history is configured during build and the max index depends on max depth of error history.\n
ommpy 0:d383e2dee0f7 1128 * index = 0 points to the oldest entry in the history, and index = (max history depth - 1) points to the latest entry in the error history.\n
ommpy 0:d383e2dee0f7 1129 * @param error_info This is the mbed_error_context info captured as part of the error history. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
ommpy 0:d383e2dee0f7 1130 * @return 0 or MBED_SUCCESS on success.
ommpy 0:d383e2dee0f7 1131 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index
ommpy 0:d383e2dee0f7 1132 *
ommpy 0:d383e2dee0f7 1133 */
ommpy 0:d383e2dee0f7 1134 mbed_error_status_t mbed_get_error_hist_info(int index, mbed_error_ctx *error_info);
ommpy 0:d383e2dee0f7 1135
ommpy 0:d383e2dee0f7 1136 /**
ommpy 0:d383e2dee0f7 1137 * Saves the error history information to a file
ommpy 0:d383e2dee0f7 1138 *
ommpy 0:d383e2dee0f7 1139 * @param path path to the file in the filesystem
ommpy 0:d383e2dee0f7 1140 * @return 0 or MBED_ERROR_SUCCESS on success.
ommpy 0:d383e2dee0f7 1141 * MBED_ERROR_WRITE_FAILED if writing to file failed
ommpy 0:d383e2dee0f7 1142 * MBED_ERROR_INVALID_ARGUMENT if path is not valid
ommpy 0:d383e2dee0f7 1143 *
ommpy 0:d383e2dee0f7 1144 * @note Filesystem support is required in order for this function to work.
ommpy 0:d383e2dee0f7 1145 *
ommpy 0:d383e2dee0f7 1146 */
ommpy 0:d383e2dee0f7 1147 mbed_error_status_t mbed_save_error_hist(const char *path);
ommpy 0:d383e2dee0f7 1148
ommpy 0:d383e2dee0f7 1149 #ifdef __cplusplus
ommpy 0:d383e2dee0f7 1150 }
ommpy 0:d383e2dee0f7 1151 #endif
ommpy 0:d383e2dee0f7 1152
ommpy 0:d383e2dee0f7 1153 #endif
ommpy 0:d383e2dee0f7 1154
ommpy 0:d383e2dee0f7 1155 /** @}*/
ommpy 0:d383e2dee0f7 1156 /** @}*/
ommpy 0:d383e2dee0f7 1157
ommpy 0:d383e2dee0f7 1158