|
16 | 16 |
|
17 | 17 | #include "cmsis_compiler.h"
|
18 | 18 | #include "rtx_os.h"
|
| 19 | +#include "rtx_evr.h" |
19 | 20 | #include "mbed_rtx.h"
|
20 | 21 | #include "mbed_error.h"
|
21 | 22 |
|
@@ -66,3 +67,72 @@ __NO_RETURN uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
|
66 | 67 | /* That shouldn't be reached */
|
67 | 68 | for (;;) {}
|
68 | 69 | }
|
| 70 | + |
| 71 | +#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED |
| 72 | + |
| 73 | +static const char* error_msg(int32_t status) |
| 74 | +{ |
| 75 | + switch (status) { |
| 76 | + case osError: |
| 77 | + return "Unspecified RTOS error"; |
| 78 | + case osErrorTimeout: |
| 79 | + return "Operation not completed within the timeout period"; |
| 80 | + case osErrorResource: |
| 81 | + return "Resource not available"; |
| 82 | + case osErrorParameter: |
| 83 | + return "Parameter error"; |
| 84 | + case osErrorNoMemory: |
| 85 | + return "System is out of memory"; |
| 86 | + case osErrorISR: |
| 87 | + return "Not allowed in ISR context"; |
| 88 | + default: |
| 89 | + return "Unknown"; |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +void EvrRtxKernelError (int32_t status) |
| 94 | +{ |
| 95 | + error("Kernel error %i: %s\r\n", status, error_msg(status)); |
| 96 | +} |
| 97 | + |
| 98 | +void EvrRtxThreadError (osThreadId_t thread_id, int32_t status) |
| 99 | +{ |
| 100 | + error("Thread %p error %i: %s\r\n", thread_id, status, error_msg(status)); |
| 101 | +} |
| 102 | + |
| 103 | +void EvrRtxTimerError (osTimerId_t timer_id, int32_t status) |
| 104 | +{ |
| 105 | + error("Timer %p error %i: %s\r\n", timer_id, status, error_msg(status)); |
| 106 | +} |
| 107 | + |
| 108 | +void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status) |
| 109 | +{ |
| 110 | + error("Event %p error %i: %s\r\n", ef_id, status, error_msg(status)); |
| 111 | +} |
| 112 | + |
| 113 | +void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status) |
| 114 | +{ |
| 115 | + error("Mutex %p error %i: %s\r\n", mutex_id, status, error_msg(status)); |
| 116 | +} |
| 117 | + |
| 118 | +void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status) |
| 119 | +{ |
| 120 | + // Ignore semaphore overflow, the count will saturate with a returned error |
| 121 | + if (status == osRtxErrorSemaphoreCountLimit) { |
| 122 | + return; |
| 123 | + } |
| 124 | + |
| 125 | + error("Semaphore %p error %i\r\n", semaphore_id, status); |
| 126 | +} |
| 127 | + |
| 128 | +void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status) |
| 129 | +{ |
| 130 | + error("Memory Pool %p error %i\r\n", mp_id, status); |
| 131 | +} |
| 132 | + |
| 133 | +void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status) |
| 134 | +{ |
| 135 | + error("Message Queue %p error %i\r\n", mq_id, status); |
| 136 | +} |
| 137 | + |
| 138 | +#endif |
0 commit comments