27 #include "platform/mbed_retarget.h" 28 #include "platform/mbed_toolchain.h" 42 #ifndef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 43 #define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 44 #else //MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 45 #if MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN > 64 49 #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." 53 #define MBED_ERROR_STATUS_CODE_MASK (0x0000FFFF) 54 #define MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK (0x0000FFFF) 55 #define MBED_ERROR_STATUS_CODE_POS (0) 56 #define MBED_ERROR_STATUS_CODE_FIELD_SIZE (16) 58 #define MBED_ERROR_STATUS_MODULE_MASK (0x00FF0000) 59 #define MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK (0x000000FF) 60 #define MBED_ERROR_STATUS_MODULE_POS (16) 61 #define MBED_ERROR_STATUS_MODULE_FIELD_SIZE (8) 63 #define MBED_ERROR_STATUS_TYPE_MASK (0x60000000) 64 #define MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK (0x00000003) 65 #define MBED_ERROR_STATUS_TYPE_POS (29) 66 #define MBED_ERROR_STATUS_TYPE_FIELD_SIZE (2) 72 #define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \ 74 ((mbed_error_status_t) (error_code & MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_CODE_POS) | \ 75 ((mbed_error_status_t) (module & MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_MODULE_POS) | \ 76 ((mbed_error_status_t) (type & MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_TYPE_POS)) 78 #define MBED_GET_ERROR_TYPE( error_status ) ((error_status & MBED_ERROR_STATUS_TYPE_MASK) >> MBED_ERROR_STATUS_TYPE_POS) 79 #define MBED_GET_ERROR_MODULE( error_status ) ((error_status & MBED_ERROR_STATUS_MODULE_MASK) >> MBED_ERROR_STATUS_MODULE_POS) 80 #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)) 116 #define MBED_DEFINE_POSIX_ERROR( error_name, error_code ) \ 117 MBED_ERROR_CODE_##error_name = error_code, \ 118 MBED_ERROR_##error_name = -(MBED_POSIX_ERROR_BASE + error_code) 126 #define MBED_DEFINE_SYSTEM_ERROR( error_name, error_code ) \ 127 MBED_ERROR_CODE_##error_name = MBED_SYSTEM_ERROR_BASE + error_code, \ 128 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 136 #define MBED_DEFINE_CUSTOM_ERROR( error_name, error_code ) \ 137 MBED_ERROR_CODE_##error_name = MBED_CUSTOM_ERROR_BASE + error_code, \ 138 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 159 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 160 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 ) 162 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 163 #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__ ) 164 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 165 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 166 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 167 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) 190 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 191 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 ) 193 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 194 #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__ ) 195 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 196 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 197 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 198 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) 213 MBED_ERROR_TYPE_SYSTEM = 0,
214 MBED_ERROR_TYPE_CUSTOM = 1,
218 MBED_ERROR_TYPE_POSIX = 3
269 MBED_MODULE_APPLICATION = 0,
270 MBED_MODULE_PLATFORM,
272 MBED_MODULE_NETWORK_STACK,
274 MBED_MODULE_MEMORY_SUBSYSTEM,
275 MBED_MODULE_FILESYSTEM,
276 MBED_MODULE_BLOCK_DEVICE,
278 MBED_MODULE_DRIVER_SERIAL,
279 MBED_MODULE_DRIVER_RTC,
280 MBED_MODULE_DRIVER_I2C,
281 MBED_MODULE_DRIVER_SPI,
282 MBED_MODULE_DRIVER_GPIO,
283 MBED_MODULE_DRIVER_ANALOG,
284 MBED_MODULE_DRIVER_DIGITAL,
285 MBED_MODULE_DRIVER_CAN,
286 MBED_MODULE_DRIVER_ETHERNET,
287 MBED_MODULE_DRIVER_CRC,
288 MBED_MODULE_DRIVER_PWM,
289 MBED_MODULE_DRIVER_QSPI,
290 MBED_MODULE_DRIVER_USB,
291 MBED_MODULE_DRIVER_WATCHDOG,
292 MBED_MODULE_TARGET_SDK,
294 MBED_MODULE_NETWORK_STATS,
297 MBED_MODULE_UNKNOWN = 255,
298 MBED_MODULE_MAX = MBED_MODULE_UNKNOWN
302 #define MBED_SUCCESS 0 304 #define MBED_POSIX_ERROR_BASE 0 305 #define MBED_SYSTEM_ERROR_BASE 256 306 #define MBED_CUSTOM_ERROR_BASE 4096 833 mbed_error_status_t error_status;
834 uint32_t error_address;
835 uint32_t error_value;
837 uint32_t thread_entry_address;
838 uint32_t thread_stack_size;
839 uint32_t thread_stack_mem;
840 uint32_t thread_current_sp;
841 #ifdef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 843 uint32_t error_line_number;
845 #if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED 846 int32_t error_reboot_count;
847 int32_t is_error_processed;
848 uint32_t crc_error_ctx;
909 #define MBED_MAKE_SYSTEM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, module, error_code) 924 #define MBED_MAKE_CUSTOM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, module, error_code) 939 #define MBED_MAKE_ERROR(module, error_code) MBED_MAKE_SYSTEM_ERROR(module, error_code) 1021 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);
1069 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);