CMSIS-RTOS2  Version 2.1.0
Real-Time Operating System: API and RTX Reference Implementation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

RTX5 functions. More...

Functions

uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
 OS Error Callback function. More...
 
void osRtxIdleThread (void *argument)
 OS Idle Thread. More...
 
int32_t osRtxSysTimerSetup (void)
 OS System Timer functions (default implementation uses SysTick) More...
 
void osRtxSysTimerEnable (void)
 Enable System Timer. More...
 
void osRtxSysTimerDisable (void)
 Disable System Timer. More...
 
void osRtxSysTimerAckIRQ (void)
 Acknowledge System Timer IRQ. More...
 
uint32_t osRtxSysTimerGetCount (void)
 Get System Timer count. More...
 
uint32_t osRtxSysTimerGetFreq (void)
 Get System Timer frequency. More...
 

Description

Function Documentation

uint32_t osRtxErrorNotify ( uint32_t  code,
void *  object_id 
)

Some system error conditions can be detected during runtime. If the RTX kernel detects a runtime error, it calls the runtime error function osRtxErrorNotify for an object specified by parameter object_id.

The parameter code passes the actual error code to this function:

Error Code Description
osRtxErrorStackUnderflow Stack underflow detected for thread (thread_id=object_id)
osRtxErrorISRQueueOverflow ISR Queue overflow detected when inserting object (object_id)
osRtxErrorTimerQueueOverflow User Timer Callback Queue overflow detected for timer (timer_id=object_id)
osRtxErrorClibSpace Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
osRtxErrorClibMutex Standard C/C++ library mutex initialization failed

The function osRtxErrorNotify must contain an infinite loop to prevent further program execution. You can use an emulator to step over the infinite loop and trace into the code introducing a runtime error. For the overflow errors this means you need to increase the size of the object causing an overflow.

Note
Cannot be called from Interrupt Service Routines.

Code Example

#include "rtx_os.h"
uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
(void)object_id;
switch (code) {
// Stack underflow detected for thread (thread_id=object_id)
break;
// ISR Queue overflow detected when inserting object (object_id)
break;
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
break;
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
break;
// Standard C/C++ library mutex initialization failed
break;
default:
break;
}
for (;;) {}
//return 0U;
}
osRtxErrorClibMutexvoid osRtxIdleThread ( void *  argument)

The function osRtxIdleThread is executed by the RTX kernel, when no other threads are ready to run. By default, this thread is an empty end-less loop that does nothing. It only waits until another task becomes ready to run. You may change the code of the osRtxIdleThread function to put the CPU into a power-saving or idle mode.

The default stack size for this thread is defined in the file RTX_Config.h. Refer to Thread Configuration.

Note
Cannot be called from Interrupt Service Routines.

Code Example

#include "rtx_os.h"
__NO_RETURN void osRtxIdleThread (void *argument) {
(void)argument;
for (;;) {}
}
int32_t osRtxSysTimerSetup ( void  )

Setup System Timer.

Returns
system timer IRQ number.

By default, RTX5 uses the Cortex-M SysTick timer, but using osRtxSysTimerSetup allows to set up an alternative system timer.

Note
Cannot be called from Interrupt Service Routines.
void osRtxSysTimerEnable ( void  )

The function osRtxSysTimerEnable enables the alternative system timer that has been set up using osRtxSysTimerSetup.

Note
Cannot be called from Interrupt Service Routines.
void osRtxSysTimerDisable ( void  )

The function osRtxSysTimerDisable disables the alternative system timer that has been set up using osRtxSysTimerSetup.

Note
Cannot be called from Interrupt Service Routines.
void osRtxSysTimerAckIRQ ( void  )
Note
Cannot be called from Interrupt Service Routines.
uint32_t osRtxSysTimerGetCount ( void  )
Returns
system timer count.

The function osRtxSysTimerGetCount returns the system timer count of the alternative timer set up by osRtxSysTimerSetup.

Note
Cannot be called from Interrupt Service Routines.
uint32_t osRtxSysTimerGetFreq ( void  )
Returns
system timer frequency.

The function osRtxSysTimerGetFreq returns the system timer frequency of the alternative timer set up by osRtxSysTimerSetup.

Note
Cannot be called from Interrupt Service Routines.