@@ -107,29 +107,40 @@ static const char *error_msg(int32_t status)
107107 }
108108}
109109
110+ static void trap_rtx_error (unsigned int error_value , int32_t rtx_status , mbed_error_status_t error_status )
111+ {
112+ // Attempts to get the console for the first time while printing an error
113+ // may well cause a mutex error; in general let RTX calls fail during
114+ // an error condition.
115+ if (mbed_get_error_in_progress ()) {
116+ return ;
117+ }
118+ MBED_ERROR1 (error_status , error_msg (rtx_status ), error_value );
119+ }
120+
110121void EvrRtxKernelError (int32_t status )
111122{
112- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_EVENT ), error_msg ( status ), status );
123+ trap_rtx_error ( status , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_EVENT ) );
113124}
114125
115126void EvrRtxThreadError (osThreadId_t thread_id , int32_t status )
116127{
117- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_THREAD_EVENT ), error_msg ( status ), thread_id );
128+ trap_rtx_error (( unsigned int ) thread_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_THREAD_EVENT ) );
118129}
119130
120131void EvrRtxTimerError (osTimerId_t timer_id , int32_t status )
121132{
122- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_TIMER_EVENT ), error_msg ( status ), timer_id );
133+ trap_rtx_error (( unsigned int ) timer_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_TIMER_EVENT ) );
123134}
124135
125136void EvrRtxEventFlagsError (osEventFlagsId_t ef_id , int32_t status )
126137{
127- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT ), error_msg ( status ), ef_id );
138+ trap_rtx_error (( unsigned int ) ef_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT ) );
128139}
129140
130141void EvrRtxMutexError (osMutexId_t mutex_id , int32_t status )
131142{
132- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MUTEX_EVENT ), error_msg ( status ), mutex_id );
143+ trap_rtx_error (( unsigned int ) mutex_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MUTEX_EVENT ) );
133144}
134145
135146void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id , int32_t status )
@@ -139,17 +150,17 @@ void EvrRtxSemaphoreError(osSemaphoreId_t semaphore_id, int32_t status)
139150 return ;
140151 }
141152
142- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT ), error_msg ( status ), semaphore_id );
153+ trap_rtx_error (( unsigned int ) semaphore_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT ) );
143154}
144155
145156void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id , int32_t status )
146157{
147- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT ), error_msg ( status ), mp_id );
158+ trap_rtx_error (( unsigned int ) mp_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT ) );
148159}
149160
150161void EvrRtxMessageQueueError (osMessageQueueId_t mq_id , int32_t status )
151162{
152- MBED_ERROR1 ( MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT ), error_msg ( status ), mq_id );
163+ trap_rtx_error (( unsigned int ) mq_id , status , MBED_MAKE_ERROR ( MBED_MODULE_PLATFORM , MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT ) );
153164}
154165
155166#endif
0 commit comments