21 #include "platform/mbed_retarget.h" 22 #include "platform/mbed_toolchain.h" 44 #ifndef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 45 #define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 46 #else //MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 47 #if MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN > 64 51 #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." 55 #define MBED_ERROR_STATUS_CODE_MASK (0x0000FFFF) 56 #define MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK (0x0000FFFF) 57 #define MBED_ERROR_STATUS_CODE_POS (0) 58 #define MBED_ERROR_STATUS_CODE_FIELD_SIZE (16) 60 #define MBED_ERROR_STATUS_MODULE_MASK (0x00FF0000) 61 #define MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK (0x000000FF) 62 #define MBED_ERROR_STATUS_MODULE_POS (16) 63 #define MBED_ERROR_STATUS_MODULE_FIELD_SIZE (8) 65 #define MBED_ERROR_STATUS_TYPE_MASK (0x60000000) 66 #define MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK (0x00000003) 67 #define MBED_ERROR_STATUS_TYPE_POS (29) 68 #define MBED_ERROR_STATUS_TYPE_FIELD_SIZE (2) 74 #define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \ 76 ((mbed_error_status_t) (error_code & MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_CODE_POS) | \ 77 ((mbed_error_status_t) (module & MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_MODULE_POS) | \ 78 ((mbed_error_status_t) (type & MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_TYPE_POS)) 80 #define MBED_GET_ERROR_TYPE( error_status ) ((error_status & MBED_ERROR_STATUS_TYPE_MASK) >> MBED_ERROR_STATUS_TYPE_POS) 81 #define MBED_GET_ERROR_MODULE( error_status ) ((error_status & MBED_ERROR_STATUS_MODULE_MASK) >> MBED_ERROR_STATUS_MODULE_POS) 82 #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)) 118 #define MBED_DEFINE_POSIX_ERROR( error_name, error_code ) \ 119 MBED_ERROR_CODE_##error_name = error_code, \ 120 MBED_ERROR_##error_name = -(MBED_POSIX_ERROR_BASE + error_code) 128 #define MBED_DEFINE_SYSTEM_ERROR( error_name, error_code ) \ 129 MBED_ERROR_CODE_##error_name = MBED_SYSTEM_ERROR_BASE + error_code, \ 130 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 138 #define MBED_DEFINE_CUSTOM_ERROR( error_name, error_code ) \ 139 MBED_ERROR_CODE_##error_name = MBED_CUSTOM_ERROR_BASE + error_code, \ 140 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 161 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 162 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 ) 164 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 165 #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__ ) 166 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 167 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 168 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 169 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) 192 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 193 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 ) 195 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 196 #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__ ) 197 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 198 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 199 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 200 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) 215 MBED_ERROR_TYPE_SYSTEM = 0,
216 MBED_ERROR_TYPE_CUSTOM = 1,
220 MBED_ERROR_TYPE_POSIX = 3
271 MBED_MODULE_APPLICATION = 0,
272 MBED_MODULE_PLATFORM,
274 MBED_MODULE_NETWORK_STACK,
276 MBED_MODULE_MEMORY_SUBSYSTEM,
277 MBED_MODULE_FILESYSTEM,
278 MBED_MODULE_BLOCK_DEVICE,
280 MBED_MODULE_DRIVER_SERIAL,
281 MBED_MODULE_DRIVER_RTC,
282 MBED_MODULE_DRIVER_I2C,
283 MBED_MODULE_DRIVER_SPI,
284 MBED_MODULE_DRIVER_GPIO,
285 MBED_MODULE_DRIVER_ANALOG,
286 MBED_MODULE_DRIVER_DIGITAL,
287 MBED_MODULE_DRIVER_CAN,
288 MBED_MODULE_DRIVER_ETHERNET,
289 MBED_MODULE_DRIVER_CRC,
290 MBED_MODULE_DRIVER_PWM,
291 MBED_MODULE_DRIVER_QSPI,
292 MBED_MODULE_DRIVER_USB,
293 MBED_MODULE_DRIVER_WATCHDOG,
294 MBED_MODULE_TARGET_SDK,
296 MBED_MODULE_NETWORK_STATS,
299 MBED_MODULE_UNKNOWN = 255,
300 MBED_MODULE_MAX = MBED_MODULE_UNKNOWN
304 #define MBED_SUCCESS 0 306 #define MBED_POSIX_ERROR_BASE 0 307 #define MBED_SYSTEM_ERROR_BASE 256 308 #define MBED_CUSTOM_ERROR_BASE 4096 835 mbed_error_status_t error_status;
836 uint32_t error_address;
837 uint32_t error_value;
839 uint32_t thread_entry_address;
840 uint32_t thread_stack_size;
841 uint32_t thread_stack_mem;
842 uint32_t thread_current_sp;
843 #ifdef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 845 uint32_t error_line_number;
847 #if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED 848 int32_t error_reboot_count;
849 int32_t is_error_processed;
850 uint32_t crc_error_ctx;
911 #define MBED_MAKE_SYSTEM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, module, error_code) 926 #define MBED_MAKE_CUSTOM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, module, error_code) 941 #define MBED_MAKE_ERROR(module, error_code) MBED_MAKE_SYSTEM_ERROR(module, error_code) 1023 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);
1071 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);