Initial commit
2385
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/rtos.dxy
vendored
Normal file
2381
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/rtos_CM0-7.dxy
vendored
Normal file
2465
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2.txt
vendored
Normal file
342
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Event.txt
vendored
Normal file
@ -0,0 +1,342 @@
|
||||
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Event Flag Management ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_EventFlags Event Flags
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Synchronize threads using event flags.
|
||||
\details
|
||||
The event flags management functions in CMSIS-RTOS allow you to control or wait for event flags. Each signal has up to 31
|
||||
event flags.
|
||||
|
||||
A thread
|
||||
- can wait for event flags to be set (using \ref osEventFlagsWait). Using this function, it enters the
|
||||
\ref ThreadStates "BLOCKED" state.
|
||||
- may set one or more flags in any other given thread (using \ref osEventFlagsSet).
|
||||
- may clear its own signals or the signals of other threads (using \ref osEventFlagsClear).
|
||||
|
||||
When a thread wakes up and resumes execution, its signal flags are automatically cleared (unless event flags option
|
||||
\ref osFlagsNoClear is specified).
|
||||
|
||||
\note The functions \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, and \ref osEventFlagsWait can be
|
||||
called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
\note Refer to \ref eventFlagsConfig for RTX5 configuration options.
|
||||
|
||||
Working with Events
|
||||
--------------------
|
||||
Here is a simple example that shows how two thread can communicate with each others using event flags:
|
||||
|
||||
\image html simple_signal.png "Simple event communication"
|
||||
|
||||
The following steps are required to use event flags:
|
||||
-# In the thread that is supposed to send a event with id sig1_id, call the set function:
|
||||
\code
|
||||
osDelay(1000U); // wait for 1 second
|
||||
osEventFlagsSet(sig1_id, 0x0001U); // set the flag 0x0001U for event sig1_id
|
||||
\endcode
|
||||
-# In another thread (or threads) that are supposed to wait for the event, call the wait function:
|
||||
\code
|
||||
osEventFlagsWait(sig1_id, 0x0001U, NULL, osWaitForever); // wait forever for any flag
|
||||
\endcode
|
||||
|
||||
The following complete example code can be directly used with the "CMSIS-RTOS2 main template" and is also provided as a
|
||||
stand-alone template for RTX5:
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Event Flags creation & usage
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define FLAGS_MSK1 0x00000001U
|
||||
|
||||
osEventFlagsId_t evt_id; // event flags id
|
||||
|
||||
osThreadId_t tid_Thread_EventSender; // thread id 1
|
||||
osThreadId_t tid_Thread_EventReceiver; // thread id 2
|
||||
|
||||
void Thread_EventSender (void *argument); // thread function 1
|
||||
void Thread_EventReceiver (void *argument); // thread function 2
|
||||
|
||||
int Init_Events (void) {
|
||||
|
||||
evt_id = osEventFlagsNew(NULL);
|
||||
if (evt_id == NULL) {
|
||||
; // Event Flags object not created, handle failure
|
||||
}
|
||||
|
||||
tid_Thread_EventSender = osThreadNew(Thread_EventSender, NULL, NULL);
|
||||
if (tid_Thread_EventSender == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
tid_Thread_EventReceiver = osThreadNew(Thread_EventReceiver, NULL, NULL);
|
||||
if (tid_Thread_EventReceiver == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void Thread_EventSender (void *argument) {
|
||||
|
||||
while (1) {
|
||||
osEventFlagsSet(evt_id, FLAGS_MSK1);
|
||||
osThreadYield(); // suspend thread
|
||||
}
|
||||
}
|
||||
|
||||
void Thread_EventReceiver (void *argument) {
|
||||
uint32_t flags;
|
||||
|
||||
while (1) {
|
||||
flags = osEventFlagsWait(evt_id, FLAGS_MSK1, osFlagsWaitAny, osWaitForever);
|
||||
//handle event
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osEventFlagsId_t
|
||||
\details
|
||||
Returned by:
|
||||
- \ref osEventFlagsNew
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\struct osEventFlagsAttr_t
|
||||
\details
|
||||
Attributes to configure an event flag set.
|
||||
|
||||
Refer to \ref CMSIS_RTOS_MemoryMgmt for details about usage of
|
||||
- osEventFlagsAttr_t::cb_mem
|
||||
- osEventFlagsAttr_t::cb_size
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr)
|
||||
\details
|
||||
The function \b osEventFlagsNew creates a new event flags object that is used to send events across threads and returns the
|
||||
pointer to the event flags object identifier or \token{NULL} in case of an error. It can be safely called before the RTOS is
|
||||
started (call to \ref osKernelStart), but not before it is initialized (call to \ref osKernelInitialize).
|
||||
|
||||
The parameter \a attr sets the event flags attributes (refer to \ref osEventFlagsAttr_t). Default attributes will be used if
|
||||
set to \token{NULL}, i.e. kernel memory allocation is used for the event control block.
|
||||
|
||||
\note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
osEventFlagsId_t evt_id; // message queue id
|
||||
|
||||
int Init_Events (void) {
|
||||
|
||||
evt_id = osEventFlagsNew(NULL);
|
||||
if (evt_id == NULL) {
|
||||
; // Event Flags object not created, handle failure
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)
|
||||
\details
|
||||
The function \b osEventFlagsSet sets the event flags specified by the parameter \a flags in an event flags object specified
|
||||
by parameter \a ef_id.
|
||||
|
||||
The threads with highest priority waiting for the flag(s) set will be notified to resume from \ref ThreadStates "BLOCKED" state.
|
||||
The function returns the event flags stored in the event control block or an error code (highest bit is set, refer to
|
||||
\ref flags_error_codes). Further threads may be wakened in priority order when the option \b osFlagsNoClear is given to the
|
||||
\ref osEventFlagsWait call.
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error.
|
||||
- \em osFlagsErrorParameter: parameter \a ef_id does not identify a valid event flags object or \em flags has highest bit set.
|
||||
- \em osFlagsErrorResource: the event flags object is in an invalid state.
|
||||
- \em osFlagsErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified event flags object.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
osEventFlagsId_t evt_id; // event flags id
|
||||
|
||||
void Thread_EventSender (void *argument) {
|
||||
|
||||
while (1) {
|
||||
osEventFlagsSet(evt_id, 0x00000001U);
|
||||
osThreadYield(); // suspend thread
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)
|
||||
\details
|
||||
The function \b osEventFlagsClear clears the event flags specified by the parameter \a flags in an event flags object
|
||||
specified by parameter \a ef_id. The function returns the event flags before clearing or an error code (highest bit is set,
|
||||
refer to \ref flags_error_codes).
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error.
|
||||
- \em osFlagsErrorParameter: parameter \a ef_id does not identify a valid event flags object or \em flags has highest bit set.
|
||||
- \em osFlagsErrorResource: the event flags object is in an invalid state.
|
||||
- \em osFlagsErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified event flags object.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osEventFlagsGet (osEventFlagsId_t ef_id)
|
||||
\details
|
||||
The function \b osEventFlagsGet returns the event flags currently set in an event flags object specified by parameter
|
||||
\a ef_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)
|
||||
\details
|
||||
The function \b osEventFlagsWait suspends the execution of the currently \ref ThreadStates "RUNNING" thread until any or all event flags
|
||||
specified by the parameter \a flags in the event object specified by parameter \a ef_id are set. When these event flags are
|
||||
already set, the function returns instantly. Otherwise, the thread is put into the state \ref ThreadStates "BLOCKED".
|
||||
|
||||
The \em options parameter specifies the wait condition:
|
||||
|Option | |
|
||||
|--------------------|-------------------------------------------------------|
|
||||
|\b osFlagsWaitAny | Wait for any flag (default). |
|
||||
|\b osFlagsWaitAll | Wait for all flags. |
|
||||
|\b osFlagsNoClear | Do not clear flags which have been specified to wait for. |
|
||||
|
||||
If \c osFlagsNoClear is set in the options \ref osEventFlagsClear can be used to clear flags manually.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits for event flags. While the system waits, the thread
|
||||
that is calling this function is put into the \ref ThreadStates "BLOCKED" state. The parameter \ref CMSIS_RTOS_TimeOutValue
|
||||
"timeout" can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the event flags become
|
||||
available (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
The function returns the event flags before clearing or an error code (highest bit is set, refer to \ref flags_error_codes).
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error.
|
||||
- \em osFlagsErrorTimeout: awaited flags have not been set in the given time.
|
||||
- \em osFlagsErrorResource: awaited flags have not been set when no \a timeout was specified.
|
||||
- \em osFlagsErrorParameter: parameter \a ef_id does not identify a valid event flags object or \em flags has highest bit set.
|
||||
- \em osFlagsErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified event flags object.
|
||||
|
||||
\note May be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" if the parameter \a timeout is set to
|
||||
\token{0}.
|
||||
|
||||
\b Code \b Example
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
osEventFlagsId_t evt_id; // event flags id
|
||||
|
||||
void Thread_EventReceiver (void *argument) {
|
||||
uint32_t flags;
|
||||
|
||||
while (1) {
|
||||
flags = osEventFlagsWait(evt_id, 0x00000001U, osFlagsWaitAny, osWaitForever);
|
||||
//handle event
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id)
|
||||
\details
|
||||
The function \b osEventFlagsDelete deletes the event flags object specified by parameter \a ef_id and releases the internal
|
||||
memory obtained for the event flags handling. After this call, the \em ef_id is no longer valid and cannot be used. This can
|
||||
cause starvation of threads that are waiting for flags of this event object. The \em ef_id may be created again using the
|
||||
function \ref osEventFlagsNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the specified event flags object has been deleted.
|
||||
- \em osErrorISR: \b osEventFlagsDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorParameter: parameter \a ef_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the event flags object is in an invalid state.
|
||||
- \em osFlagsErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified event flags object.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osEventFlagsGetName (osEventFlagsId_t ef_id)
|
||||
\details
|
||||
The function \b osEventFlagsGetName returns the pointer to the name string of the event flags object identified by parameter
|
||||
\a ef_id or \token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
osEventFlagsId_t evt_id; // event flasg id
|
||||
|
||||
void EvtFlagsGetName_example (void) {
|
||||
char *name;
|
||||
|
||||
name = osEventFlagsGetName(evt_id);
|
||||
if (name == NULL) {
|
||||
// Failed to get the event flags object name
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osEventFlagsAttr_t::attr_bits
|
||||
\details
|
||||
Reserved for future use (must be set to '0' for future compatibility).
|
||||
|
||||
\var osEventFlagsAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory for the event flag control block object. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the event flag control block.
|
||||
|
||||
\var osEventFlagsAttr_t::cb_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref cb_mem. For RTX, the minimum value is defined with \ref osRtxEventFlagsCbSize (higher values are permitted).
|
||||
|
||||
Default: \token{0} as the default is no memory provided with \ref cb_mem.
|
||||
|
||||
\var osEventFlagsAttr_t::name
|
||||
\details
|
||||
Pointer to a constant string with a human readable name (displayed during debugging) of the event flag object.
|
||||
|
||||
Default: \token{NULL} no name specified.
|
||||
*/
|
591
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Kernel.txt
vendored
Normal file
@ -0,0 +1,591 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Kernel Control ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_KernelCtrl Kernel Information and Control
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Provides version/system information and starts/controls the RTOS Kernel.
|
||||
\details
|
||||
The kernel Information and Control function group allows to:
|
||||
- obtain information about the system and the underlying kernel.
|
||||
- obtain version information about the CMSIS-RTOS API.
|
||||
- initialize of the RTOS kernel for creating objects.
|
||||
- start the RTOS kernel and thread switching.
|
||||
- check the execution status of the RTOS kernel.
|
||||
|
||||
\note The kernel information and control functions cannot be called from
|
||||
\ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
\note The kernel initialization for RTX5 is documented in \ref SystemStartup.
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
/*----------------------------------------------------------------------------
|
||||
* Application main thread
|
||||
*---------------------------------------------------------------------------*/
|
||||
void app_main (void *argument) {
|
||||
|
||||
// ...
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
|
||||
// System Initialization
|
||||
SystemCoreClockUpdate();
|
||||
// ...
|
||||
|
||||
osKernelInitialize(); // Initialize CMSIS-RTOS
|
||||
osThreadNew(app_main, NULL, NULL); // Create application main thread
|
||||
osKernelStart(); // Start thread execution
|
||||
for (;;) {}
|
||||
}
|
||||
\endcode
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\struct osVersion_t
|
||||
\details
|
||||
Identifies the underlying RTOS kernel and API version number. The version is represented in a combined decimal number in the
|
||||
format: major.minor.rev: mmnnnrrrr
|
||||
|
||||
Use \ref osKernelGetInfo to retrieve the version numbers.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\enum osKernelState_t
|
||||
\details
|
||||
State of the kernel as retrieved by \ref osKernelGetState. In case \b osKernelGetState fails or if it is called from an ISR,
|
||||
it will return \c osKernelError, otherwise it returns the kernel state.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osKernelInitialize (void)
|
||||
\details
|
||||
The function \b osKernelInitialize initializes the RTOS Kernel. Before it is successfully executed, only the functions
|
||||
\ref osKernelGetInfo and \ref osKernelGetState may be called.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK in case of success.
|
||||
- \em osError if an unspecific error occurred.
|
||||
- \em osErrorISR if called from an \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routine".
|
||||
- \em osErrorNoMemory if no memory could be reserved for the operation.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b> Code Example</b>
|
||||
\code
|
||||
#include "RTE_Components.h"
|
||||
#include CMSIS_device_header
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Application main thread
|
||||
*---------------------------------------------------------------------------*/
|
||||
void app_main (void *argument) {
|
||||
|
||||
// ...
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
|
||||
// System Initialization
|
||||
SystemCoreClockUpdate();
|
||||
// ...
|
||||
|
||||
osKernelInitialize(); // Initialize CMSIS-RTOS
|
||||
osThreadNew(app_main, NULL, NULL); // Create application main thread
|
||||
osKernelStart(); // Start thread execution
|
||||
for (;;) {}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size)
|
||||
\details
|
||||
The function \b osKernelGetInfo retrieves the API and kernel version of the underlying RTOS kernel and a human readable
|
||||
identifier string for the kernel. It can be safely called before the RTOS is initialized or started (call to
|
||||
\ref osKernelInitialize or \ref osKernelStart).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK in case of success.
|
||||
- \em osError if an unspecific error occurred.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
void info (void) {
|
||||
char infobuf[100];
|
||||
osVersion_t osv;
|
||||
osStatus_t status;
|
||||
|
||||
status = osKernelGetInfo(&osv, infobuf, sizeof(infobuf));
|
||||
if(status == osOK) {
|
||||
printf("Kernel Information: %s\r\n", infobuf);
|
||||
printf("Kernel Version : %d\r\n", osv.kernel);
|
||||
printf("Kernel API Version: %d\r\n", osv.api);
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osKernelState_t osKernelGetState (void)
|
||||
\details
|
||||
The function \b osKernelGetState returns the current state of the kernel and can be safely called before the RTOS is
|
||||
initialized or started (call to \ref osKernelInitialize or \ref osKernelStart). In case it fails it will return \c osKernelError,
|
||||
otherwise it returns the kernel state (refer to \ref osKernelState_t for the list of kernel states).
|
||||
|
||||
Possible \ref osKernelState_t return values:
|
||||
- \ref osKernelError if an unspecific error occurred.
|
||||
- the actual kernel state otherwise.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
int main (void) {
|
||||
// System Initialization
|
||||
SystemCoreClockUpdate();
|
||||
// ...
|
||||
if(osKernelGetState() == osKernelInactive) { // Is the kernel initialized?
|
||||
osKernelInitialize(); // Initialize CMSIS-RTOS kernel
|
||||
}
|
||||
;
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osKernelStart (void)
|
||||
\details
|
||||
The function \b osKernelStart starts the RTOS kernel and begins thread switching. It will not return to its calling function
|
||||
in case of success. Before it is successfully executed, only the functions \ref osKernelGetInfo, \ref osKernelGetState, and
|
||||
object creation functions (\b osXxxNew) may be called.
|
||||
|
||||
At least one initial thread should be created prior osKernelStart, see \ref osThreadNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osError if an unspecific error occurred.
|
||||
- \em osErrorISR if called from an \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routine".
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
int main (void) {
|
||||
// System Initialization
|
||||
SystemCoreClockUpdate();
|
||||
// ...
|
||||
if(osKernelGetState() == osKernelInactive) {
|
||||
osKernelInitialize();
|
||||
}
|
||||
; // ... Start Threads
|
||||
if (osKernelGetState() == osKernelReady) { // If kernel is ready to run...
|
||||
osKernelStart(); // ... start thread execution
|
||||
}
|
||||
|
||||
while(1); // only reached in case of error
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn int32_t osKernelLock (void)
|
||||
\details
|
||||
The function \b osKernelLock allows to lock all task switches. It returns the previous value of the lock state (\token{1} if
|
||||
it was locked, \token{0} if it was unlocked), or a negative number representing an error code otherwise (refer to
|
||||
\ref osStatus_t).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osError if an unspecific error occurred.
|
||||
- \em osErrorISR if called from an \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routine".
|
||||
- \em osErrorSafetyClass if the calling thread safety class is lower than the kernel protect safety class.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
int32_t state = osKernelLock();
|
||||
// ... critical code
|
||||
osKernelRestore(state);
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn int32_t osKernelUnlock (void)
|
||||
\details
|
||||
The function \b osKernelUnlock resumes from \ref osKernelLock. It returns the previous value of the lock state (\token{1} if
|
||||
it was locked, \token{0} if it was unlocked), or a negative number representing an error code otherwise (refer to
|
||||
\ref osStatus_t).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osError if an unspecific error occurred.
|
||||
- \em osErrorISR if called from an \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routine".
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
int32_t sl = osKernelLock();
|
||||
// ... critical code
|
||||
{
|
||||
int32_t su = osKernelUnlock();
|
||||
// ... uncritical code
|
||||
osKernelRestoreLock(su);
|
||||
}
|
||||
// ... critical code
|
||||
osKernelRestoreLock(sl);
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn int32_t osKernelRestoreLock (int32_t lock)
|
||||
\details
|
||||
The function \b osKernelRestoreLock restores the previous lock state after \ref osKernelLock or \ref osKernelUnlock.
|
||||
|
||||
The argument \a lock specifies the lock state as obtained by \ref osKernelLock or \ref osKernelUnlock.
|
||||
|
||||
The function returns the new value of the lock state (\token{1} if it was locked, \token{0} if it was unlocked), or a
|
||||
negative number representing an error code otherwise (refer to \ref osStatus_t).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osError if an unspecific error occurred.
|
||||
- \em osErrorISR if called from interrupt other than fault or \ref osWatchdogAlarm_Handler.
|
||||
- \em osErrorSafetyClass if the calling thread safety class is lower than the kernel protect safety class.
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
int32_t sl = osKernelLock();
|
||||
// ... critical code
|
||||
{
|
||||
int32_t su = osKernelUnlock();
|
||||
// ... uncritical code
|
||||
osKernelRestoreLock(su);
|
||||
}
|
||||
// ... critical code
|
||||
osKernelRestoreLock(sl);
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osKernelSuspend (void)
|
||||
\details
|
||||
CMSIS-RTOS provides extension for tick-less operation which is useful for applications that use extensively low-power modes
|
||||
where the SysTick timer is also disabled. To provide a time-tick in such power-saving modes a wake-up timer is used to derive
|
||||
timer intervals. The function \b osKernelSuspend suspends the RTX kernel scheduler and thus enables sleep modes.
|
||||
|
||||
The return value can be used to determine the amount of system ticks until the next tick-based kernel event will occur, i.e.
|
||||
a delayed thread becomes ready again. It is recommended to set up the low power timer to generate a wake-up interrupt based
|
||||
on this return value.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
void osRtxIdleThread (void) {
|
||||
/* The idle thread is running
|
||||
when no other thread is ready
|
||||
to run. */
|
||||
unsigned int sleep;
|
||||
|
||||
for (;;) {
|
||||
/* HERE: include optional user
|
||||
code to be executed when no
|
||||
task runs. */
|
||||
sleep = osKernelSuspend(); /* Suspend RTX thread scheduler */
|
||||
|
||||
if (sleep) { /* How long can we sleep? */
|
||||
/* "sleep" is in RTX Timer Ticks
|
||||
which is 1ms in this
|
||||
configuration */
|
||||
|
||||
/* Setup wake-up e.g. watchdog */
|
||||
|
||||
__WFE(); /* Enter Power-down mode */
|
||||
|
||||
/* After Wake-up */
|
||||
sleep = tc; /* Adjust with cycles slept */
|
||||
}
|
||||
|
||||
osKernelResume(sleep); /* Resume thread scheduler */
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void osKernelResume (uint32_t sleep_ticks)
|
||||
\details
|
||||
CMSIS-RTOS provides extension for tick-less operation which is useful for applications that use extensively low-power modes
|
||||
where the SysTick timer is also disabled. To provide a time-tick in such power-saving modes a wake-up timer is used to derive
|
||||
timer intervals. The function \b osKernelResume enables the RTX kernel scheduler and thus wakes up the system from sleep
|
||||
mode.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
void osRtxIdleThread (void) {
|
||||
/* The idle thread is running
|
||||
when no other thread is ready
|
||||
to run. */
|
||||
unsigned int sleep;
|
||||
|
||||
for (;;) {
|
||||
/* HERE: include optional user
|
||||
code to be executed when no
|
||||
task runs. */
|
||||
sleep = osKernelSuspend(); /* Suspend RTX thread scheduler */
|
||||
|
||||
if (sleep) { /* How long can we sleep? */
|
||||
/* "sleep" is in RTX Timer Ticks
|
||||
which is 1ms in this
|
||||
configuration */
|
||||
|
||||
/* Setup wake-up e.g. watchdog */
|
||||
|
||||
__WFE(); /* Enter Power-down mode */
|
||||
|
||||
/* After Wake-up */
|
||||
sleep = tc; /* Adjust with cycles slept */
|
||||
}
|
||||
|
||||
osKernelResume(sleep); /* Resume thread scheduler */
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osKernelGetTickCount (void)
|
||||
\details
|
||||
The function \b osKernelGetTickCount returns the current RTOS kernel tick count.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
\b Code \b Example
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Thread_1 (void *arg) { // Thread function
|
||||
uint32_t tick;
|
||||
|
||||
tick = osKernelGetTickCount(); // retrieve the number of system ticks
|
||||
for (;;) {
|
||||
tick += 1000; // delay 1000 ticks periodically
|
||||
osDelayUntil(tick);
|
||||
// ...
|
||||
}
|
||||
}\endcode
|
||||
|
||||
Due to the limited value range used for the tick count it may overflow during runtime,
|
||||
i.e. after 2<sup>32</sup> ticks which are roughly 49days @ 1ms. Typically one has not to
|
||||
take special care of this unless a monotonic counter is needed. For such a case an additional
|
||||
64bit tick counter can be implemented as follows. The given example needs GetTick() called at
|
||||
least twice per tick overflow to work properly.
|
||||
|
||||
\b Code \b Example
|
||||
\code
|
||||
uint64_t GetTick(void) {
|
||||
static uint32_t tick_h = 0U;
|
||||
static uint32_t tick_l = 0U;
|
||||
uint32_t tick;
|
||||
|
||||
tick = osKernelGetTickCount();
|
||||
if (tick < tick_l) {
|
||||
tick_h++;
|
||||
}
|
||||
tick_l = tick;
|
||||
|
||||
return (((uint64_t)tick_h << 32) | tick_l);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osKernelGetTickFreq (void)
|
||||
\details
|
||||
The function \b osKernelGetTickFreq returns the frequency of the current RTOS kernel tick.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osKernelGetSysTimerCount (void)
|
||||
\details
|
||||
The function \b osKernelGetSysTimerCount returns the current RTOS kernel system timer as a 32-bit value.
|
||||
The value is a rolling 32-bit counter that is composed of the kernel system interrupt timer value
|
||||
and the counter that counts these interrupts (RTOS kernel ticks).
|
||||
|
||||
This function allows the implementation of very short timeout checks below the RTOS tick granularity.
|
||||
Such checks might be required when checking for a busy status in a device or peripheral initialization
|
||||
routine, see code example below.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code{.c}
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void SetupDevice (void) {
|
||||
uint32_t tick;
|
||||
|
||||
// Calculating 100us timeout in system timer ticks
|
||||
const uint32_t timeout = 100U * osKernelGetSysTimerFreq() / 1000000u;
|
||||
|
||||
tick = osKernelGetSysTimerCount(); // get start value of the Kernel system tick
|
||||
Device.Setup (); // initialize a device or peripheral
|
||||
do { // poll device busy status for 100 microseconds
|
||||
if (!Device.Busy) break; // check if device is correctly initialized
|
||||
} while ((osKernelGetSysTimerCount() - tick) < timeout));
|
||||
if (Device.Busy) {
|
||||
; // in case device still busy, signal error
|
||||
}
|
||||
// start interacting with device
|
||||
}
|
||||
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osKernelGetSysTimerFreq (void)
|
||||
\details
|
||||
The function \b osKernelGetSysTimerFreq returns the frequency of the current RTOS kernel system timer.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osKernelProtect (uint32_t safety_class);
|
||||
\details
|
||||
The function \b osKernelProtect configures kernel access protection. After its successful execution, only threads with
|
||||
safety class equal or higher than the \a safety_class specified in the argument can execute kernel control functions.
|
||||
- \ref osKernelLock
|
||||
- \ref osKernelUnlock
|
||||
- \ref osKernelRestoreLock
|
||||
- \ref osKernelSuspend
|
||||
- \ref osKernelResume
|
||||
- \ref osKernelProtect
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK in case of success.
|
||||
- \em osErrorParameter if \a safety_class is invalid.
|
||||
- \em osError if kernel is not in ready or running state.
|
||||
- \em osErrorISR if called from an \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routine".
|
||||
- \em osErrorSafetyClass if the calling thread safety class is lower than the kernel protect safety class.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example:</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void ProtectKernelControlFunctions (void) {
|
||||
osStatus_t status;
|
||||
|
||||
status = osKernelProtect(4U); // Enable Kernel Control for threads with safety class 4 or higher
|
||||
// verify status value here.
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osKernelDestroyClass (uint32_t safety_class, uint32_t mode);
|
||||
\details
|
||||
The function \b osKernelDestroyClass destroys RTOS objects based on safety class assignment. \a safety_class provides the reference safety class value, while \a mode is considered as a bitmap that additionally specifies the safety classes to be destroyed.
|
||||
|
||||
If \ref osSafetyWithSameClass is set in \a mode than the RTOS objects with safety class value equal to \a safety_class will be destroyed.
|
||||
<br>
|
||||
If \ref osSafetyWithLowerClass is set in \a mode than the RTOS objects with safety class value lower than \a safety_class will be destroyed.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK in case of success.
|
||||
- \em osErrorParameter if \a safety_class is invalid.
|
||||
- \em osErrorResource if no other \ref ThreadStates "READY" thread exists.
|
||||
- \em osErrorISR if called from interrupt other than \ref osWatchdogAlarm_Handler.
|
||||
- \em osErrorSafetyClass if the calling thread safety class is lower than the kernel protect safety class.
|
||||
|
||||
<b>Code Example:</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void DestroyNonCriticalClasses (void) {
|
||||
osStatus_t status;
|
||||
|
||||
status = osKernelDestroyClass(4U, osSafetyWithSameClass | osSafetyWithLowerClass); // Destroy objects with safety class 4 or lower
|
||||
// verify status value here.
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void osFaultResume (void);
|
||||
\details
|
||||
Resume normal RTOS operation when exiting exception faults.
|
||||
|
||||
<b>Code Example:</b>
|
||||
\code
|
||||
void HardFault_Handler (void) {
|
||||
__ASM volatile (
|
||||
"... \n\t" // Enter assembly and handle faults
|
||||
"... \n\t"
|
||||
"ldr r0,=osFaultResume \n\t" // Before exiting the handler load and
|
||||
"bx r0 \n\t" // jump to osFaultResume
|
||||
);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osKernelState_t::osKernelInactive
|
||||
\details
|
||||
The kernel is not ready yet. \ref osKernelInitialize needs to be executed successfully.
|
||||
|
||||
\var osKernelState_t::osKernelReady
|
||||
\details
|
||||
The kernel is not yet running. \ref osKernelStart transfers the kernel to the running state.
|
||||
|
||||
\var osKernelState_t::osKernelRunning
|
||||
\details
|
||||
The kernel is initialized and running.
|
||||
|
||||
\var osKernelState_t::osKernelLocked
|
||||
\details
|
||||
The kernel was locked with \ref osKernelLock. The functions \ref osKernelUnlock or \ref osKernelRestoreLock unlocks it.
|
||||
|
||||
\var osKernelState_t::osKernelSuspended
|
||||
\details
|
||||
The kernel was suspended using \ref osKernelSuspend. The function \ref osKernelResume returns to normal operation.
|
||||
|
||||
\var osKernelState_t::osKernelError
|
||||
\details
|
||||
An error occurred.
|
||||
|
||||
\var osKernelState_t::osKernelReserved
|
||||
\details
|
||||
Reserved.
|
||||
*/
|
||||
|
283
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_MemPool.txt
vendored
Normal file
@ -0,0 +1,283 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Memory Pool Management ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_PoolMgmt Memory Pool
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Manage thread-safe fixed-size blocks of dynamic memory.
|
||||
\details
|
||||
\b Memory \b Pools are fixed-size blocks of memory that are thread-safe. They operate much faster than the dynamically
|
||||
allocated heap and do not suffer from fragmentation. Being thread-safe, they can be accessed from threads and ISRs alike.
|
||||
|
||||
A Memory Pool can be seen as a linked list of available (unused) memory blocks of fixed and equal size. Allocating memory
|
||||
from a pool (using \ref osMemoryPoolAlloc) simply unchains a block from the list and hands over control to the user. Freeing
|
||||
memory to the pool (using \ref osMemoryPoolFree) simply rechains the block into the list.
|
||||
|
||||
\image html "mempool.png" "CMSIS-RTOS Memory Pools"
|
||||
|
||||
\note One must not write to freed block. It is up to the implementation to reuse the memory of unused blocks for internal
|
||||
control data, i.e. linked list pointers.
|
||||
|
||||
\b Shared \b memory is one of the basic models to exchange information between threads. Using memory pools for exchanging
|
||||
data, you can share more complex objects between threads if compared to a \ref CMSIS_RTOS_Message. Memory pool management
|
||||
functions are used to define and manage such fixed-sized memory pools.
|
||||
|
||||
\note The functions \ref osMemoryPoolAlloc, \ref osMemoryPoolFree, \ref osMemoryPoolGetCapacity,
|
||||
\ref osMemoryPoolGetBlockSize, \ref osMemoryPoolGetCount, \ref osMemoryPoolGetSpace can be called from
|
||||
\ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
\note Refer to \ref memPoolConfig for RTX5 configuration options.
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osMemoryPoolId_t
|
||||
\details
|
||||
Returned by:
|
||||
- \ref osMemoryPoolNew
|
||||
*/
|
||||
|
||||
/**
|
||||
\struct osMemoryPoolAttr_t
|
||||
\details
|
||||
Attributes to configure a memory pool.
|
||||
|
||||
Refer to \ref CMSIS_RTOS_MemoryMgmt for details about usage of
|
||||
- osMemoryPoolAttr_t::cb_mem
|
||||
- osMemoryPoolAttr_t::cb_size
|
||||
- osMemoryPoolAttr_t::mp_mem
|
||||
- osMemoryPoolAttr_t::mp_size
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)
|
||||
\details
|
||||
The function \b osMemoryPoolNew creates and initializes a memory pool object and returns the pointer to the memory pool
|
||||
object identifier or \token{NULL} in case of an error. It can be safely called before the RTOS is
|
||||
started (call to \ref osKernelStart), but not before it is initialized (call to \ref osKernelInitialize).
|
||||
|
||||
The total amount of memory needed is at least <code>block_count * block_size</code>. Memory from the pool can only be
|
||||
allocated/freed in fixed portions of \c block_size.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
\b Code \b Example
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Memory Pool creation & usage
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define MEMPOOL_OBJECTS 16 // number of Memory Pool Objects
|
||||
|
||||
typedef struct { // object data type
|
||||
uint8_t Buf[32];
|
||||
uint8_t Idx;
|
||||
} MEM_BLOCK_t;
|
||||
|
||||
osMemoryPoolId_t mpid_MemPool; // memory pool id
|
||||
|
||||
osThreadId_t tid_Thread_MemPool; // thread id
|
||||
|
||||
void Thread_MemPool (void *argument); // thread function
|
||||
|
||||
int Init_MemPool (void) {
|
||||
|
||||
mpid_MemPool = osMemoryPoolNew(MEMPOOL_OBJECTS, sizeof(MEM_BLOCK_t), NULL);
|
||||
if (mpid_MemPool == NULL) {
|
||||
; // MemPool object not created, handle failure
|
||||
}
|
||||
|
||||
tid_Thread_MemPool = osThreadNew(Thread_MemPool, NULL, NULL);
|
||||
if (tid_Thread_MemPool == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void Thread_MemPool (void *argument) {
|
||||
MEM_BLOCK_t *pMem;
|
||||
osStatus_t status;
|
||||
|
||||
while (1) {
|
||||
; // Insert thread code here...
|
||||
|
||||
pMem = (MEM_BLOCK_t *)osMemoryPoolAlloc(mpid_MemPool, 0U); // get Mem Block
|
||||
if (pMem != NULL) { // Mem Block was available
|
||||
pMem->Buf[0] = 0x55U; // do some work...
|
||||
pMem->Idx = 0U;
|
||||
|
||||
status = osMemoryPoolFree(mpid_MemPool, pMem); // free mem block
|
||||
switch (status) {
|
||||
case osOK:
|
||||
break;
|
||||
case osErrorParameter:
|
||||
break;
|
||||
case osErrorNoMemory:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
osThreadYield(); // suspend thread
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolGetName returns the pointer to the name string of the memory pool identified by parameter \a
|
||||
mp_id or \token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout)
|
||||
\details
|
||||
The blocking function \b osMemoryPoolAlloc allocates the memory pool parameter \a mp_id and returns a pointer to the address
|
||||
of the allocated memory or \token{0} in case of an error.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits to allocate the memory. While the system waits, the thread
|
||||
that is calling this function is put into the \ref ThreadStates "BLOCKED" state. The thread will become \ref ThreadStates "READY"
|
||||
as soon as at least one block of memory gets available.
|
||||
|
||||
The parameter \ref CMSIS_RTOS_TimeOutValue "timeout" can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the memory is allocated (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
The result is the pointer to the memory block allocated, or NULL if no memory is available.
|
||||
|
||||
\note It is in the responsibility of the user to respect the block size, i.e. not access memory beyond the blocks limit.
|
||||
|
||||
\note May be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" if the parameter \a timeout is set to
|
||||
\token{0}.
|
||||
|
||||
\b Code \b Example
|
||||
|
||||
Refer to \ref osMemoryPoolNew.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block)
|
||||
\details
|
||||
The function \b osMemoryPoolFree frees the memory pool block specified by the parameter \a block in the memory pool object
|
||||
specified by the parameter \a mp_id. The memory block is put back to the list of available blocks.
|
||||
|
||||
If another thread is waiting for memory to become available the thread is put to \ref ThreadStates "READY" state.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the memory has been freed.
|
||||
- \em osErrorParameter: parameter \a mp_id is \token{NULL} or invalid, \a block points to invalid memory.
|
||||
- \em osErrorResource: the memory pool is in an invalid state.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified memory pool.
|
||||
|
||||
\note \b osMemoryPoolFree may perform certain checks on the \a block pointer given. But using \b osMemoryPoolFree
|
||||
with a pointer other than one received from \ref osMemoryPoolAlloc has \b UNPREDICTED behaviour.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
\b Code \b Example
|
||||
|
||||
Refer to \ref osMemoryPoolNew.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolGetCapacity returns the maximum number of memory blocks in the memory pool object specified by
|
||||
parameter \a mp_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolGetBlockSize returns the memory block size in bytes in the memory pool object specified by
|
||||
parameter \a mp_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolGetCount returns the number of memory blocks used in the memory pool object specified by
|
||||
parameter \a mp_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolGetSpace returns the number of memory blocks available in the memory pool object specified by
|
||||
parameter \a mp_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id)
|
||||
\details
|
||||
The function \b osMemoryPoolDelete deletes a memory pool object specified by parameter \a mp_id. It releases internal
|
||||
memory obtained for memory pool handling. After this call, the \a mp_id is no longer valid and cannot be used. The
|
||||
memory pool may be created again using the function \ref osMemoryPoolNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the memory pool object has been deleted.
|
||||
- \em osErrorParameter: parameter \a mp_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the memory pool is in an invalid state.
|
||||
- \em osErrorISR: \b osMemoryPoolDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified memory pool.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osMemoryPoolAttr_t::attr_bits
|
||||
\details
|
||||
Reserved for future use (set to '0').\n
|
||||
Default: \token{0}.
|
||||
|
||||
\var osMemoryPoolAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory location for the memory pool control block object. This can optionally be used for custom memory management systems.\n
|
||||
Default: \token{NULL} (uses kernel memory management).
|
||||
|
||||
\var osMemoryPoolAttr_t::cb_size
|
||||
\details
|
||||
The size of the memory block passed with \ref cb_mem. Must be the size of a memory pool control block object or larger.
|
||||
|
||||
\var osMemoryPoolAttr_t::name
|
||||
\details
|
||||
Pointer to a string with a human readable name of the memory pool object.\n
|
||||
Default: \token{NULL}.
|
||||
|
||||
\var osMemoryPoolAttr_t::mp_mem
|
||||
\details
|
||||
Pointer to a memory location for the data of the memory pool object.\n
|
||||
Default: \token{NULL}.
|
||||
|
||||
\var osMemoryPoolAttr_t::mp_size
|
||||
\details
|
||||
The size of the memory passed with \ref mp_mem.
|
||||
*/
|
305
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Message.txt
vendored
Normal file
@ -0,0 +1,305 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Message Queue Management ====
|
||||
/**
|
||||
@addtogroup CMSIS_RTOS_Message Message Queue
|
||||
@ingroup CMSIS_RTOS
|
||||
@brief Exchange messages between threads in a FIFO-like operation.
|
||||
@details
|
||||
\b Message \b passing is another basic communication model between threads. In the message passing model, one thread sends
|
||||
data explicitly, while another thread receives it. The operation is more like some kind of I/O rather than a direct access to
|
||||
information to be shared. In CMSIS-RTOS, this mechanism is called s \b message \b queue. The data is passed from one thread
|
||||
to another in a FIFO-like operation. Using message queue functions, you can control, send, receive, or wait for messages. The
|
||||
data to be passed can be of integer or pointer type:
|
||||
|
||||
\image html "MessageQueue.png" "CMSIS-RTOS Message Queue"
|
||||
|
||||
Compared to a \ref CMSIS_RTOS_PoolMgmt, message queues are less efficient in general, but solve a broader range of problems.
|
||||
Sometimes, threads do not have a common address space or the use of shared memory raises problems, such as mutual exclusion.
|
||||
|
||||
\note The functions \ref osMessageQueuePut, \ref osMessageQueueGet, \ref osMessageQueueGetCapacity,
|
||||
\ref osMessageQueueGetMsgSize, \ref osMessageQueueGetCount, \ref osMessageQueueGetSpace can be called from
|
||||
\ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
\note Refer to \ref msgQueueConfig for RTX5 configuration options.
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osMessageQueueId_t
|
||||
\details
|
||||
Returned by:
|
||||
- \ref osMessageQueueNew
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\struct osMessageQueueAttr_t
|
||||
\details
|
||||
Specifies the following attributes for the \ref osMessageQueueNew function.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)
|
||||
\details
|
||||
The function \ref osMessageQueueNew creates and initializes a message queue object.
|
||||
The function returns a message queue object identifier or \token{NULL} in case of an error.
|
||||
|
||||
The function can be called after kernel initialization with \ref osKernelInitialize. It is possible to
|
||||
create message queue objects before the RTOS kernel is started with \ref osKernelStart.
|
||||
|
||||
The total amount of memory required for the message queue data is at least <code>msg_count * msg_size</code>.
|
||||
The \em msg_size is rounded up to a double even number to ensure 32-bit alignment of the memory blocks.
|
||||
|
||||
The memory blocks allocated from the message queue have a fixed size defined with the parameter \c msg_size.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
Refer to \ref osMessageQueuePut
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osMessageQueueGetName (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueGetName returns the pointer to the name string of the message queue identified by parameter \a
|
||||
mq_id or \token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout)
|
||||
\details
|
||||
The blocking function \b osMessageQueuePut puts the message pointed to by \a msg_ptr into the the message queue specified
|
||||
by parameter \a mq_id. The parameter \a msg_prio is used to sort message according their priority (higher numbers indicate
|
||||
a higher priority) on insertion.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits to put the message into the queue. While the system waits, the
|
||||
thread that is calling this function is put into the \ref ThreadStates "BLOCKED" state. The parameter \ref CMSIS_RTOS_TimeOutValue "timeout"
|
||||
can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the message is delivered (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the message has been put into the queue.
|
||||
- \em osErrorTimeout: the message could not be put into the queue in the given time (wait-timed semantics).
|
||||
- \em osErrorResource: not enough space in the queue (try semantics).
|
||||
- \em osErrorParameter: parameter \em mq_id is \token{NULL} or invalid, non-zero timeout specified in an ISR.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified message queue.
|
||||
|
||||
\note May be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" if the parameter \a timeout is set to
|
||||
\token{0}.
|
||||
|
||||
<b>Code Example:</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Message Queue creation & usage
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define MSGQUEUE_OBJECTS 16 // number of Message Queue Objects
|
||||
|
||||
typedef struct { // object data type
|
||||
uint8_t Buf[32];
|
||||
uint8_t Idx;
|
||||
} MSGQUEUE_OBJ_t;
|
||||
|
||||
osMessageQueueId_t mid_MsgQueue; // message queue id
|
||||
|
||||
osThreadId_t tid_Thread_MsgQueue1; // thread id 1
|
||||
osThreadId_t tid_Thread_MsgQueue2; // thread id 2
|
||||
|
||||
void Thread_MsgQueue1 (void *argument); // thread function 1
|
||||
void Thread_MsgQueue2 (void *argument); // thread function 2
|
||||
|
||||
int Init_MsgQueue (void) {
|
||||
|
||||
mid_MsgQueue = osMessageQueueNew(MSGQUEUE_OBJECTS, sizeof(MSGQUEUE_OBJ_t), NULL);
|
||||
if (mid_MsgQueue == NULL) {
|
||||
; // Message Queue object not created, handle failure
|
||||
}
|
||||
|
||||
tid_Thread_MsgQueue1 = osThreadNew(Thread_MsgQueue1, NULL, NULL);
|
||||
if (tid_Thread_MsgQueue1 == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
tid_Thread_MsgQueue2 = osThreadNew(Thread_MsgQueue2, NULL, NULL);
|
||||
if (tid_Thread_MsgQueue2 == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void Thread_MsgQueue1 (void *argument) {
|
||||
MSGQUEUE_OBJ_t msg;
|
||||
|
||||
while (1) {
|
||||
; // Insert thread code here...
|
||||
msg.Buf[0] = 0x55U; // do some work...
|
||||
msg.Idx = 0U;
|
||||
osMessageQueuePut(mid_MsgQueue, &msg, 0U, 0U);
|
||||
osThreadYield(); // suspend thread
|
||||
}
|
||||
}
|
||||
|
||||
void Thread_MsgQueue2 (void *argument) {
|
||||
MSGQUEUE_OBJ_t msg;
|
||||
osStatus_t status;
|
||||
|
||||
while (1) {
|
||||
; // Insert thread code here...
|
||||
status = osMessageQueueGet(mid_MsgQueue, &msg, NULL, 0U); // wait for message
|
||||
if (status == osOK) {
|
||||
; // process data
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
|
||||
\details
|
||||
The function \b osMessageQueueGet retrieves a message from the message queue specified by the parameter \a mq_id and saves it
|
||||
to the buffer pointed to by the parameter \a msg_ptr. The message priority is stored to parameter \a msg_prio if not token{NULL}.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits to retrieve the message from the queue. While the system waits,
|
||||
the thread that is calling this function is put into the \ref ThreadStates "BLOCKED" state. The parameter
|
||||
\ref CMSIS_RTOS_TimeOutValue "timeout" can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the message is retrieved (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the message has been retrieved from the queue.
|
||||
- \em osErrorTimeout: the message could not be retrieved from the queue in the given time (timed-wait semantics).
|
||||
- \em osErrorResource: nothing to get from the queue (try semantics).
|
||||
- \em osErrorParameter: parameter \em mq_id is \token{NULL} or invalid, non-zero timeout specified in an ISR.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified message queue.
|
||||
|
||||
\note May be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" if the parameter \a timeout is set to
|
||||
\token{0}.
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
Refer to \ref osMessageQueuePut
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueGetCapacity returns the maximum number of messages in the message queue object specified by
|
||||
parameter \a mq_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueGetMsgSize returns the maximum message size in bytes for the message queue object specified by
|
||||
parameter \a mq_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueGetCount returns the number of queued messages in the message queue object specified by
|
||||
parameter \a mq_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueGetSpace returns the number available slots for messages in the message queue object specified
|
||||
by parameter \a mq_id or \token{0} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueReset resets the message queue specified by the parameter \a mq_id.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the message queue has been rest.
|
||||
- \em osErrorParameter: parameter \em mq_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the message queue is in an invalid state.
|
||||
- \em osErrorISR: \b osMessageQueueReset cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified message queue.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id)
|
||||
\details
|
||||
The function \b osMessageQueueDelete deletes a message queue object specified by parameter \a mq_id. It releases internal
|
||||
memory obtained for message queue handling. After this call, the \a mq_id is no longer valid and cannot be used. The
|
||||
message queue may be created again using the function \ref osMessageQueueNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the message queue object has been deleted.
|
||||
- \em osErrorParameter: parameter \em mq_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the message queue is in an invalid state.
|
||||
- \em osErrorISR: \b osMessageQueueDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified message queue.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osMessageQueueAttr_t::attr_bits
|
||||
\details
|
||||
Reserved for future use (must be set to '0' for future compatibility).
|
||||
|
||||
\var osMessageQueueAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory for the message queue control block object. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the message queue control block.
|
||||
|
||||
\var osMessageQueueAttr_t::cb_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref cb_mem. For RTX, the minimum value is defined with \ref osRtxMessageQueueCbSize (higher values are permitted).
|
||||
|
||||
Default: \token{0} as the default is no memory provided with \ref cb_mem.
|
||||
|
||||
\var osMessageQueueAttr_t::name
|
||||
\details
|
||||
Pointer to a constant string with a human readable name (displayed during debugging) of the message queue object.
|
||||
|
||||
Default: \token{NULL} no name specified.
|
||||
|
||||
\var osMessageQueueAttr_t::mq_mem
|
||||
\details
|
||||
Pointer to a memory for the message queue data. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the memory pool data.
|
||||
|
||||
\var osMessageQueueAttr_t::mq_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref mq_mem. The minimum memory block size is <code>msg_count * msg_size</code> (parameters of the \ref osMessageQueueNew function). The \em msg_size is rounded up to a double even number to ensure 32-bit alignment of the memory blocks.
|
||||
|
||||
Default: 0 as the default is no memory provided with \ref mq_mem.
|
||||
*/
|
844
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Migration.txt
vendored
Normal file
@ -0,0 +1,844 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\page os2Migration Migration from API v1 to API v2
|
||||
|
||||
To use the API version 2 functions follow the steps described in:
|
||||
- \subpage os2MigrationGuide - Steps to migrate from API version 1 to API version 2
|
||||
- \subpage os2MigrationFunctions - List of function differences
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
Functions
|
||||
\endif
|
||||
\page os2MigrationFunctions Detailed API Function Differences
|
||||
|
||||
This section lists the CMSIS-RTOS API v1 and API v2 functions along with the differences in functionality.
|
||||
The list is sorted alphabetically by API v2 function names and is structured the following way:
|
||||
|
||||
- RTOS API v2 function prototype
|
||||
- RTOS API v1 function prototype that is equivalent or provides similar functionality
|
||||
- Brief description of the RTOS v2 function.
|
||||
- Description of the difference.
|
||||
|
||||
The background color indicates:
|
||||
- <div class="new">Green: New functions in API v2 that are not available in API v1 </div>
|
||||
|
||||
- <div class="mod">Amber: Functions that are modified or replaced in API v2 compared to API v1 </div>
|
||||
|
||||
- <div class="del">Red: Functions in API v1 that are deprecated in API v2 </div>
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
Kernel Information and Control
|
||||
\endif
|
||||
|
||||
\section mig_kernel Kernel Information and Control
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osKernelGetInfo (osVersion_t* version, char* id_buf, uint32_t id_size)}
|
||||
\none
|
||||
\copybrief{osKernelGetInfo}
|
||||
New function #osKernelGetInfo.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osKernelState_t #osKernelGetState (void)}
|
||||
\func{int32_t osKernelRunning (void)}
|
||||
\copybrief{osKernelGetState}
|
||||
- The function \b osKernelGetState replaces the RTOS v1 function \b osKernelRunning.
|
||||
- Return type changed to \ref osKernelState_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osKernelGetTickCount (void)}
|
||||
\none
|
||||
\copybrief{osKernelGetTickCount}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osKernelGetTickFreq (void)}
|
||||
\none
|
||||
\copybrief{osKernelGetTickFreq}
|
||||
- The function \b osKernelGetTickFreq replaces the RTOS v1 macro \b osKernelTickMicroSec.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{uint32_t #osKernelGetSysTimerCount (void)}
|
||||
\func{uint32_t osKernelSysTick (void)}
|
||||
\copybrief{osKernelGetSysTimerCount}
|
||||
- The function \b osKernelGetSysTimerCount replaces the RTOS v1 function \b osKernelSysTick.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint64_t #osKernelGetSysTimerFreq (void)}
|
||||
\none
|
||||
\copybrief{osKernelGetSysTimerFreq}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osKernelInitialize (void)}
|
||||
\func{osStatus osKernelInitialize (void)}
|
||||
\copybrief{osKernelInitialize}
|
||||
- Return type changed to \ref osStatus_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{int32_t #osKernelLock (void)}
|
||||
\none
|
||||
\copybrief{osKernelLock}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{int32_t #osKernelUnlock (void)}
|
||||
\none
|
||||
\copybrief{osKernelUnlock}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{void #osKernelRestoreLock (void)}
|
||||
\none
|
||||
\copybrief{osKernelRestoreLock}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osKernelStart (void)}
|
||||
\func{osStatus osKernelStart (void)}
|
||||
\copybrief{osKernelStart}
|
||||
- Return type changed to \ref osStatus_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osKernelSuspend (void)}
|
||||
\none
|
||||
\copybrief{osKernelSuspend}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{void #osKernelResume (uint32_t sleep_time)}
|
||||
\none
|
||||
\copybrief{osKernelResume}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Thread Management =======
|
||||
\endif
|
||||
|
||||
\section mig_threadMgmt Thread Management
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osThreadDetach (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadDetach}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items)}
|
||||
\none
|
||||
\copybrief{osThreadEnumerate}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{__NO_RETURN void #osThreadExit (void)}
|
||||
\none
|
||||
\copybrief{osThreadExit}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadGetCount (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadGetCount}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osThreadGetName (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osThreadId_t #osThreadGetId (void)}
|
||||
\func{osThreadId osThreadGetId (void)}
|
||||
\copybrief{osThreadGetId}
|
||||
- Return type changed to #osThreadId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osPriority_t #osThreadGetPriority (osThreadId_t thread_id)}
|
||||
\func{osPriority osThreadGetPriority (osThreadId thread_id)}
|
||||
\copybrief{osThreadGetPriority}
|
||||
- Return type changed to #osPriority_t.
|
||||
- Parameter type changed to #osThreadId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadGetStackSize (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadGetStackSize}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadGetStackSpace (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadGetStackSpace}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osThreadState_t #osThreadGetState (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadGetState}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osThreadJoin (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadJoin}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osThreadId_t #osThreadNew (osThreadFunc_t function, void *argument, const osThreadAttr_t *attr)}
|
||||
\func{osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)}
|
||||
\copybrief{osThreadNew}
|
||||
- The function \b osThreadNew replaces the RTOS v1 function \b osThreadCreate.
|
||||
- Options are now passed using a \ref osThreadAttr_t struct, replacing the \b osThreadDef macro.
|
||||
- New function prototype is <kbd>void func (void *arg)</kbd>, before: <kbd>void func (const void *arg)</kbd>.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osThreadResume (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadResume}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority)}
|
||||
\func{osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority)}
|
||||
\copybrief{osThreadSetPriority}
|
||||
- Return type changed to #osStatus_t.
|
||||
- Parameter types changed to #osThreadId_t and #osPriority_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osThreadSuspend (osThreadId_t thread_id)}
|
||||
\none
|
||||
\copybrief{osThreadSuspend}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osThreadTerminate (osThreadId_t thread_id)}
|
||||
\func{osStatus osThreadTerminate (osThreadId thread_id)}
|
||||
\copybrief{osThreadTerminate}
|
||||
- Return type changed to #osStatus_t.
|
||||
- Parameter type changed to #osThreadId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osThreadYield (void)}
|
||||
\func{osStatus osThreadYield (void)}
|
||||
\copybrief{osThreadYield}
|
||||
- Return type changed to #osStatus_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Thread Flags =======
|
||||
\endif
|
||||
|
||||
\section mig_threadFlags Thread Flags
|
||||
\details
|
||||
New section to synchronize threads using flags. Thread flags and the more flexible \ref mig_eventFlags are replacing the RTOS v1 <b>Signal Events</b>. Refer to \ref mig_signalEvents for a list of deprecated functions.
|
||||
Refer to \ref CMSIS_RTOS_ThreadFlagsMgmt for details.
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags)}
|
||||
\none
|
||||
\copybrief{osThreadFlagsSet}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadFlagsClear (uint32_t flags)}
|
||||
\none
|
||||
\copybrief{osThreadFlagsClear}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadFlagsGet (void)}
|
||||
\none
|
||||
\copybrief{osThreadFlagsGet}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)}
|
||||
\none
|
||||
\copybrief{osThreadFlagsWait}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Event Flags =======
|
||||
\endif
|
||||
|
||||
\section mig_eventFlags Event Flags
|
||||
\details
|
||||
New section to synchronize events using flags. Event flags and thread flags are replacing the RTOS v1 <b>Signal Events</b>.
|
||||
All functions listed in the RTOS v1 <b>Signal Events</b> have been deprecated.
|
||||
Refer to \ref mig_signalEvents for a list of deprecated functions.
|
||||
Refer to \ref CMSIS_RTOS_EventFlags for details about the new function.
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)}
|
||||
\none
|
||||
\copybrief{osEventFlagsClear}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osEventFlagsGetName (osEventFlagsId_t ef_id)}
|
||||
\none
|
||||
\copybrief{osEventFlagsGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osEventFlagsDelete (osEventFlagsId_t ef_id)}
|
||||
\none
|
||||
\copybrief{osEventFlagsDelete}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osEventFlagsGet (osEventFlagsId_t ef_id)}
|
||||
\none
|
||||
\copybrief{osEventFlagsGet}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osEventFlagsId_t #osEventFlagsNew (const osEventFlagsAttr_t *attr)}
|
||||
\none
|
||||
\copybrief{osEventFlagsNew}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)}
|
||||
\none
|
||||
\copybrief{osEventFlagsSet}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)}
|
||||
\none
|
||||
\copybrief{osEventFlagsWait}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Generic Wait Functions =======
|
||||
\endif
|
||||
|
||||
\section mig_wait Generic Wait Functions
|
||||
\details
|
||||
Refer to \ref CMSIS_RTOS_Wait for details.
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osDelay (uint32_t ticks)}
|
||||
\func{osStatus osDelay (uint32_t timeout)}
|
||||
\copybrief{osDelay}
|
||||
- The return type changed to #osStatus_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osDelayUntil (uint32_t ticks)}
|
||||
\none
|
||||
\copybrief{osDelayUntil}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osEvent osWait (uint32_t millisec)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Timer Management =======
|
||||
\endif
|
||||
|
||||
\section mig_timer Timer Management
|
||||
\details
|
||||
Refer to \ref CMSIS_RTOS_TimerMgmt for details.
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osTimerDelete (osTimerId_t timer_id)}
|
||||
\func{osStatus osTimerDelete (osTimerId timer_id)}
|
||||
\copybrief{osTimerDelete}
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter type has changed to #osTimerId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osTimerGetName (osTimerId_t timer_id)}
|
||||
\none
|
||||
\copybrief{osTimerGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osTimerIsRunning (osTimerId_t timer_id)}
|
||||
\none
|
||||
\copybrief{osTimerIsRunning}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osTimerId_t #osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)}
|
||||
\func{osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument)}
|
||||
\copybrief{osTimerNew}
|
||||
- The function \b osTimerNew replaces the RTOS v1 function \b osTimerCreate.
|
||||
- The return type changed to #osTimerId_t.
|
||||
- The parameter list and types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osTimerStart (osTimerId_t timer_id, uint32_t ticks)}
|
||||
\func{osStatus osTimerStart (osTimerId timer_id, uint32_t timeout)}
|
||||
\copybrief{osTimerStart}
|
||||
- The return type changed to #osStatus_t.
|
||||
- The first parameter type has changed to #osTimerId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osTimerStop (osTimerId_t timer_id)}
|
||||
\func{osStatus osTimerStop (osTimerId timer_id)}
|
||||
\copybrief{osTimerStop}
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter type has changed to #osTimerId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Mutexes =======
|
||||
\endif
|
||||
|
||||
\section mig_mutex Mutexes
|
||||
Refer to \ref CMSIS_RTOS_MutexMgmt for details.
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout)}
|
||||
\func{osStatus osMutexWait (osMutexId mutex_id, uint32_t timeout)}
|
||||
\copybrief{osMutexAcquire}
|
||||
- The function \b osMutexAcquire replaces the RTOS v1 function \b osMutexWait.
|
||||
- Return type changed to \ref osStatus_t.
|
||||
- First parameter type changed to \ref osMutexId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMutexDelete (osMutexId_t mutex_id)}
|
||||
\func{osStatus osMutexDelete (osMutexId mutex_id)}
|
||||
\copybrief{osMutexDelete}
|
||||
- The return type changed to \ref osStatus_t.
|
||||
- The parameter type changed to \ref osMutexId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osMutexGetName (osMutexId_t mutex_id)}
|
||||
\none
|
||||
\copybrief{osMutexGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osThreadId_t #osMutexGetOwner (osMutexId_t mutex_id)}
|
||||
\none
|
||||
\copybrief{osMutexGetOwner}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osMutexId_t #osMutexNew (const osMutexAttr_t *attr)}
|
||||
\func{osMutexId osMutexCreate (const osMutexDef_t *mutex_def)}
|
||||
\copybrief{osMutexNew}
|
||||
- The function \b osMutexNew replaces the RTOS v1 function \b osMutexCreate.
|
||||
- The return type changed to \ref osMutexId_t.
|
||||
- The parameter type changed to \ref osMutexAttr_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMutexRelease (osMutexId_t mutex_id)}
|
||||
\func{osStatus osMutexRelease (osMutexId mutex_id)}
|
||||
\copybrief{osMutexRelease}
|
||||
- The return type changed to \ref osStatus_t.
|
||||
- The parameter type changed to \ref osMutexId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== SEMAPHORES =======
|
||||
\endif
|
||||
|
||||
\section mig_sem Semaphores
|
||||
Refer to \ref CMSIS_RTOS_SemaphoreMgmt for details.
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout)}
|
||||
\none
|
||||
\copybrief{osSemaphoreAcquire}
|
||||
New function. Replaces \c osSemaphoreWait.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osSemaphoreDelete (osSemaphoreId_t semaphore_id)}
|
||||
\func{osStatus osSemaphoreDelete (osSemaphoreId semaphore_id)}
|
||||
\copybrief{osSemaphoreDelete}
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter type has changed to #osSemaphoreId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osSemaphoreGetCount (osSemaphoreId_t semaphore_id)}
|
||||
\none
|
||||
\copybrief{osSemaphoreGetCount}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osSemaphoreGetName (osSemaphoreId_t semaphore_id)}
|
||||
\none
|
||||
\copybrief{osSemaphoreGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osSemaphoreId_t #osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)}
|
||||
\func{osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count)}
|
||||
\copybrief{osSemaphoreNew}
|
||||
- The function \b osSemaphoreNew replaces the RTOS v1 function \b osSemaphoreCreate.
|
||||
- The return type changed to #osSemaphoreId_t.
|
||||
- The parameter list and types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osSemaphoreRelease (osSemaphoreId_t semaphore_id)}
|
||||
\func{osStatus osSemaphoreRelease (osSemaphoreId semaphore_id)}
|
||||
\copybrief{osSemaphoreRelease}
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter type has changed to #osSemaphoreId_t.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t timeout)}
|
||||
\n
|
||||
Deprecated. Replaced by #osSemaphoreAcquire.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Memory Pool =======
|
||||
\endif
|
||||
|
||||
\section mig_memPool Memory Pool
|
||||
|
||||
\div{mod}
|
||||
\func{void * #osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout)}
|
||||
\func{void * osPoolAlloc (osPoolId pool_id)}
|
||||
\copybrief{osMemoryPoolAlloc}
|
||||
- The function \b osMemoryPoolAlloc replaces both RTOS v1 functions \b osPoolAlloc.
|
||||
- The parameter list and types changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osMemoryPoolDelete (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolDelete}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMemoryPoolFree (osMemoryPoolId_t mp_id, void * block)}
|
||||
\func{osStatus osPoolFree (osPoolId pool_id, void * block)}
|
||||
\copybrief{osMemoryPoolFree}
|
||||
- The function \b osMemoryPoolFree replaces the RTOS v1 function \b osPoolFree.
|
||||
- The first parameter type \b osMemoryPoolId_t replaces the ROTS v1 type \b osPoolId.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolGetBlockSize}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolGetCapacity}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMemoryPoolGetCount (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolGetCount}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osMemoryPoolGetName (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMemoryPoolGetSpace (osMemoryPoolId_t mp_id)}
|
||||
\none
|
||||
\copybrief{osMemoryPoolGetSpace}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osMemoryPoolId_t #osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)}
|
||||
\func{osPoolId osPoolCreate (const osPoolDef_t * pool_def)}
|
||||
\copybrief{osMemoryPoolGetSpace}
|
||||
- The function \b osMemoryPoolNew replaces the RTOS v1 function \b osPoolCreate.
|
||||
- The return type changed to #osMemoryPoolId_t.
|
||||
- Parameter list and parameter types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Message Queue =======
|
||||
\endif
|
||||
|
||||
\section mig_msgQueue Message Queue
|
||||
In general, messages are now using fixed size memory instead of being 32-bit values. Refer to \ref CMSIS_RTOS_Message for
|
||||
details.
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osMessageQueueDelete (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueDelete}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)}
|
||||
\func{osEvent osMessageGet (osMessageQId queue_id, uint32_t timeout)}
|
||||
\copybrief{osMessageQueueGet}
|
||||
- The function \b osMessageQueueGet replaces the RTOS v1 function \b osMessageGet.
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter list and parameter types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMessageQueueGetCapacity (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueGetCapacity}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMessageQueueGetCount (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueGetCount}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMessageQueueGetMsgSize (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueGetMsgSize}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{const char *#osMessageQueueGetName (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueGetName}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{uint32_t #osMessageQueueGetSpace (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueGetSpace}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osMessageQueueId_t #osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)}
|
||||
\func{osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id)}
|
||||
\copybrief{osMessageQueueNew}
|
||||
- The function \b osMessageQueueNew replaces the RTOS v1 function \b osMessageCreate.
|
||||
- The return type changed to #osMessageQueueId_t.
|
||||
- The parameter list and parameter types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{mod}
|
||||
\func{osStatus_t #osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout)}
|
||||
\func{osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t timeout)}
|
||||
\copybrief{osMessageQueuePut}
|
||||
- The function \b osMessageQueuePut replaces the RTOS v1 function \b osMessagePut.
|
||||
- The return type changed to #osStatus_t.
|
||||
- The parameter list and parameter types have changed.
|
||||
|
||||
\enddiv
|
||||
|
||||
\div{new}
|
||||
\func{osStatus_t #osMessageQueueReset (osMessageQueueId_t mq_id)}
|
||||
\none
|
||||
\copybrief{osMessageQueueReset}
|
||||
New function.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Mail Queue =======
|
||||
\endif
|
||||
|
||||
\section mig_mailQueue Mail Queue
|
||||
The <b>Mail Queue</b> RTOS v1 functions have been deprecated.
|
||||
Use the functionality of the \ref CMSIS_RTOS_Message instead.
|
||||
Differences are listed under \ref mig_msgQueue.
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{void * osMailAlloc (osMailQId queue_id, uint32_t timeout)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{void * osMailCAlloc (osMailQId queue_id, uint32_t timeout)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osStatus osMailFree (osMailQId queue_id, void *mail)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osEvent osMailGet (osMailQId queue_id, uint32_t timeout)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osStatus osMailPut (osMailQId queue_id, void *mail)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
|
||||
\if NEVER_ENABLE
|
||||
=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====
|
||||
====== Signal Events =======
|
||||
\endif
|
||||
|
||||
\section mig_signalEvents Signal Events
|
||||
\details
|
||||
The section RTOS v1 <b>Signal Events</b> has been deprecated. Use the functions listed under \ref mig_threadFlags instead.
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{int32_t osSignalClear (osThreadId thread_id, int32_t signals)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{int32_t osSignalSet (osThreadId thread_id, int32_t signals)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
|
||||
\div{del}
|
||||
\none
|
||||
\func{osEvent osSignalWait (int32_t signals, uint32_t timeout)}
|
||||
\n
|
||||
Deprecated.
|
||||
\enddiv
|
||||
*/
|
187
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_MigrationGuide.txt
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\page os2MigrationGuide RTX Migration Guide
|
||||
|
||||
RTX5 supplies both API layers: CMSIS-RTOS v1 and CMSIS-RTOS v2. This allows a gradient transition from version 1 to 2. A
|
||||
modified v1 header and a special v1 compatibility module enable existing code to run on a v2 implementation with almost no
|
||||
modifications.
|
||||
|
||||
Only a few incompatibilities and limitations exist:
|
||||
- Kernel startup\n
|
||||
- The function \c osKernelRunning has been removed in CMSIS-RTOS v2, use osKernelGetState() instead.
|
||||
- Function \c main was usually a running thread in CMSIS-RTOS v1 implementations, which is not the case in CMSIS-RTOS v2
|
||||
anymore. The Kernel was running even without calling corresponding APIs to initialize and start the Kernel explicitly.
|
||||
In CMSIS-RTOS v2 the Kernel needs be initialized by calling osKernelInitialize() and must be started by calling
|
||||
osKernelStart().
|
||||
- OS tick\n
|
||||
RTX5 uses the \ref CMSIS_RTOS_TickAPI to configure the tick interrupts. The interval calculation is typically based on
|
||||
\c SystemCoreClock variable. Thus one has to assure this variable is set correctly before calling \ref osKernelStart.
|
||||
- The function \c osWait is deprecated.
|
||||
- Error code incompatibility\n
|
||||
CMSIS-RTOS v1 used two different error codes for invalid parameters: \c osErrorParameter and \c osErrorValue. The new
|
||||
version only uses a common \ref osErrorParameter code. Therefore, code relying on osErrorValue is not compatible. The
|
||||
following functions are affected:
|
||||
- \ref osThreadSetPriority returns \ref osErrorParameter instead of osErrorValue when priority is out of range
|
||||
- \ref osMemoryPoolFree (previously \c osPoolFree) returns \ref osErrorParameter instead of osErrorValue when block to be
|
||||
returned is invalid
|
||||
- The \ref osDelay return code has changed from osErrorTimeout to \ref osOK.
|
||||
|
||||
The level of migration depends on the project's phase in its life cycle:
|
||||
- The \ref MigL1 "first level" of migration is to migrate to RTX5 without changing the API level.
|
||||
- The \ref MigL2 "second level" in the transition is to use v2 API functions and v1 API functions in mixed variation.
|
||||
- The \ref MigL3 "third level" is the full transition to the API v2. It is non-trivial and requires some additional
|
||||
development effort to migrate all API v1 calls to v2.
|
||||
|
||||
|
||||
\section MigL1 Level 1 Migration - Upgrade to RTX5 on API v1
|
||||
|
||||
Upgrade to RTX Version 5 from any 4.x version using the API v1 compatibility layer. Configure an existing project as follows:
|
||||
|
||||
- Open \b Manage \b Run-Time \b Environment window
|
||||
- Expand \b CMSIS software component.
|
||||
- Expand \b RTOS \b (API), uncheck \b Keil \b RTX, and select \b Keil \b RTX5.
|
||||
- Expand \b RTOS2 \b (API) and select \b Keil \b RTX5.
|
||||
- Resolve missing components.
|
||||
|
||||
\image html "RTX5_Migrate1.PNG" "Component Selection for RTX5"
|
||||
|
||||
- Click OK.
|
||||
- Expand \b CMSIS group in the \b Project window:
|
||||
- Open \b %RTX_Config.h and adapt the configuration to suit the application including (refer to \ref config_rtx5):
|
||||
- System Configuration->Global Dynamic Memory size
|
||||
- Kernel Tick Frequency
|
||||
- Thread Configuration->Default Thread Stack size
|
||||
- Rename function <tt>int main (void)</tt> to <tt>void app_main (void *arg)</tt>.
|
||||
- Create a new function <tt>int main (void)</tt> which implements at least:
|
||||
- System initialization and configuration
|
||||
- Update <a href="../../Core/html/group__system__init__gr.html">SystemCoreClock</a>
|
||||
- Initialize CMSIS-RTOS kernel
|
||||
- Creates new thread app_main
|
||||
- Start RTOS scheduler
|
||||
|
||||
<b>Example - Application Main Thread</b>
|
||||
\code
|
||||
#include "RTE_Components.h"
|
||||
#include CMSIS_device_header
|
||||
|
||||
/* Renamed main() function */
|
||||
void app_main (void const *argument) {
|
||||
// contents of old "main"
|
||||
}
|
||||
|
||||
osThreadDef(app_main, osPriorityNormal, 1, 0);
|
||||
|
||||
int main (void) {
|
||||
// System Initialization
|
||||
SystemCoreClockUpdate();
|
||||
// ...
|
||||
osKernelInitialize();
|
||||
osThreadCreate(osThread(app_main), NULL);
|
||||
osKernelStart();
|
||||
for (;;);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\note In RTOS API v1 all timings were specified in milliseconds. RTX5 defines all times in kernel ticks.
|
||||
To match both it is recommended to set the Kernel Tick Frequency to 1000 Hz in the \ref systemConfig.
|
||||
|
||||
To validate the correct operation of your RTOS after migration you can temporarily integrate the \ref rtosValidation
|
||||
component into your project.
|
||||
|
||||
|
||||
\section MigL2 Level 2 Migration - Use API v2 and v1 alongside in RTX5
|
||||
|
||||
Implementing new features in your project is ideally done using the new API. Both API versions are offered in RTX5 and can
|
||||
exist along-side.
|
||||
|
||||
The component selection is identical to Migration Level 1.
|
||||
|
||||
Include "cmsis_os2.h" in all modules where access to API v2 functions is required.
|
||||
|
||||
\code
|
||||
#include "cmsis_os.h" // ARM::CMSIS:RTOS:Keil RTX5
|
||||
#include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5
|
||||
\endcode
|
||||
|
||||
The following snippet shows how threads - created with both API versions - live along-side:
|
||||
|
||||
\code
|
||||
/*----------------------------------------------------------------------------
|
||||
* Thread 4 'phaseD': Phase D output - API v2 thread
|
||||
*---------------------------------------------------------------------------*/
|
||||
void phaseD (void *argument) {
|
||||
for (;;) {
|
||||
osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
|
||||
Switch_On (LED_D);
|
||||
signal_func(tid_phaseA); /* call common signal function */
|
||||
Switch_Off(LED_D);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Thread 5 'clock': Signal Clock - API v1 thread
|
||||
*---------------------------------------------------------------------------*/
|
||||
void clock (void const *argument) {
|
||||
for (;;) {
|
||||
osSignalWait(0x0100, osWaitForever); /* Wait for event send by API v2 function osThreadFlagsSet() */
|
||||
Switch_On (LED_CLK);
|
||||
osDelay(80); /* delay ticks */
|
||||
Switch_Off(LED_CLK);
|
||||
}
|
||||
}
|
||||
|
||||
/* Define the API v1 thread */
|
||||
osThreadDef(clock, osPriorityNormal, 1, 0);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Main: Initialize and start RTX Kernel
|
||||
*---------------------------------------------------------------------------*/
|
||||
void app_main (void *argument) {
|
||||
|
||||
; //...
|
||||
/* Create the API v2 thread */
|
||||
tid_phaseD = osThreadNew(phaseD, NULL, NULL);
|
||||
/* Create the API v1 thread */
|
||||
tid_clock = osThreadCreate(osThread(clock), NULL);
|
||||
|
||||
osThreadFlagsSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */
|
||||
|
||||
osDelay(osWaitForever);
|
||||
while(1);
|
||||
}
|
||||
\endcode
|
||||
|
||||
The full example "RTX5 Migration" is part of the CMSIS5 pack and available from the pack installer.
|
||||
|
||||
|
||||
\section MigL3 Level 3 Migration - Full transition to API v2
|
||||
Migrating fully to APIv2 reduces the overhead of the translation layer and simplifies the project.
|
||||
There is some effort to replace and re-test all API Version 1 calls.
|
||||
The following steps are recommended as a rough guide-line:
|
||||
- Open Manage Run-Time Environment window:
|
||||
- Expand CMSIS Software Component:
|
||||
- Expand RTOS (API) Software Component and de-select Keil RTX5
|
||||
- Click OK
|
||||
- Exchange all occurrences of
|
||||
\code
|
||||
#include "cmsis_os.h"
|
||||
\endcode
|
||||
with
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
\endcode
|
||||
- Identify all references to the API v1 and replace with the appropriate calls in v2. You might want to use the Error List
|
||||
window in uVision to identify the related code passages quickly.
|
||||
|
||||
\note See \ref os2MigrationFunctions for details in differences.
|
||||
|
||||
Generally there are no longer os*Def macros to declare OS objects.
|
||||
|
||||
\note
|
||||
- Signal Events have been replaced. Use the functions listed under Thread Flags and Event Flags instead.
|
||||
- The Mail Queue RTOS v1 functions have been deprecated. Use the functionality of the Message Queue instead. Differences are
|
||||
listed under \ref mig_msgQueue.
|
||||
*/
|
||||
|
411
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Mutex.txt
vendored
Normal file
@ -0,0 +1,411 @@
|
||||
//
|
||||
// close group struct osMutexAttr_t
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Mutex Management ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_MutexMgmt Mutex Management
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Synchronize resource access using Mutual Exclusion (Mutex).
|
||||
\details
|
||||
<b>Mutual exclusion</b> (widely known as \b Mutex) is used in various operating systems for resource management. Many
|
||||
resources in a microcontroller device can be used repeatedly, but only by one thread at a time (for example communication
|
||||
channels, memory, and files). Mutexes are used to protect access to a shared resource. A mutex is created and then passed
|
||||
between the threads (they can acquire and release the mutex).
|
||||
|
||||
\image html "Mutex.png" "CMSIS-RTOS Mutex"
|
||||
|
||||
A mutex is a special version of a \ref CMSIS_RTOS_SemaphoreMgmt "semaphore". Like the semaphore, it is a container for
|
||||
tokens. But instead of being able to have multiple tokens, a mutex can only carry one (representing the resource). Thus, a
|
||||
mutex token is binary and bounded, i.e. it is either \em available, or \em blocked by a owning thread. The advantage of a
|
||||
mutex is that it introduces thread ownership. When a thread acquires a mutex and becomes its owner, subsequent mutex acquires
|
||||
from that thread will succeed immediately without any latency (if \ref osMutexRecursive is specified). Thus, mutex acquires/releases
|
||||
can be nested.
|
||||
|
||||
\image html "mutex_states.png" "CMSIS-RTOS Mutex States"
|
||||
|
||||
\note Mutex management functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" (ISR), unlike a
|
||||
binary semaphore that can be released from an ISR.
|
||||
\note Refer to \ref mutexConfig for RTX5 configuration options.
|
||||
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osMutexRecursive
|
||||
\details
|
||||
Recursive flag in osMutexAttr_t.
|
||||
|
||||
The same thread can consume a mutex multiple times without locking itself.
|
||||
Each time the owning thread acquires the mutex the lock count is incremented. The mutex must
|
||||
be released multiple times as well until the lock count reaches zero. At reaching zero the
|
||||
mutex is actually released and can be acquired by other threads.
|
||||
|
||||
\note The maximum amount of recursive locks possible is implementation specific, i.e. the type size used for the lock count.
|
||||
If the maximum amount of recursive locks is depleted mutex acquire might fail.
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id;
|
||||
|
||||
const osMutexAttr_t Thread_Mutex_attr = {
|
||||
"myThreadMutex", // human readable mutex name
|
||||
osMutexRecursive, // attr_bits
|
||||
NULL, // memory for control block
|
||||
0U // size for control block
|
||||
};
|
||||
|
||||
// must be called from a thread context
|
||||
void UseMutexRecursively(int count) {
|
||||
osStatus_t result = osMutexAcquire(mutex_id, osWaitForever); // lock count is incremented, might fail when lock count is depleted
|
||||
if (result == osOK) {
|
||||
if (count < 10) {
|
||||
UseMutexRecursively(count + 1);
|
||||
}
|
||||
osMutexRelease(mutex_id); // lock count is decremented, actually releases the mutex on lock count zero
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osMutexPrioInherit
|
||||
\details
|
||||
Priority inheritance flag in osMutexAttr_t.
|
||||
|
||||
A mutex using priority inheritance protocol transfers a waiting threads priority to the
|
||||
current mutex owner if the owners thread priority is lower. This assures that a low priority
|
||||
thread does not block a high priority thread.
|
||||
|
||||
Otherwise a low priority thread might hold a mutex but is not granted execution time due to
|
||||
another mid priority thread. Without priority inheritance the high priority thread waiting
|
||||
for the mutex would be blocked by the mid priority thread, called priority inversion.
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
This example reveals a blocked high priority thread if \ref osMutexPrioInherit is removed.
|
||||
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id;
|
||||
|
||||
const osMutexAttr_t Thread_Mutex_attr = {
|
||||
"myThreadMutex", // human readable mutex name
|
||||
osMutexPrioInherit, // attr_bits
|
||||
NULL, // memory for control block
|
||||
0U // size for control block
|
||||
};
|
||||
|
||||
void HighPrioThread(void *argument) {
|
||||
osDelay(1000U); // wait 1s until start actual work
|
||||
while(1) {
|
||||
osMutexAcquire(mutex_id, osWaitForever); // try to acquire mutex
|
||||
// do stuff
|
||||
osMutexRelease(mutex_id);
|
||||
}
|
||||
}
|
||||
|
||||
void MidPrioThread(void *argument) {
|
||||
osDelay(1000U); // wait 1s until start actual work
|
||||
while(1) {
|
||||
// do non blocking stuff
|
||||
}
|
||||
}
|
||||
|
||||
void LowPrioThread(void *argument) {
|
||||
while(1) {
|
||||
osMutexAcquire(mutex_id, osWaitForever);
|
||||
osDelay(5000U); // block mutex for 5s
|
||||
osMutexRelease(mutex_id);
|
||||
osDelay(5000U); // sleep for 5s
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
During the first second the high and mid priority threads are delayed. Thus the low priority
|
||||
thread can start its work, acquires the mutex and delays while holding it.
|
||||
|
||||
After the first second the high and mid priority threads become ready. Thus the high priority
|
||||
thread gets precedence and tries to acquire the mutex. Because the mutex is already owned by
|
||||
the low priority thread the high priority thread gets blocked.
|
||||
|
||||
Finally the mid priority thread gets executed and start doing a lot of non-blocking stuff,
|
||||
i.e. it does not call any blocking RTOS functionality.
|
||||
|
||||
Without \ref osMutexPrioInherit we would stuck here forever. Even if the low priority thread
|
||||
gets ready after 5s. Due to its low priority the mid priority thread always gets precedence.
|
||||
The effect called priority inversion leads to the mid priority thread blocking the high
|
||||
priority thread indirectly.
|
||||
|
||||
Using \ref osMutexPrioInherit as shown in the example code we get rid of this situation. Due
|
||||
to the priority inheritance protocol the low priority thread inherits the high priority
|
||||
while holding the mutex. Thus the low priority thread gets precedence over the mid priority
|
||||
thread until it release the mutex. On osMutexRelease the high priority thread get ready and
|
||||
is scheduled immediately.
|
||||
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osMutexRobust
|
||||
\details
|
||||
Robust flag in osMutexAttr_t.
|
||||
|
||||
Robust mutexes are automatically released if the owning thread is terminated (either by
|
||||
\ref osThreadExit or \ref osThreadTerminate). Non-robust mutexes are not released and the user must
|
||||
assure mutex release manually.
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
This example reveals a blocked mutex if osMutexRobust is removed.
|
||||
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id;
|
||||
|
||||
const osMutexAttr_t Thread_Mutex_attr = {
|
||||
"myThreadMutex", // human readable mutex name
|
||||
osMutexRobust, // attr_bits
|
||||
NULL, // memory for control block
|
||||
0U // size for control block
|
||||
};
|
||||
|
||||
void Thread(void *argument) {
|
||||
osMutexAcquire(mutex_id, osWaitForever);
|
||||
osThreadExit();
|
||||
}
|
||||
\endcode
|
||||
|
||||
Due to \ref osMutexRobust the mutex gets released automatically. A non-robust mutex would stay locked and cannot be released anymore.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osMutexId_t
|
||||
\details
|
||||
Returned by:
|
||||
- \ref osMutexNew
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\struct osMutexAttr_t
|
||||
\details
|
||||
Specifies the following attributes for the \ref osMutexNew function.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osMutexId_t osMutexNew (const osMutexAttr_t *attr)
|
||||
\details
|
||||
The function \b osMutexNew creates and initializes a new mutex object and returns the pointer to the mutex object identifier
|
||||
or \token{NULL} in case of an error. It can be safely called before the RTOS is
|
||||
started (call to \ref osKernelStart), but not before it is initialized (call to \ref osKernelInitialize).
|
||||
|
||||
The parameter \a attr sets the mutex object attributes (refer to \ref osMutexAttr_t). Default attributes will be used if set
|
||||
to \token{NULL}.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id;
|
||||
|
||||
const osMutexAttr_t Thread_Mutex_attr = {
|
||||
"myThreadMutex", // human readable mutex name
|
||||
osMutexRecursive | osMutexPrioInherit, // attr_bits
|
||||
NULL, // memory for control block
|
||||
0U // size for control block
|
||||
};
|
||||
|
||||
void CreateMutex (void) {
|
||||
mutex_id = osMutexNew(&Thread_Mutex_attr);
|
||||
if (mutex_id != NULL) {
|
||||
// Mutex object created
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osMutexGetName (osMutexId_t mutex_id)
|
||||
\details
|
||||
The function \b osMutexGetName returns the pointer to the name string of the mutex identified by parameter \a mutex_id or
|
||||
\token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout)
|
||||
\details
|
||||
The blocking function \b osMutexAcquire waits until a mutex object specified by parameter \a mutex_id becomes available. If
|
||||
no other thread has obtained the mutex, the function instantly returns and blocks the mutex object.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits to acquire the mutex. While the system waits, the thread that is
|
||||
calling this function is put into the \ref ThreadStates "BLOCKED" state. The parameter \ref CMSIS_RTOS_TimeOutValue "timeout"
|
||||
can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the mutex becomes available (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the mutex has been obtained.
|
||||
- \em osErrorTimeout: the mutex could not be obtained in the given time.
|
||||
- \em osErrorResource: the mutex could not be obtained when no \a timeout was specified.
|
||||
- \em osErrorParameter: parameter \em mutex_id is \token{NULL} or invalid.
|
||||
- \em osErrorISR: cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified mutex.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void WaitMutex (void) {
|
||||
osMutexId_t mutex_id;
|
||||
osStatus_t status;
|
||||
|
||||
mutex_id = osMutexNew(NULL);
|
||||
if (mutex_id != NULL) {
|
||||
status = osMutexAcquire(mutex_id, 0U);
|
||||
if (status != osOK) {
|
||||
// handle failure code
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMutexRelease (osMutexId_t mutex_id)
|
||||
\details
|
||||
The function \b osMutexRelease releases a mutex specified by parameter \a mutex_id. Other threads that currently wait for
|
||||
this mutex will be put into the \ref ThreadStates "READY" state.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the mutex has been correctly released.
|
||||
- \em osErrorResource: the mutex could not be released (mutex was not acquired or running thread is not the owner).
|
||||
- \em osErrorParameter: parameter \em mutex_id is \token{NULL} or invalid.
|
||||
- \em osErrorISR: \b osMutexRelease cannot be called from interrupt service routines.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id; // Mutex id populated by the function osMutexNew()
|
||||
|
||||
void ReleaseMutex (osMutexId_t mutex_id) {
|
||||
osStatus_t status;
|
||||
|
||||
if (mutex_id != NULL) {
|
||||
status = osMutexRelease(mutex_id);
|
||||
if (status != osOK) {
|
||||
// handle failure code
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osThreadId_t osMutexGetOwner (osMutexId_t mutex_id)
|
||||
\details
|
||||
The function \b osMutexGetOwner returns the thread ID of the thread that acquired a mutex specified by parameter \a
|
||||
mutex_id. In case of an error or if the mutex is not blocked by any thread, it returns \token{NULL}.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osMutexDelete (osMutexId_t mutex_id)
|
||||
\details
|
||||
The function \b osMutexDelete deletes a mutex object specified by parameter \a mutex_id. It releases internal memory obtained
|
||||
for mutex handling. After this call, the \a mutex_id is no longer valid and cannot be used. The mutex may be created again
|
||||
using the function \ref osMutexNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the mutex object has been deleted.
|
||||
- \em osErrorParameter: parameter \em mutex_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the mutex is in an invalid state.
|
||||
- \em osErrorISR: \b osMutexDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified mutex.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osMutexId_t mutex_id; // Mutex id populated by the function osMutexNew()
|
||||
|
||||
void DeleteMutex (osMutexId_t mutex_id) {
|
||||
osStatus_t status;
|
||||
|
||||
if (mutex_id != NULL) {
|
||||
status = osMutexDelete(mutex_id);
|
||||
if (status != osOK) {
|
||||
// handle failure code
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osMutexAttr_t::attr_bits
|
||||
\details
|
||||
The following bit masks can be used to set options:
|
||||
- \ref osMutexRecursive : a thread can consume the mutex multiple times without locking itself.
|
||||
- \ref osMutexPrioInherit : the owner thread inherits the priority of a (higher priority) waiting thread.
|
||||
- \ref osMutexRobust : the mutex is automatically released when owner thread is terminated.
|
||||
|
||||
Use logical \em 'OR' operation to select multiple options, for example:
|
||||
\code
|
||||
osMutexRecursive | osMutexPrioInherit;
|
||||
\endcode
|
||||
|
||||
Default: \token{0} which specifies:
|
||||
- <i>non recursive mutex</i>: a thread cannot consume the mutex multiple times.
|
||||
- <i>non priority raising</i>: the priority of an owning thread is not changed.
|
||||
- <i>mutex is not automatically release</i>: the mutex object must be always is automatically released when owner thread is terminated.
|
||||
|
||||
*/
|
||||
/**
|
||||
\var osMutexAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory for the mutex control block object. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the mutex control block.
|
||||
*/
|
||||
/**
|
||||
\var osMutexAttr_t::cb_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref cb_mem. For RTX, the minimum value is defined with \ref osRtxMutexCbSize (higher values are permitted).
|
||||
|
||||
Default: \token{0} as the default is no memory provided with \ref cb_mem.
|
||||
*/
|
||||
/**
|
||||
\var osMutexAttr_t::name
|
||||
\details
|
||||
Pointer to a constant string with a human readable name (displayed during debugging) of the mutex object.
|
||||
|
||||
Default: \token{NULL} no name specified.
|
||||
*/
|
297
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_ProcessIsolation.txt
vendored
Normal file
@ -0,0 +1,297 @@
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_ProcessIsolation Process Isolation
|
||||
\ingroup CMSIS_RTOS CMSIS_RTOSv2
|
||||
@{
|
||||
|
||||
This chapter explains mechanisms available for process isolation support in CMSIS-RTOS2 API.
|
||||
\if FuSaRTS
|
||||
See \ref fusa_process_isolation for a summary of other related pages such as RTX configuration and safety user requirements.
|
||||
\endif
|
||||
|
||||
CMSIS-RTOS2 API defines a set of features to protect critical parts of an application against software flaws that may exist in other parts of an application.
|
||||
|
||||
\par
|
||||
- <b>\ref rtos_process_isolation_mpu</b> for memory access protection in the system.
|
||||
<br>
|
||||
RTOS threads can access only memory regions and peripherals based on their MPU Protected Zone assignment. Non-privileged thread code cannot accidentally modify critical RTOS kernel data or memory belonging to other zones.
|
||||
|
||||
\par
|
||||
- <b>\ref rtos_process_isolation_safety_class</b> for access protection to RTOS objects.
|
||||
<br>
|
||||
The RTOS objects with a higher safety class assigned to them cannot be modified via RTOS API functions from threads that have lower safety class assigned.
|
||||
|
||||
\par
|
||||
- <b>\ref rtos_process_isolation_thread_wdt</b> to verify execution times of threads.
|
||||
<br>
|
||||
Each thread can maintain own thread watchdog and in case of timing violations, corresponding thread watchdog alarm will be triggered.
|
||||
|
||||
\par
|
||||
- <b>\ref rtos_process_isolation_faults</b> in case of a detected failure (for example thread watchdog alarm or MPU Fault).
|
||||
<br>
|
||||
The RTOS provides functions to block execution of malfunctioning components and with that dedicate system resources for operation of the safety critical threads.
|
||||
|
||||
\if FuSaRTS
|
||||
Section \ref fusa_process_isolation lists safety requirements for Process Isolation functions.
|
||||
\endif
|
||||
|
||||
\addtogroup rtos_process_isolation_mpu MPU Protected Zones
|
||||
\details
|
||||
Memory Protection Unit (MPU) is available on many Cortex-M devices and allows restricted access to memory regions and peripherals. <a href="../../Core/html/index.html#ref_man_sec"><b>The Cortex-M Reference Manuals</b></a> provide detailed information about the MPU.
|
||||
|
||||
An MPU Protected Zone is a set of multiple memory regions and peripherals with specified access rights. One or more RTOS threads can be assigned to an MPU Protected Zone.
|
||||
|
||||
The figure below illustrates the concept for MPU Protected Zones that isolate various threads.
|
||||
|
||||
\image html rtos_mpu.png "Process isolation with MPU in RTX RTOS"
|
||||
|
||||
Sections below explains how to use MPU Protected Zones.
|
||||
- \ref rtos_process_isolation_mpu_refs
|
||||
- \ref rtos_process_isolation_mpu_def
|
||||
- \ref rtos_process_isolation_mpu_load
|
||||
- \ref rtos_process_isolation_mpu_objects
|
||||
- \ref rtos_process_isolation_mpu_fault
|
||||
|
||||
\section rtos_process_isolation_mpu_refs Function references
|
||||
|
||||
Summary of functions that implement MPU Protected Zone functionality:
|
||||
|
||||
- \ref osThreadNew : \copybrief osThreadNew
|
||||
- \ref osThreadZone : \copybrief osThreadZone
|
||||
- \ref osThreadGetZone : \copybrief osThreadGetZone
|
||||
- \ref osThreadTerminateZone : \copybrief osThreadTerminateZone
|
||||
- \ref osZoneSetup_Callback : \copybrief osZoneSetup_Callback
|
||||
|
||||
\section rtos_process_isolation_mpu_def Define MPU Protected Zones
|
||||
|
||||
In the architectural design phase an application is logically split into functionalities with the same integrity level (same safety requirements). They can safely operate within the same MPU Protected Zone and hence access same memory areas and peripherals.
|
||||
|
||||
MPU protected zones are defined in an MPU table where each row describes an individual MPU zone and each cell in the row specifies an MPU region within that zone. For details see section <a href="../../Core/html/group__mpu__functions.html"><b>MPU Functions</b></a> in CMSIS-Core(M) documentation.
|
||||
|
||||
<a href="https://arm-software.github.io/CMSIS_5/Zone/html/index.html" target="_blank"><b>CMSIS-Zone</b></a> provides a utility that allows graphic configuration of MPU protected zones and generates MPU table in the CMSIS format.
|
||||
|
||||
\note
|
||||
Interrupt handlers bypass the MPU protection. For this reason, it is required that all interrupt handlers are verified according to the highest integrity level to exclude unintended memory accesses.
|
||||
|
||||
\subsection rtx_process_isolation_mpu_id Zone Identifiers
|
||||
Zone ID is used to refer to a specific MPU protected zone. Zone ID value equals to the row index (starting from 0) in the MPU table that describes corresponding MPU Protected Zone.
|
||||
An MPU Protected Zone is assigned to one or more RTOS threads. This is done by providing the Zone ID value in thread attributes \ref osThreadAttr_t when creating the thread with the \ref osThreadNew function.
|
||||
|
||||
\b Example:
|
||||
|
||||
\code
|
||||
/* ThreadA thread attributes */
|
||||
const osThreadAttr_t thread_A_attr = {
|
||||
.name = "ThreadA", // human readable thread name
|
||||
.attr_bits = osThreadZone(3U) // assign thread to MPU protected zone 3
|
||||
};
|
||||
osThreadNew(ThreadA, NULL, &thread_A_attr);
|
||||
\endcode
|
||||
|
||||
\section rtos_process_isolation_mpu_load Load MPU Protected Zone
|
||||
|
||||
When switching threads the RTOS kernel compares Zone IDs of the currently running thread and the next thread to be executed. If the Zone Ids are different then a callback function \ref osZoneSetup_Callback is called. This function shall be implemented in the user application code to actually switch to the new MPU Protected Zone. In the function the user should load the MPU Protected Zone according to the Zone Id provided in the argument.
|
||||
|
||||
\b Example:
|
||||
\code
|
||||
/* Update MPU settings for newly activating Zone */
|
||||
void osZoneSetup_Callback (uint32_t zone) {
|
||||
|
||||
if (zone >= ZONES_NUM) {
|
||||
// Here issue an error for incorrect zone value
|
||||
}
|
||||
|
||||
ARM_MPU_Load(mpu_table[zone], MPU_REGIONS);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\section rtos_process_isolation_mpu_objects RTOS Objects and MPU Protection
|
||||
To access RTOS objects from the application RTOS APIs rely on a numeric xxx_id parameter associated with the object as explained in \ref rtos_api2. For example
|
||||
|
||||
\code
|
||||
osEventFlagsId_t evt_flags;
|
||||
evt_flags = osEventFlagsNew(NULL);
|
||||
osEventFlagsSet(evt_flags, 1);
|
||||
\endcode
|
||||
|
||||
The allocation of an RTOS object to the memory in a specific MPU Protected Zone does not provide access restriction. The access restriction can be bypassed if another thread calls the CMSIS-RTOS2 API with the object ID of the RTOS object as argument. The CMSIS-RTOS2 function is executed in handler mode and therefore can access and modify the RTOS object without raising a Memory Fault.
|
||||
To enable access control for RTOS objects the \ref rtos_process_isolation_safety_class concept is introduced in CMSIS-RTOS2.
|
||||
|
||||
\section rtos_process_isolation_mpu_fault Handle Memory Access Faults
|
||||
|
||||
A memory access fault is triggered when a thread tries to access memory or peripherals outside of the MPU Protected Zone loaded while the thread is running. In such case Memory Management Interrupt (<a href="../../Core/html/group__NVIC__gr.html "><b>MemoryManagement_IRQn</b></a>) is triggered by the processor and its handling function is executed according to the exception vector table specified in the device startup file (by default \token{MemManage_Handler(void)} ).
|
||||
|
||||
The \e MemManage_Handler() interrupt handler is application specific and needs to be implemented by the user. In the handler it is possible to identify the thread that caused the memory access fault, the corresponding zone id and the safety class. This information can be used to define actions for entering a safe state. \ref rtos_process_isolation_faults provides more details on the available system recovery possibilities.
|
||||
|
||||
\addtogroup rtos_process_isolation_safety_class Safety Classes
|
||||
|
||||
\ref rtos_process_isolation_mpu_objects explains that MPU Protected Zones do not provide full access protection to RTOS objects accessed via CMSIS-RTOS2 API. The concept of a safety class fills this gap.
|
||||
|
||||
Every RTOS object, including thread is assigned with a numeric safety class value. A thread cannot modify an RTOS object if its safety class value is higher than the safety class value of the thread.
|
||||
For example, it is not possible to change the priority or suspend a thread that has a higher safety class value than the thread that is currently executed.
|
||||
|
||||
\section rtos_process_isolation_safety_class_refs Function references
|
||||
|
||||
Summary of functions and macros that implement safety classes:
|
||||
|
||||
- \ref osSafetyClass : \copybrief osSafetyClass
|
||||
- \ref osThreadGetClass : \copybrief osThreadGetClass
|
||||
- \ref osSafetyWithSameClass : \copybrief osSafetyWithSameClass
|
||||
- \ref osSafetyWithLowerClass : \copybrief osSafetyWithLowerClass
|
||||
- \ref osKernelProtect : \copybrief osKernelProtect
|
||||
- \ref osThreadSuspendClass : \copybrief osThreadSuspendClass
|
||||
- \ref osThreadResumeClass : \copybrief osThreadResumeClass
|
||||
- \ref osKernelDestroyClass : \copybrief osKernelDestroyClass
|
||||
|
||||
\ref rtos_process_isolation_safety_class_assign lists CMSIS-RTOS2 API functions that support safety class assignment when creating RTOS objects.
|
||||
\ref rtos_process_isolation_safety_class_error lists CMSIS-RTOS2 API functions that verify safety class assignment before execution.
|
||||
\section rtos_process_isolation_safety_class_assign Assign Safety Class to an RTOS Object
|
||||
|
||||
It is possible to create any objects regardless of the safety class after the kernel initialize with \ref osKernelInitialize, but before the kernel is started with \ref osKernelStart. This allows to setup a system before actually starting the RTOS kernel.
|
||||
|
||||
Threads of a higher safety class can create RTOS objects that belong to a lower or same safety class. For the object types listed below, the \e attr_bits can have an optional safety class value that is assigned when the RTOS object is created with the \e <i>os<Object>New</i> function. The macro \ref osSafetyClass encodes the value for the \e attr_bits field in the attr struct. For example:
|
||||
|
||||
\code
|
||||
const osEventFlagsAttr_t evt_flags_attr = {
|
||||
.attr_bits = osSafetyClass(SAFETY_CLASS_SAFE_MODE_OPERATION)
|
||||
};
|
||||
osEventFlagsId_t evt_flags;
|
||||
evt_flags = osEventFlagsNew(&evt_flags_attr);
|
||||
\endcode
|
||||
|
||||
The following object types support safety class assignment when creating an object with corresponding \e os<Object>New function:
|
||||
|
||||
- \ref osThreadAttr_t \copybrief osThreadAttr_t Used in the \ref osThreadNew function.
|
||||
- \ref osEventFlagsAttr_t \copybrief osEventFlagsAttr_t Used in the \ref osThreadNew function.
|
||||
- \ref osTimerAttr_t \copybrief osTimerAttr_t Used in the \ref osTimerNew function.
|
||||
- \ref osMutexAttr_t \copybrief osMutexAttr_t Used in the \ref osMutexNew function.
|
||||
- \ref osSemaphoreAttr_t \copybrief osSemaphoreAttr_t Used in the \ref osSemaphoreNew function.
|
||||
- \ref osMemoryPoolAttr_t \copybrief osMemoryPoolAttr_t Used in the \ref osMemoryPoolNew function.
|
||||
- \ref osMessageQueueAttr_t \copybrief osMessageQueueAttr_t Used in the \ref osMessageQueueNew function.
|
||||
|
||||
If safety class is not provided when creating the RTOS object then it inherits the safety class of the current running thread that creates the object. If the object is created before kernel is started and no safety class is provided, then it receives default safety class 0. This simplifies integration of third-party code that can be classified as non-safety critical.
|
||||
|
||||
\section rtos_process_isolation_safety_class_error Handle Object Access Violation
|
||||
|
||||
RTOS API call returns error code \ref osErrorSafetyClass if the requested object manipulation cannot be performed because the target object has higher safety class than the safety class of the running thread. For example:
|
||||
\code
|
||||
status = osEventFlagsSet(evt_flags, 1);
|
||||
if (status == osErrorSafetyClass)
|
||||
{
|
||||
//handle the safety class error
|
||||
}
|
||||
\endcode
|
||||
|
||||
Following functions compare the safety class of the running thread with the safety class of the target object.
|
||||
|
||||
In \ref CMSIS_RTOS_KernelCtrl functions:
|
||||
|
||||
Comparison is done with safety class configured with \ref osKernelProtect
|
||||
- \ref osKernelLock
|
||||
- \ref osKernelRestoreLock
|
||||
- \ref osKernelSuspend
|
||||
- \ref osKernelProtect
|
||||
- \ref osKernelDestroyClass
|
||||
|
||||
In \ref CMSIS_RTOS_ThreadMgmt functions:
|
||||
- \ref osThreadNew
|
||||
- \ref osThreadSetPriority
|
||||
- \ref osThreadSuspend
|
||||
- \ref osThreadResume
|
||||
- \ref osThreadDetach
|
||||
- \ref osThreadJoin
|
||||
- \ref osThreadTerminate
|
||||
- \ref osThreadSuspendClass
|
||||
- \ref osThreadResumeClass
|
||||
|
||||
In \ref CMSIS_RTOS_ThreadFlagsMgmt functions:
|
||||
- \ref osThreadFlagsSet
|
||||
|
||||
In \ref CMSIS_RTOS_EventFlags functions:
|
||||
- \ref osEventFlagsNew
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
- \ref osEventFlagsDelete
|
||||
|
||||
In \ref CMSIS_RTOS_TimerMgmt functions:
|
||||
- \ref osTimerNew
|
||||
- \ref osTimerStart
|
||||
- \ref osTimerStop
|
||||
- \ref osTimerDelete
|
||||
|
||||
In \ref CMSIS_RTOS_MutexMgmt functions:
|
||||
- \ref osMutexNew
|
||||
- \ref osMutexAcquire
|
||||
- \ref osMutexDelete
|
||||
|
||||
In \ref CMSIS_RTOS_SemaphoreMgmt functions:
|
||||
- \ref osSemaphoreNew
|
||||
- \ref osSemaphoreAcquire
|
||||
- \ref osSemaphoreRelease
|
||||
- \ref osSemaphoreDelete
|
||||
|
||||
In \ref CMSIS_RTOS_PoolMgmt functions:
|
||||
- \ref osMemoryPoolNew
|
||||
- \ref osMemoryPoolAlloc
|
||||
- \ref osMemoryPoolFree
|
||||
- \ref osMemoryPoolDelete
|
||||
|
||||
In \ref CMSIS_RTOS_Message functions:
|
||||
- \ref osMessageQueueNew
|
||||
- \ref osMessageQueuePut
|
||||
- \ref osMessageQueueGet
|
||||
- \ref osMessageQueueReset
|
||||
- \ref osMessageQueueDelete
|
||||
|
||||
\addtogroup rtos_process_isolation_thread_wdt Thread Watchdogs
|
||||
|
||||
CMSIS-RTOS defines <b>Thread Watchdogs</b> that allow to control timing constraints for thread execution (<a href="https://en.wikipedia.org/wiki/Temporal_isolation" target="_blank"><b>temporal isolation</b></a>).
|
||||
|
||||
Each thread has an independent watchdog timer that is started with the function \ref osThreadFeedWatchdog(uint32_t ticks). The \token{ticks} value specifies the timeout before it expires. Within this time interval the function \ref osThreadFeedWatchdog must be called again within the thread to restart the watchdog timer.
|
||||
|
||||
If the thread watchdog is not restarted during the specified amount of ticks the Watchdog Alarm callback \ref osWatchdogAlarm_Handler(osThreadId_t thread_id) is triggered and can be used to recover the system or proceed to the system shutdown.
|
||||
|
||||
Figure below explains the concept with an example:
|
||||
|
||||
\image html thread_watchdogs.png "Example use of Thread Watchdogs"
|
||||
|
||||
\ref rtos_process_isolation_faults provides more details on the available possibilities for system recovery.
|
||||
\note If the application suspends a thread from scheduling by calling \ref osThreadSuspend or \ref osThreadSuspendClass, the thread watchdog still continues to run, and it is expected to expire and trigger \ref osWatchdogAlarm_Handler because the thread will not be serviced as expected.
|
||||
\note Hence it may be necessary to differentiate handling of thread watchdogs that expired unexpectedly from the thread watchdog alarms of intentionally suspended threads.
|
||||
|
||||
\section rtos_process_isolation_thread_wdt_refs Function references
|
||||
|
||||
Summary of functions that implement thread watchdog functionality
|
||||
|
||||
- \ref osThreadFeedWatchdog : \copybrief osThreadFeedWatchdog
|
||||
- \ref osWatchdogAlarm_Handler : \copybrief osWatchdogAlarm_Handler
|
||||
|
||||
\addtogroup rtos_process_isolation_faults Fault Handling
|
||||
|
||||
When a failure, or an error is detected in a system (for example \ref rtos_process_isolation_mpu_fault "memory access fault", \ref rtos_process_isolation_thread_wdt "thread watchdog alarm", or others) CMSIS-RTOS2 API allows to stop further execution of selected RTOS threads. This can be used to block malfunctioning components or free computing resources and so enable execution of the safety critical threads.
|
||||
|
||||
Following approaches are available:
|
||||
- function \ref osThreadTerminateZone can be called in case of a fault exception. It will terminate all threads from the specified MPU Protected Zone (for example, can be the zone that has caused the fault). The function cannot be called in thread context or interrupts other than faults. Note that \ref osFaultResume can be called at the end of the handling code to return program execution into a known context and let kernel schedule the next thread ready for execution.
|
||||
- function \ref osThreadSuspendClass can be called in case of a thread watchdog alarm or other errors handled in thread context. It allows to suspend operation of threads based on the safety class assignment. Function \ref osThreadResumeClass can be used to resume operation of threads based on their safety class. \ref rtos_process_isolation_thread_wdt contains an example that demonstrates fault handling concept for thread watchdogs.
|
||||
|
||||
Function \ref osKernelDestroyClass fully removes RTOS objects of specific safety classes from the system. This can be useful to do before restarting operation of terminated or suspended threads.
|
||||
|
||||
\section rtos_process_isolation_faults_refs Function references
|
||||
|
||||
Following CMSIS-RTOS2 functions and macros support fault handling:
|
||||
|
||||
- \ref osThreadGetZone : \copybrief osThreadGetZone
|
||||
- \ref osThreadTerminateZone : \copybrief osThreadTerminateZone
|
||||
- \ref osThreadGetClass : \copybrief osThreadGetClass
|
||||
- \ref osSafetyWithSameClass : \copybrief osSafetyWithSameClass
|
||||
- \ref osSafetyWithLowerClass : \copybrief osSafetyWithLowerClass
|
||||
- \ref osThreadSuspendClass : \copybrief osThreadSuspendClass
|
||||
- \ref osThreadResumeClass : \copybrief osThreadResumeClass
|
||||
- \ref osKernelDestroyClass : \copybrief osKernelDestroyClass
|
||||
- \ref osFaultResume : \copybrief osFaultResume
|
||||
- \ref osWatchdogAlarm_Handler : \copybrief osFaultResume
|
||||
|
||||
// @}
|
||||
|
||||
*/
|
||||
// end
|
296
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Sema.txt
vendored
Normal file
@ -0,0 +1,296 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Semaphore Management ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_SemaphoreMgmt Semaphores
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Access shared resources simultaneously from different threads.
|
||||
\details
|
||||
Semaphores are used to manage and protect access to shared resources. Semaphores are very similar to
|
||||
\ref CMSIS_RTOS_MutexMgmt "Mutexes". Whereas a Mutex permits just one thread to access a shared resource at a
|
||||
time, a semaphore can be used to permit a fixed number of threads/ISRs to access a pool of shared resources. Using
|
||||
semaphores, access to a group of identical peripherals can be managed (for example multiple DMA channels).
|
||||
|
||||
\image html "Semaphore.png" "CMSIS-RTOS Semaphore"
|
||||
|
||||
A semaphore object should be initialized to the maximum number of available tokens. This number of available resources is
|
||||
specified as parameter of the \ref osSemaphoreNew function. Each time a semaphore token is obtained with \ref osSemaphoreAcquire
|
||||
(in \em available state), the semaphore count is decremented. When the semaphore count is 0 (i.e. \em depleted state), no
|
||||
more semaphore tokens can be obtained. The thread/ISR that tries to obtain the semaphore token needs to wait until the next
|
||||
token is free. Semaphores are released with \ref osSemaphoreRelease incrementing the semaphore count.
|
||||
|
||||
\image html "semaphore_states.png" "CMSIS-RTOS Semaphore States"
|
||||
|
||||
\note The functions \ref osSemaphoreAcquire, \ref osSemaphoreGetCount, and \ref osSemaphoreRelease can be called from
|
||||
\ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
\note Refer to \ref semaphoreConfig for RTX5 configuration options.
|
||||
|
||||
Semaphore Use Cases
|
||||
-------------------
|
||||
Due to their flexibility, semaphores cover a wide range of synchronizing applications. At the same time, they are perhaps the
|
||||
most challenging RTOS object to understand. The following explains a use case for semaphores, taken from the book
|
||||
<a href="http://www.greenteapress.com/semaphores/" target="_blank">The Little Book Of Semaphores</a> by Allen B. Downey which
|
||||
is available for free download.
|
||||
|
||||
<b>Non-binary Semaphore (Multiplex)</b>
|
||||
|
||||
A multiplex limits the number of threads that can access a critical section of code. For example, this could be a function
|
||||
accessing DMA resources which can only support a limited number of calls.
|
||||
|
||||
To allow multiple threads to run the function, initialize a semaphore to the maximum number of threads that can be allowed.
|
||||
The number of tokens in the semaphore represents the number of additional threads that may enter. If this number is zero,
|
||||
then the next thread trying to access the function will have to wait until one of the other threads exits and releases its
|
||||
token. When all threads have exited the token number is back to n. The following example shows the code for one of the
|
||||
threads that might access the resource:
|
||||
|
||||
\code
|
||||
osSemaphoreId_t multiplex_id;
|
||||
|
||||
void thread_n (void) {
|
||||
|
||||
multiplex_id = osSemaphoreNew(3U, 3U, NULL);
|
||||
while(1) {
|
||||
osSemaphoreAcquire(multiplex_id, osWaitForever);
|
||||
// do something
|
||||
osSemaphoreRelease(multiplex_id);
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
<b>Producer/Consumer Semaphore</b>
|
||||
|
||||
The producer-consumer problem can be solved using two semaphores.
|
||||
|
||||
A first semaphore (\token{empty_id}) counts down the available (empty) buffers, i.e.
|
||||
the producer thread can wait for available buffer slots by acquiring from this one.
|
||||
|
||||
A second semaphore (\token{filled_id}) counts up the used (filled) buffers, i.e.
|
||||
the consumer thread can wait for available data by acquiring from this one.
|
||||
|
||||
It is crucial for the correct behaviour that the threads acquire and release on both
|
||||
semaphores in the given sequence. According to this example one can have multiple
|
||||
producer and/or consumer threads running concurrently.
|
||||
|
||||
\code
|
||||
#define BUFFER_SIZE 10U
|
||||
|
||||
osSemaphoreId_t empty_id = osSemaphoreNew(BUFFER_SIZE, BUFFER_SIZE, NULL);
|
||||
osSemaphoreId_t filled_id = osSemaphoreNew(BUFFER_SIZE, 0U, NULL);
|
||||
|
||||
void producer_thread (void) {
|
||||
while(1) {
|
||||
osSemaphoreAcquire(empty_id, osWaitForever);
|
||||
// produce data
|
||||
osSemaphoreRelease(filled_id);
|
||||
}
|
||||
}
|
||||
|
||||
void consumer_thread (void) {
|
||||
|
||||
while(1){
|
||||
osSemaphoreAcquire(filled_id, osWaitForever);
|
||||
// consume data
|
||||
osSemaphoreRelease(empty_id);
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osSemaphoreId_t
|
||||
\details
|
||||
Returned by:
|
||||
- \ref osSemaphoreNew
|
||||
*/
|
||||
|
||||
/**
|
||||
\struct osSemaphoreAttr_t
|
||||
\details
|
||||
Specifies the following attributes for the \ref osSemaphoreNew function.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
|
||||
\details
|
||||
The function \b osSemaphoreNew creates and initializes a semaphore object that is used to manage access to shared resources
|
||||
and returns the pointer to the semaphore object identifier or \token{NULL} in case of an error. It can be safely called
|
||||
before the RTOS is started (call to \ref osKernelStart), but not before it is initialized (call to \ref osKernelInitialize).
|
||||
|
||||
The parameter \em max_count specifies the maximum number of available tokens. A \em max_count value of 1 creates a binary
|
||||
semaphore.
|
||||
|
||||
The parameter \em initial_count sets the initial number of available tokens.
|
||||
|
||||
The parameter \em attr specifies additional semaphore attributes. Default attributes will be used if set to \token{NULL}.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h" // CMSIS RTOS header file
|
||||
|
||||
osSemaphoreId_t sid_Semaphore; // semaphore id
|
||||
|
||||
osThreadId_t tid_Thread_Semaphore; // thread id
|
||||
|
||||
void Thread_Semaphore (void *argument); // thread function
|
||||
|
||||
int Init_Semaphore (void) {
|
||||
|
||||
sid_Semaphore = osSemaphoreNew(2U, 2U, NULL);
|
||||
if (sid_Semaphore == NULL) {
|
||||
; // Semaphore object not created, handle failure
|
||||
}
|
||||
|
||||
tid_Thread_Semaphore = osThreadNew(Thread_Semaphore, NULL, NULL);
|
||||
if (tid_Thread_Semaphore == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void Thread_Semaphore (void *argument) {
|
||||
osStatus_t val;
|
||||
|
||||
while (1) {
|
||||
; // Insert thread code here...
|
||||
|
||||
val = osSemaphoreAcquire(sid_Semaphore, 10U); // wait for max. 10 ticks for semaphore token to get available
|
||||
switch (val) {
|
||||
case osOK:
|
||||
; // Use protected code here...
|
||||
osSemaphoreRelease(sid_Semaphore); // return a token back to a semaphore
|
||||
break;
|
||||
case osErrorResource:
|
||||
break;
|
||||
case osErrorParameter:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
osThreadYield(); // suspend thread
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id)
|
||||
\details
|
||||
The function \b osSemaphoreGetName returns the pointer to the name string of the semaphore identified by parameter \a
|
||||
semaphore_id or \token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout)
|
||||
\details
|
||||
The blocking function \b osSemaphoreAcquire waits until a token of the semaphore object specified by parameter
|
||||
\a semaphore_id becomes available. If a token is available, the function instantly returns and decrements the token count.
|
||||
|
||||
The parameter \a timeout specifies how long the system waits to acquire the token. While the system waits, the thread
|
||||
that is calling this function is put into the \ref ThreadStates "BLOCKED" state. The parameter \ref CMSIS_RTOS_TimeOutValue
|
||||
"timeout" can have the following values:
|
||||
- when \a timeout is \token{0}, the function returns instantly (i.e. try semantics).
|
||||
- when \a timeout is set to \b osWaitForever the function will wait for an infinite time until the semaphore becomes
|
||||
available (i.e. wait semantics).
|
||||
- all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the token has been obtained and the token count decremented.
|
||||
- \em osErrorTimeout: the token could not be obtained in the given time.
|
||||
- \em osErrorResource: the token could not be obtained when no \a timeout was specified.
|
||||
- \em osErrorParameter: the parameter \a semaphore_id is \token{NULL} or invalid.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified semaphore.
|
||||
|
||||
\note May be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" if the parameter \a timeout is set to
|
||||
\token{0}.
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
Refer to \ref osSemaphoreNew.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id)
|
||||
\details
|
||||
The function \b osSemaphoreRelease releases a token of the semaphore object specified by parameter \a semaphore_id. Tokens
|
||||
can only be released up to the maximum count specified at creation time, see \ref osSemaphoreNew. Other threads that
|
||||
currently wait for a token of this semaphore object will be put into the \ref ThreadStates "READY" state.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the token has been released and the count incremented.
|
||||
- \em osErrorResource: the token could not be released (maximum token count has been reached).
|
||||
- \em osErrorParameter: the parameter \a semaphore_id is \token{NULL} or invalid.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified semaphore.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
|
||||
Refer to \ref osSemaphoreNew.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id)
|
||||
\details
|
||||
The function \b osSemaphoreGetCount returns the number of available tokens of the semaphore object specified by parameter
|
||||
\a semaphore_id. In case of an error it returns \token{0}.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id)
|
||||
\details
|
||||
The function \b osSemaphoreDelete deletes a semaphore object specified by parameter \a semaphore_id. It releases internal
|
||||
memory obtained for semaphore handling. After this call, the \a semaphore_id is no longer valid and cannot be used. The
|
||||
semaphore may be created again using the function \ref osSemaphoreNew.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the semaphore object has been deleted.
|
||||
- \em osErrorParameter: the parameter \a semaphore_id is \token{NULL} or invalid.
|
||||
- \em osErrorResource: the semaphore is in an invalid state.
|
||||
- \em osErrorISR: \b osSemaphoreDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified semaphore.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osSemaphoreAttr_t::attr_bits
|
||||
\details
|
||||
Reserved for future use (must be set to '0' for future compatibility).
|
||||
|
||||
\var osSemaphoreAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory for the semaphore control block object. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the semaphore control block.
|
||||
|
||||
\var osSemaphoreAttr_t::cb_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref cb_mem. For RTX, the minimum value is defined with \ref osRtxSemaphoreCbSize (higher values are permitted).
|
||||
|
||||
Default: \token{0} as the default is no memory provided with \ref cb_mem.
|
||||
|
||||
\var osSemaphoreAttr_t::name
|
||||
\details
|
||||
Pointer to a constant string with a human readable name (displayed during debugging) of the semaphore object.
|
||||
|
||||
Default: \token{NULL} no name specified.
|
||||
*/
|
166
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Status.txt
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Definitions ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_Definitions Definitions
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Constants and enumerations used by many CMSIS-RTOS functions.
|
||||
\details The following constants and enumerations are used by many CMSIS-RTOS function calls.
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osStatus_t
|
||||
\details
|
||||
The \b osStatus_t enumeration defines the event status and error codes that are returned by many CMSIS-RTOS functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
\def osWaitForever
|
||||
\details A special \ref CMSIS_RTOS_TimeOutValue that informs the RTOS to wait infinite until a resource becomes available.
|
||||
It applies to the following functions:
|
||||
- \ref osDelay : \copybrief osDelay
|
||||
- \ref osThreadFlagsWait : \copybrief osThreadFlagsWait
|
||||
- \ref osEventFlagsWait : \copybrief osEventFlagsWait
|
||||
- \ref osMutexAcquire : \copybrief osMutexAcquire
|
||||
- \ref osSemaphoreAcquire : \copybrief osSemaphoreAcquire
|
||||
- \ref osMemoryPoolAlloc : \copybrief osMemoryPoolAlloc
|
||||
- \ref osMessageQueuePut : \copybrief osMessageQueuePut
|
||||
- \ref osMessageQueueGet : \copybrief osMessageQueueGet
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsWaitAny
|
||||
|
||||
Reference:
|
||||
- \ref osEventFlagsWait
|
||||
- \ref osThreadFlagsWait
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsWaitAll
|
||||
|
||||
Reference:
|
||||
- \ref osEventFlagsWait
|
||||
- \ref osThreadFlagsWait
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsNoClear
|
||||
|
||||
Reference:
|
||||
- \ref osEventFlagsWait
|
||||
- \ref osThreadFlagsWait
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osSafetyClass(n)
|
||||
\param n safety class value.
|
||||
\brief Safety class value in attribute bit field format.
|
||||
\details
|
||||
|
||||
The preprocessor macro \b osSafetyClass constructs attribute bitmask with safety class bits set to \a n.
|
||||
|
||||
<b>Code Example:</b>
|
||||
\code
|
||||
/* Event Flags object attributes */
|
||||
const osEventFlagsAttr_t ef_attr = {
|
||||
.name = "EventFlags1", // human readable object name
|
||||
.attr_bits = osSafetyClass(2U) // assign object to safety class 2
|
||||
};
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osSafetyWithSameClass
|
||||
\details
|
||||
Definition for RTOS objects with the same safety class. Can be used as mode argument in the following functions:
|
||||
- \ref osThreadSuspendClass : \copybrief osThreadSuspendClass
|
||||
- \ref osThreadResumeClass : \copybrief osThreadResumeClass
|
||||
- \ref osKernelDestroyClass : \copybrief osKernelDestroyClass
|
||||
|
||||
\def osSafetyWithLowerClass
|
||||
\details
|
||||
Definition for RTOS objects with lower safety class. Can be used as mode argument in the following functions:
|
||||
- \ref osThreadSuspendClass : \copybrief osThreadSuspendClass
|
||||
- \ref osThreadResumeClass : \copybrief osThreadResumeClass
|
||||
- \ref osKernelDestroyClass : \copybrief osKernelDestroyClass
|
||||
*/
|
||||
|
||||
/// @}
|
||||
/**
|
||||
\addtogroup flags_error_codes Flags Functions Error Codes
|
||||
\ingroup CMSIS_RTOS_Definitions
|
||||
\brief Constants used by \ref CMSIS_RTOS_ThreadFlagsMgmt and \ref CMSIS_RTOS_EventFlags to return error codes.
|
||||
\details In case of an error, flags functions (\ref CMSIS_RTOS_ThreadFlagsMgmt and
|
||||
\ref CMSIS_RTOS_EventFlags) return error codes. To indicate that an error has occurred, the highest bit of
|
||||
the return value is be set. You can check the exact error using the codes shown below.
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsErrorUnknown
|
||||
\details Generic error. It is returned when no other error can be applied.
|
||||
|
||||
Reference:
|
||||
- \ref osThreadFlagsSet
|
||||
- \ref osThreadFlagsClear
|
||||
- \ref osThreadFlagsWait
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsErrorTimeout
|
||||
\details This error is returned if a timeout was specified and the specified flags were not set, when the
|
||||
timeout occurred.
|
||||
|
||||
Reference:
|
||||
- \ref osThreadFlagsSet
|
||||
- \ref osThreadFlagsClear
|
||||
- \ref osThreadFlagsWait
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsErrorResource
|
||||
\details This error is returned when you try to get a flag that was not set \a and timeout 0 was
|
||||
specified. Is also returned when the specified object identifier is corrupt or invalid.
|
||||
|
||||
Reference:
|
||||
- \ref osThreadFlagsSet
|
||||
- \ref osThreadFlagsClear
|
||||
- \ref osThreadFlagsWait
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsErrorParameter
|
||||
\details This error is returned when a given parameter is wrong.
|
||||
|
||||
Reference:
|
||||
- \ref osThreadFlagsSet
|
||||
- \ref osThreadFlagsClear
|
||||
- \ref osThreadFlagsWait
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \def osFlagsErrorISR
|
||||
\details This error is returned when a non-ISR-callable function was called from an ISR.
|
||||
|
||||
Reference:
|
||||
- \ref osThreadFlagsSet
|
||||
- \ref osThreadFlagsClear
|
||||
- \ref osThreadFlagsWait
|
||||
- \ref osEventFlagsSet
|
||||
- \ref osEventFlagsClear
|
||||
- \ref osEventFlagsWait
|
||||
*/
|
||||
|
||||
/// @}
|
1019
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Thread.txt
vendored
Normal file
207
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_ThreadFlags.txt
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Thread Flags Management ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_ThreadFlagsMgmt Thread Flags
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Synchronize threads using flags.
|
||||
\details
|
||||
Thread Flags are a more specialized version of the Event Flags. See \ref CMSIS_RTOS_EventFlags.
|
||||
While Event Flags can be used to globally signal a number of threads, thread flags are only send to a single specific thread.
|
||||
Every thread instance can receive thread flags without any additional allocation of a thread flags object.
|
||||
|
||||
\note Thread flag management functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines", except
|
||||
for \ref osThreadFlagsSet.
|
||||
|
||||
<b>Usage Example</b>
|
||||
|
||||
The following (incomplete) code excerpt sketches the usage principals for <b>Thread Flags</b>.
|
||||
|
||||
The behavior is the following:
|
||||
- app_main starts executing
|
||||
- statement A sets thread flags to 0x02 (flags = 0x02 – after set)
|
||||
- app_main enters delay
|
||||
- execution switches to threadX
|
||||
- statement B waits for flag 0x01 and blocks since flag is not set
|
||||
- execution switches to app_main
|
||||
- statement C sets thread flags to 0x07
|
||||
- threadX wakes-up and clears flag 0x01, thread flags = 0x06, return value set to 0x07 (before clear), note: all this happens during statement C
|
||||
- statement C returns with flags = 0x06
|
||||
- app_main enters delay
|
||||
- execution switches to threadX
|
||||
- statement B returns with flagsX = 0x07
|
||||
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
osThreadId_t tid;
|
||||
uint32_t flagsX;
|
||||
uint32_t flags;
|
||||
|
||||
void threadX (void *argument) {
|
||||
|
||||
osDelay(1U);
|
||||
for (;;) {
|
||||
flagsX = osThreadFlagsWait(0x0001U, osFlagsWaitAny, osWaitForever); /* B */
|
||||
}
|
||||
}
|
||||
|
||||
void app_main (void *argument) {
|
||||
|
||||
tid = osThreadNew(threadX, NULL, NULL);
|
||||
|
||||
flags = osThreadFlagsSet(tid, 0x0002U); /* A */
|
||||
osDelay(2U);
|
||||
flags = osThreadFlagsSet(tid, 0x0005U); /* C */
|
||||
osDelay(2U);
|
||||
|
||||
for(;;);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \fn uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags )
|
||||
The function \b osThreadFlagsSet sets the thread flags for a thread specified by parameter \em thread_id. The thread returns
|
||||
the flags stored in the thread control block, or an error code if highest bit is set (refer to \ref flags_error_codes).
|
||||
Refer to \b Usage \b Examples below to understand how the return value is computed.
|
||||
|
||||
The target thread waiting for a flag to be set will resume from \ref ThreadStates "BLOCKED" state.
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error.
|
||||
- \em osFlagsErrorParameter: parameter \em thread_id is not a valid thread or \em flags has highest bit set.
|
||||
- \em osFlagsErrorResource: the thread is in invalid state.
|
||||
- \em osFlagsErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified thread.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
\b Code \b Example
|
||||
\code
|
||||
/*----------------------------------------------------------------------------
|
||||
* Function 'signal_func' called from multiple threads
|
||||
*---------------------------------------------------------------------------*/
|
||||
void signal_func (osThreadId_t tid) {
|
||||
osThreadFlagsSet(tid_clock, 0x0100U); /* set signal to clock thread */
|
||||
osDelay(500U); /* delay 500ms */
|
||||
osThreadFlagsSet(tid_clock, 0x0100U); /* set signal to clock thread */
|
||||
osDelay(500U); /* delay 500ms */
|
||||
osThreadFlagsSet(tid, 0x0001U); /* set signal to thread 'thread' */
|
||||
osDelay(500U); /* delay 500ms */
|
||||
}
|
||||
\endcode
|
||||
|
||||
\b Usage \b Examples
|
||||
|
||||
The following diagram assumes that in the control block of Thread1 the flag 1 is already set. Thread2 now sets flag 2 and
|
||||
Thread1 returns the updated value immediately:
|
||||
|
||||
\msc
|
||||
a [label="", textcolor="indigo", linecolor="indigo", arclinecolor="red"],
|
||||
b [label="", textcolor="blue", linecolor="blue", arclinecolor="blue"];
|
||||
|
||||
a note a [label="Thread1", textbgcolour="#FFCCCF"],
|
||||
b note b [label="Thread2", textbgcolour="#E0E0FF"];
|
||||
|
||||
a box a [label = "Flags == 1"];
|
||||
a<-b [label = "osThreadFlagsSet(2)"];
|
||||
a>>b [label = "return(3)"];
|
||||
a->a [label = "while(1)"];
|
||||
\endmsc
|
||||
|
||||
Depending on thread scheduling, the flag status can be modified before returning:
|
||||
|
||||
\msc
|
||||
a [label="", textcolor="indigo", linecolor="indigo", arclinecolor="red"],
|
||||
b [label="", textcolor="blue", linecolor="blue", arclinecolor="blue"];
|
||||
|
||||
a note a [label="Thread1", textbgcolour="#FFCCCF"],
|
||||
b note b [label="Thread2", textbgcolour="#E0E0FF"];
|
||||
|
||||
b box b [label = "Flags == 0"];
|
||||
b->b [label = "osThreadFlagsWait(1)"];
|
||||
b box b [label = "thread state = blocked"];
|
||||
a->b [label = "osThreadFlagsSet(1)"];
|
||||
b box b [label = "Flags == 1"];
|
||||
b box b [label = "thread state = ready"];
|
||||
b box b [label = "Flags == 0*"];
|
||||
--- [label = "If Thread2 priority > Thread1 priority, it gets scheduled immediately"];
|
||||
b->b [label = "return(1)"];
|
||||
b->b [label = "osThreadFlagsWait(1)"];
|
||||
b box b [label = "thread state = blocked"];
|
||||
--- [label = "endif"];
|
||||
b->a [label = "return(0)"];
|
||||
\endmsc
|
||||
\note * In this case \ref osThreadFlagsWait auto-clears the flag.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \fn uint32_t osThreadFlagsClear (uint32_t flags)
|
||||
\details
|
||||
The function \b osThreadFlagsClear clears the specified flags for the currently running thread. It returns the
|
||||
flags before clearing, or an error code if highest bit is set (refer to \ref flags_error_codes).
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error, i.e. not called from a running threads context.
|
||||
- \em osFlagsErrorParameter: parameter \em flags has highest bit set.
|
||||
- \em osFlagsErrorISR: the function \b osThreadFlagsClear cannot be called from interrupt service routines.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \fn uint32_t osThreadFlagsGet (void)
|
||||
\details
|
||||
The function \b osThreadFlagsGet returns the flags currently set for the currently running thread.
|
||||
If called without a active and currently running thread \b osThreadFlagsGet return zero.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/** \fn uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)
|
||||
The function \b osThreadFlagsWait suspends the execution of the currently \ref ThreadStates "RUNNING" thread until any or all of the thread
|
||||
flags specified with the parameter \a flags are set. When these thread flags are already set, the function returns instantly.
|
||||
Otherwise the thread is put into the state \ref ThreadStates "BLOCKED".
|
||||
|
||||
The parameter \em options specifies the wait condition:
|
||||
|Option | |
|
||||
|--------------------|-------------------------------------------------------|
|
||||
|\b osFlagsWaitAny | Wait for any flag (default). |
|
||||
|\b osFlagsWaitAll | Wait for all flags. |
|
||||
|\b osFlagsNoClear | Do not clear flags which have been specified to wait for. |
|
||||
|
||||
If \c osFlagsNoClear is set in the options \ref osThreadFlagsClear can be used to clear flags manually.
|
||||
Otherwise \b osThreadFlagsWait automatically clears the flags waited for.
|
||||
|
||||
The parameter \ref CMSIS_RTOS_TimeOutValue "timeout" represents a number of timer ticks and is an upper bound. The
|
||||
exact time delay depends on the actual time elapsed since the last timer tick.
|
||||
|
||||
The function returns the flags before clearing, or an error code if highest bit is set (refer to \ref flags_error_codes).
|
||||
|
||||
Possible \ref flags_error_codes return values:
|
||||
- \em osFlagsErrorUnknown: unspecified error, i.e. not called from a running threads context.
|
||||
- \em osFlagsErrorTimeout: awaited flags have not been set in the given time.
|
||||
- \em osFlagsErrorResource: awaited flags have not been set when no \a timeout was specified.
|
||||
- \em osFlagsErrorParameter: Parameter \em flags has highest bit set.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Thread (void* arg) {
|
||||
;
|
||||
osThreadFlagsWait(0x00000001U, osFlagsWaitAny, osWaitForever); // Wait forever until thread flag 1 is set.
|
||||
;
|
||||
osThreadFlagsWait(0x00000003U, osFlagsWaitAny, osWaitForever); // Wait forever until either thread flag 0 or 1 is set.
|
||||
;
|
||||
osThreadFlagsWait(0x00000003U, osFlagsWaitAll, 10U); // Wait for 10 timer ticks until thread flags 0 and 1 are set. Timeout afterwards.
|
||||
;
|
||||
osThreadFlagsWait(0x00000003U, osFlagsWaitAll | osFlagsNoClear, osWaitForever); // Same as the above, but the flags will not be cleared.
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
/// @}
|
328
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Timer.txt
vendored
Normal file
@ -0,0 +1,328 @@
|
||||
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Timer Management Functions ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_TimerMgmt Timer Management
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Create and control timer and timer callback functions.
|
||||
\details
|
||||
In addition to the \ref CMSIS_RTOS_Wait CMSIS-RTOS also supports virtual timer objects. These timer objects can
|
||||
trigger the execution of a function (not threads). When a timer expires, a callback function is executed to run associated
|
||||
code with the timer. Each timer can be configured as a one-shot or a periodic timer. A periodic timer repeats its operation
|
||||
until it is \ref osTimerDelete "deleted" or \ref osTimerStop "stopped". All timers can be
|
||||
\ref osTimerStart "started, restarted", or \ref osTimerStop "stopped".
|
||||
|
||||
\note RTX handles Timers in the thread \b osRtxTimerThread. Callback functions run under control of this thread and may use
|
||||
other CMSIS-RTOS API calls. The \b osRtxTimerThread is configured in \ref timerConfig.
|
||||
\note Timer management functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
The figure below shows the behavior of a periodic timer. For one-shot timers, the timer stops after execution of the
|
||||
callback function.
|
||||
|
||||
\image html "Timer.png" "Behavior of a Periodic Timer"
|
||||
|
||||
|
||||
Working with Timers
|
||||
--------------------
|
||||
The following steps are required to use a software timer:
|
||||
-# Define the timers:
|
||||
\code
|
||||
osTimerId_t one_shot_id, periodic_id;
|
||||
\endcode
|
||||
-# Define callback functions:
|
||||
\code
|
||||
static void one_shot_Callback (void *argument) {
|
||||
int32_t arg = (int32_t)argument; // cast back argument '0'
|
||||
// do something, i.e. set thread/event flags
|
||||
}
|
||||
static void periodic_Callback (void *argument) {
|
||||
int32_t arg = (int32_t)argument; // cast back argument '5'
|
||||
// do something, i.e. set thread/event flags
|
||||
}
|
||||
\endcode
|
||||
-# Instantiate and start the timers:
|
||||
\code
|
||||
// creates a one-shot timer:
|
||||
one_shot_id = osTimerNew(one_shot_Callback, osTimerOnce, (void *)0, NULL); // (void*)0 is passed as an argument
|
||||
// to the callback function
|
||||
// creates a periodic timer:
|
||||
periodic_id = osTimerNew(periodic_Callback, osTimerPeriodic, (void *)5, NULL); // (void*)5 is passed as an argument
|
||||
// to the callback function
|
||||
osTimerStart(one_shot_id, 500U);
|
||||
osTimerStart(periodic_id, 1500U);
|
||||
|
||||
// start the one-shot timer again after it has triggered the first time:
|
||||
osTimerStart(one_shot_id, 500U);
|
||||
|
||||
// when timers are not needed any longer free the resources:
|
||||
osTimerDelete(one_shot_id);
|
||||
osTimerDelete(periodic_id);
|
||||
\endcode
|
||||
|
||||
@{
|
||||
*/
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\enum osTimerType_t
|
||||
\details
|
||||
The \ref osTimerType_t specifies the a repeating (periodic) or one-shot timer for the function \ref osTimerNew.
|
||||
|
||||
\var osTimerType_t::osTimerOnce
|
||||
\details
|
||||
The timer is not automatically restarted once it has elapsed. It can be restarted manually using \ref osTimerStart as needed.
|
||||
|
||||
\var osTimerType_t::osTimerPeriodic
|
||||
\details
|
||||
The timer repeats automatically and triggers the callback continuously while running, see \ref osTimerStart and \ref osTimerStop.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef osTimerId_t
|
||||
\details
|
||||
Instances of this type hold a reference to a timer object. \n
|
||||
Returned by:
|
||||
- \ref osTimerNew
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\typedef void (*osTimerFunc_t) (void *argument)
|
||||
\details
|
||||
The timer callback function is called every time the timer elapses.
|
||||
|
||||
The callback might be executed either in a dedicated timer thread or in interrupt context. Thus it is recommended to only
|
||||
use ISR callable functions from the timer callback.
|
||||
|
||||
\param[in] argument The argument provided to \ref osTimerNew.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\struct osTimerAttr_t
|
||||
\details
|
||||
Specifies the following attributes for the \ref osTimerNew function.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
|
||||
\details
|
||||
The function \b osTimerNew creates an one-shot or periodic timer and associates it with a callback function with \a argument.
|
||||
The timer is in stopped state until it is started with \ref osTimerStart. The function can be safely called before the RTOS
|
||||
is started (call to \ref osKernelStart), but not before it is initialized (call to \ref osKernelInitialize).
|
||||
|
||||
The function \b osTimerNew returns the pointer to the timer object identifier or \token{NULL} in case of an error.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Timer1_Callback (void *arg); // prototypes for timer callback function
|
||||
void Timer2_Callback (void *arg); // prototypes for timer callback function
|
||||
|
||||
uint32_t exec1; // argument for the timer call back function
|
||||
uint32_t exec2; // argument for the timer call back function
|
||||
|
||||
void TimerCreate_example (void) {
|
||||
osTimerId_t id1; // timer id
|
||||
osTimerId_t id2; // timer id
|
||||
|
||||
// Create one-shoot timer
|
||||
exec1 = 1U;
|
||||
id1 = osTimerNew(Timer1_Callback, osTimerOnce, &exec1, NULL);
|
||||
if (id1 != NULL) {
|
||||
// One-shoot timer created
|
||||
}
|
||||
|
||||
// Create periodic timer
|
||||
exec2 = 2U;
|
||||
id2 = osTimerNew(Timer2_Callback, osTimerPeriodic, &exec2, NULL);
|
||||
if (id2 != NULL) {
|
||||
// Periodic timer created
|
||||
}
|
||||
:
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn const char *osTimerGetName (osTimerId_t timer_id)
|
||||
\details
|
||||
The function \b osTimerGetName returns the pointer to the name string of the timer identified by parameter \a timer_id or
|
||||
\token{NULL} in case of an error.
|
||||
|
||||
\note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks)
|
||||
\details
|
||||
The function \b osTimerStart starts or restarts a timer specified by the parameter \a timer_id. The parameter \a ticks
|
||||
specifies the value of the timer in \ref CMSIS_RTOS_TimeOutValue "time ticks".
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the specified timer has been started or restarted.
|
||||
- \em osErrorISR: \b osTimerStart cannot be called from interrupt service routines.
|
||||
- \em osErrorParameter: parameter \a timer_id is either \token{NULL} or invalid or \a ticks is incorrect.
|
||||
- \em osErrorResource: the timer is in an invalid state.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified timer.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Timer_Callback (void *arg) { // timer callback function
|
||||
// arg contains &exec
|
||||
// called every second after osTimerStart
|
||||
}
|
||||
|
||||
uint32_t exec; // argument for the timer call back function
|
||||
|
||||
void TimerStart_example (void) {
|
||||
osTimerId_t id; // timer id
|
||||
uint32_t timerDelay; // timer value
|
||||
osStatus_t status; // function return status
|
||||
|
||||
// Create periodic timer
|
||||
exec = 1U;
|
||||
id = osTimerNew(Timer_Callback, osTimerPeriodic, &exec, NULL);
|
||||
if (id != NULL) {
|
||||
timerDelay = 1000U;
|
||||
status = osTimerStart(id, timerDelay); // start timer
|
||||
if (status != osOK) {
|
||||
// Timer could not be started
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osTimerStop (osTimerId_t timer_id)
|
||||
\details
|
||||
The function \b osTimerStop stops a timer specified by the parameter \a timer_id.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the specified timer has been stopped.
|
||||
- \em osErrorISR: \b osTimerStop cannot be called from interrupt service routines.
|
||||
- \em osErrorParameter: parameter \a timer_id is either \token{NULL} or invalid.
|
||||
- \em osErrorResource: the timer is not running (you can only stop a running timer).
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified timer.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Timer_Callback (void *arg); // prototype for timer callback function
|
||||
|
||||
uint32_t exec; // argument for the timer call back function
|
||||
|
||||
void TimerStop_example (void) {
|
||||
osTimerId_t id; // timer id
|
||||
osStatus_t status; // function return status
|
||||
|
||||
// Create periodic timer
|
||||
exec = 1U;
|
||||
id = osTimerNew(Timer_Callback, osTimerPeriodic, &exec, NULL);
|
||||
osTimerStart(id, 1000U); // start timer
|
||||
:
|
||||
status = osTimerStop(id); // stop timer
|
||||
if (status != osOK) {
|
||||
// Timer could not be stopped
|
||||
}
|
||||
;
|
||||
osTimerStart(id, 1000U); // start timer again
|
||||
;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osTimerIsRunning (osTimerId_t timer_id)
|
||||
\details
|
||||
The function \b osTimerIsRunning checks whether a timer specified by parameter \a timer_id is running. It returns \token{1}
|
||||
if the timer is running and \token{0} if the timer is stopped or an error occurred.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osTimerDelete (osTimerId_t timer_id)
|
||||
\details
|
||||
The function \b osTimerDelete deletes the timer specified by parameter \a timer_id.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the specified timer has been deleted.
|
||||
- \em osErrorISR: \b osTimerDelete cannot be called from interrupt service routines.
|
||||
- \em osErrorParameter: parameter \a timer_id is either \token{NULL} or invalid.
|
||||
- \em osErrorResource: the timer is in an invalid state.
|
||||
- \em osErrorSafetyClass: the calling thread safety class is lower than the safety class of the specified timer.
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Timer_Callback (void *arg); // prototype for timer callback function
|
||||
|
||||
uint32_t exec; // argument for the timer call back function
|
||||
|
||||
void TimerDelete_example (void) {
|
||||
osTimerId_t id; // timer id
|
||||
osStatus_t status; // function return status
|
||||
|
||||
// Create periodic timer
|
||||
exec = 1U;
|
||||
id = osTimerNew(Timer_Callback, osTimerPeriodic, &exec, NULL);
|
||||
osTimerStart(id, 1000U); // start timer
|
||||
;
|
||||
status = osTimerDelete(id); // stop and delete timer
|
||||
if (status != osOK) {
|
||||
// Timer could not be deleted
|
||||
}
|
||||
;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
/// @}
|
||||
|
||||
// these struct members must stay outside the group to avoid double entries in documentation
|
||||
/**
|
||||
\var osTimerAttr_t::attr_bits
|
||||
\details
|
||||
Reserved for future use (must be set to '0' for future compatibility).
|
||||
|
||||
\var osTimerAttr_t::cb_mem
|
||||
\details
|
||||
Pointer to a memory for the timer control block object. Refer to \ref StaticObjectMemory for more information.
|
||||
|
||||
Default: \token{NULL} to use \ref CMSIS_RTOS_MemoryMgmt_Automatic for the timer control block.
|
||||
|
||||
\var osTimerAttr_t::cb_size
|
||||
\details
|
||||
The size (in bytes) of memory block passed with \ref cb_mem. For RTX, the minimum value is defined with \ref osRtxTimerCbSize (higher values are permitted).
|
||||
|
||||
Default: \token{0} as the default is no memory provided with \ref cb_mem.
|
||||
|
||||
\var osTimerAttr_t::name
|
||||
\details
|
||||
Pointer to a constant string with a human readable name (displayed during debugging) of the timer object.
|
||||
|
||||
Default: \token{NULL} no name specified.
|
||||
*/
|
1154
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Tutorial.txt
vendored
Normal file
88
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Wait.txt
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== Generic Wait Functions ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_Wait Generic Wait Functions
|
||||
\ingroup CMSIS_RTOS
|
||||
\brief Wait for a certain period of time.
|
||||
\details
|
||||
The generic wait functions provide means for a time delay.
|
||||
|
||||
\note Generic wait functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osDelay (uint32_t ticks)
|
||||
\details
|
||||
The function \b osDelay waits for a time period specified in kernel \a ticks. For a value of \token{1} the system waits
|
||||
until the next timer tick occurs. The actual time delay may be up to one timer tick less than specified, i.e. calling
|
||||
\c osDelay(1) right before the next system tick occurs the thread is rescheduled immediately.
|
||||
|
||||
The delayed thread is put into the \ref ThreadStates "BLOCKED" state and a context switch occurs immediately. The thread
|
||||
is automatically put back to the \ref ThreadStates "READY" state after the given amount of ticks has elapsed. If the thread
|
||||
will have the highest priority in \ref ThreadStates "READY" state it will be scheduled immediately.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the time delay is executed.
|
||||
- \em osErrorParameter: the time cannot be handled (zero value).
|
||||
- \em osErrorISR: \ref osDelay cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
- \em osError: \ref osDelay cannot be executed (kernel not running or no \ref ThreadStates "READY" thread exists).
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Thread_1 (void *arg) { // Thread function
|
||||
osStatus_t status; // capture the return status
|
||||
uint32_t delayTime; // delay time in milliseconds
|
||||
|
||||
delayTime = 1000U; // delay 1 second
|
||||
status = osDelay(delayTime); // suspend thread execution
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn osStatus_t osDelayUntil (uint32_t ticks)
|
||||
\details
|
||||
The function \b osDelayUntil waits until an absolute time (specified in kernel \a ticks) is reached.
|
||||
|
||||
The corner case when the kernel tick counter overflows is handled by \b osDelayUntil. Thus it is absolutely legal
|
||||
to provide a value which is lower than the current tick value, i.e. returned by \ref osKernelGetTickCount. Typically
|
||||
as a user you do not have to take care about the overflow. The only limitation you have to have in mind is that the
|
||||
maximum delay is limited to (2<sup>31</sup>)-1 ticks.
|
||||
|
||||
The delayed thread is put into the \ref ThreadStates "BLOCKED" state and a context switch occurs immediately. The thread
|
||||
is automatically put back to the \ref ThreadStates "READY" state when the given time is reached. If the thread will
|
||||
have the highest priority in \ref ThreadStates "READY" state it will be scheduled immediately.
|
||||
|
||||
Possible \ref osStatus_t return values:
|
||||
- \em osOK: the time delay is executed.
|
||||
- \em osErrorParameter: the time cannot be handled (out of bounds).
|
||||
- \em osErrorISR: \ref osDelayUntil cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
- \em osError: \ref osDelayUntil cannot be executed (kernel not running or no \ref ThreadStates "READY" thread exists).
|
||||
|
||||
\note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
void Thread_1 (void *arg) { // Thread function
|
||||
uint32_t tick;
|
||||
|
||||
tick = osKernelGetTickCount(); // retrieve the number of system ticks
|
||||
for (;;) {
|
||||
tick += 1000U; // delay 1000 ticks periodically
|
||||
osDelayUntil(tick);
|
||||
// ...
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
/// @}
|
241
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/cmsis_os2_tick.txt
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
// ==== OS Tick API ====
|
||||
/**
|
||||
\addtogroup CMSIS_RTOS_TickAPI OS Tick API
|
||||
\brief System tick timer interface for periodic RTOS Kernel Ticks defined in <b>%os_tick.h</b>
|
||||
\details
|
||||
|
||||
The <b>OS Tick API</b> is an interface to a system timer that generates the Kernel Ticks.
|
||||
|
||||
All Cortex-M processors provide an unified System Tick Timer that is typically used to generate the RTOS Kernel Tick.
|
||||
|
||||
\if ARMCA
|
||||
The Cortex-A processors do not implement an unified system timer and required a device specific implementation.
|
||||
\endif
|
||||
|
||||
CMSIS-RTOS2 provides in the directory \ref directory "CMSIS/RTOS2/Source" several OS Tick implementations that can be used by any RTOS kernel.
|
||||
|
||||
Filename | OS Tick Implementation for...
|
||||
:------------------------|:-----------------------------------------------------------------------
|
||||
\b %os_systick.c | Cortex-M SysTick timer
|
||||
\if ARMCA
|
||||
\b %os_tick_gtim.c | Cortex-A Generic Timer (available in some devices)
|
||||
\b %os_tick_ptim.c | Cortex-A Private Timer (available in some devices)
|
||||
\endif
|
||||
|
||||
\note The above OS Tick source files implement \c weak functions which may be overwritten by user-specific implementations.
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
|
||||
\details
|
||||
|
||||
Setup OS Tick timer to generate periodic RTOS Kernel Ticks.
|
||||
|
||||
The timer should be configured to generate periodic interrupts at frequency specified by \em freq.
|
||||
The parameter \em handler defines the interrupt handler function that is called.
|
||||
|
||||
The timer should only be initialized and configured but must not be started to create interrupts.
|
||||
The RTOS kernel calls the function \ref OS_Tick_Enable to start the timer interrupts.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
\code
|
||||
#ifndef SYSTICK_IRQ_PRIORITY
|
||||
#define SYSTICK_IRQ_PRIORITY 0xFFU
|
||||
#endif
|
||||
|
||||
static uint8_t PendST;
|
||||
|
||||
int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler) {
|
||||
(void)handler;
|
||||
uint32_t load;
|
||||
|
||||
if (freq == 0U) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
load = (SystemCoreClock / freq) - 1U;
|
||||
if (load > 0x00FFFFFFU) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
NVIC_SetPriority(SysTick_IRQn, SYSTICK_IRQ_PRIORITY);
|
||||
|
||||
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk;
|
||||
SysTick->LOAD = load;
|
||||
SysTick->VAL = 0U;
|
||||
|
||||
PendST = 0U;
|
||||
|
||||
return (0);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void OS_Tick_Enable (void)
|
||||
\details
|
||||
Enable OS Tick timer interrupt.
|
||||
|
||||
Enable and start the OS Tick timer to generate periodic RTOS Kernel Tick interrupts.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
\code
|
||||
void OS_Tick_Enable (void) {
|
||||
|
||||
if (PendST != 0U) {
|
||||
PendST = 0U;
|
||||
SCB->ICSR = SCB_ICSR_PENDSTSET_Msk;
|
||||
}
|
||||
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void OS_Tick_Disable (void)
|
||||
\details
|
||||
Disable OS Tick timer interrupt.
|
||||
|
||||
Stop the OS Tick timer and disable generation of RTOS Kernel Tick interrupts.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
\code
|
||||
void OS_Tick_Disable (void) {
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
|
||||
if ((SCB->ICSR & SCB_ICSR_PENDSTSET_Msk) != 0U) {
|
||||
SCB->ICSR = SCB_ICSR_PENDSTCLR_Msk;
|
||||
PendST = 1U;
|
||||
}
|
||||
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void OS_Tick_AcknowledgeIRQ (void)
|
||||
\details
|
||||
Acknowledge execution of OS Tick timer interrupt.
|
||||
|
||||
Acknowledge the execution of the OS Tick timer interrupt function, for example clear the pending flag.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
void OS_Tick_AcknowledgeIRQ (void) {
|
||||
|
||||
(void)SysTick->CTRL;
|
||||
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn int32_t OS_Tick_GetIRQn (void)
|
||||
\details
|
||||
Get OS Tick timer IRQ number.
|
||||
|
||||
Return the numeric value that identifies the interrupt called by the OS Tick timer.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
int32_t OS_Tick_GetIRQn (void) {
|
||||
return ((int32_t)SysTick_IRQn);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t OS_Tick_GetClock (void)
|
||||
\details
|
||||
Get OS Tick timer clock frequency.
|
||||
|
||||
Return the input clock frequency of the OS Tick timer. This is the increment rate of the counter value returned by the function \ref OS_Tick_GetCount.
|
||||
This function is used to by the function \ref osKernelGetSysTimerFreq.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
uint32_t OS_Tick_GetClock (void) {
|
||||
return (SystemCoreClock);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t OS_Tick_GetInterval (void)
|
||||
\details
|
||||
Get OS Tick timer interval reload value.
|
||||
|
||||
Return the number of counter ticks between to periodic OS Tick timer interrupts.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
uint32_t OS_Tick_GetInterval (void) {
|
||||
return (SysTick->LOAD + 1U);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t OS_Tick_GetCount (void)
|
||||
\details
|
||||
|
||||
Get OS Tick timer counter value.
|
||||
|
||||
Return the current value of the OS Tick counter: 0 ... (reload value -1). The reload value is returned by the function \ref OS_Tick_GetInterval.
|
||||
The OS Tick timer counter value is used to by the function \ref osKernelGetSysTimerCount.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
uint32_t OS_Tick_GetCount (void) {
|
||||
uint32_t val;
|
||||
uint32_t count;
|
||||
|
||||
val = SysTick->VAL;
|
||||
if (val != 0U) {
|
||||
count = (SysTick->LOAD - val) + 1U;
|
||||
} else {
|
||||
count = 0U;
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn OS_Tick_GetOverflow (void)
|
||||
\details
|
||||
Get OS Tick timer overflow status.
|
||||
|
||||
Return the state of OS Tick timer interrupt pending bit that indicates timer overflows to adjust SysTimer calculations.
|
||||
|
||||
<b>Cortex-M SysTick implementation:</b>
|
||||
|
||||
\code
|
||||
uint32_t OS_Tick_GetOverflow (void) {
|
||||
return ((SCB->ICSR & SCB_ICSR_PENDSTSET_Msk) >> SCB_ICSR_PENDSTSET_Pos);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/** @} */ /* group CMSIS_RTOS_TickAPI */
|
263
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/history.txt
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
/**
|
||||
\page rtos_revisionHistory Revision History
|
||||
|
||||
\section GenRTOS2Rev CMSIS-RTOS API Version 2
|
||||
|
||||
<table class="cmtable" summary="Revision History">
|
||||
<tr>
|
||||
<th>Version</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.2.0</td>
|
||||
<td>
|
||||
Added support for Process Isolation (Functional Safety):
|
||||
- Kernel Management: \ref osKernelProtect, \ref osKernelDestroyClass
|
||||
- Thread Management: \ref osThreadGetClass, \ref osThreadGetZone,<br>
|
||||
\ref osThreadSuspendClass, \ref osThreadResumeClass, \ref osThreadTerminateZone,<br>
|
||||
\ref osThreadFeedWatchdog, \ref osThreadProtectPrivileged
|
||||
- Thread attributes: \ref osThreadZone, \ref osThreadUnprivileged, \ref osThreadPrivileged
|
||||
- Object attributes: \ref osSafetyClass
|
||||
- Handler functions: \ref osWatchdogAlarm_Handler
|
||||
- Zone Management: \ref osZoneSetup_Callback
|
||||
- Exception Faults: \ref osFaultResume
|
||||
|
||||
Additional functions allowed to be called from Interrupt Service Routines:
|
||||
- \ref osThreadGetName, \ref osEventFlagsGetName, \ref osTimerGetName, \ref osMutexGetName, \ref osSemaphoreGetName, \ref osMemoryPoolGetName, \ref osMessageQueueGetName
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.1.3</td>
|
||||
<td>
|
||||
Additional functions allowed to be called from Interrupt Service Routines:
|
||||
- \ref osThreadGetId
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.1.2</td>
|
||||
<td>
|
||||
Additional functions allowed to be called from Interrupt Service Routines:
|
||||
- \ref osKernelGetInfo, \ref osKernelGetState
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.1.1</td>
|
||||
<td>
|
||||
Additional functions allowed to be called from Interrupt Service Routines:
|
||||
- \ref osKernelGetTickCount, \ref osKernelGetTickFreq
|
||||
|
||||
Changed Kernel Tick type to uint32_t:
|
||||
- updated: \ref osKernelGetTickCount, \ref osDelayUntil
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.1.0</td>
|
||||
<td>
|
||||
Support for critical and uncritical sections (nesting safe):
|
||||
- updated: \ref osKernelLock, \ref osKernelUnlock
|
||||
- added: \ref osKernelRestoreLock
|
||||
|
||||
Updated \ref CMSIS_RTOS_ThreadFlagsMgmt "Thread Flags" and \ref CMSIS_RTOS_EventFlags "Event Flags":
|
||||
- changed flags parameter and return type from int32_t to uint32_t
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V2.0.0</td>
|
||||
<td>
|
||||
New API Version 2.0 available.
|
||||
- See \ref rtos_api2 for a detailed function reference.
|
||||
- See \ref os2Migration for details on the migration process from API Version 1.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V1.02 - only documentation changes</td>
|
||||
<td>
|
||||
Added: Overview of the \ref rtosValidation "CMSIS-RTOS Validation" Software Pack.\n
|
||||
Clarified: Behavior of \ref CMSIS_RTOS_TimeOutValue.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V1.02</td>
|
||||
<td>Added: New control functions for short timeouts in microsecond resolution \b osKernelSysTick,
|
||||
\b osKernelSysTickFrequency, \b osKernelSysTickMicroSec.\n
|
||||
Removed: osSignalGet.
|
||||
</td>
|
||||
</tr>fv
|
||||
<tr>
|
||||
<td>V1.01</td>
|
||||
<td>Added capabilities for C++, kernel initialization and object deletion.\n
|
||||
Prepared for C++ class interface. In this context to \em const attribute has been moved from osXxxxDef_t typedefs to
|
||||
the osXxxxDef macros.\n
|
||||
Added: \ref osTimerDelete, \ref osMutexDelete, \ref osSemaphoreDelete.\n
|
||||
Added: \ref osKernelInitialize that prepares the kernel for object creation.\n
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
V1.00</td>
|
||||
<td>First official Release.\n
|
||||
Added: \ref osKernelStart; starting 'main' as a thread is now an optional feature.\n
|
||||
Semaphores have now the standard behavior.\n
|
||||
\b osTimerCreate does no longer start the timer. Added: \ref osTimerStart (replaces osTimerRestart).\n
|
||||
Changed: osThreadPass is renamed to \ref osThreadYield.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V0.02</td>
|
||||
<td>Preview Release.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
\section RTX5RevisionHistory CMSIS-RTOS RTX Version 5
|
||||
|
||||
<table class="cmtable" summary="Revision History">
|
||||
<tr>
|
||||
<th>Version</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.7.0</td>
|
||||
<td>
|
||||
- Based on CMSIS-RTOS API V2.2.0.
|
||||
- Added support for Process Isolation: MPU Protected Zones, Safety Classes, Thread Watchdogs.
|
||||
- Reduced component variants: Library (Library_NS replacement), Source (Source_NS replacement).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.5</td>
|
||||
<td>
|
||||
- Added de-allocation of Arm C library thread data (libspace) when thread is terminated.
|
||||
- Updated SysTick implementation for OS Tick (initial count value).
|
||||
- Added Thread Entry wrapper (compatible with GDB stack unwind).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.4</td>
|
||||
<td>
|
||||
- Fixed potential register R1 corruption when calling OS functions from threads multiple times with same arguments (when using high level compiler optimizations).
|
||||
- Fixed timer interval when periodic timer is restarted.
|
||||
- Added Floating-point initialization for Arm C Library.
|
||||
- Minor code optimizations in osMessageQueuePut/Get.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.3</td>
|
||||
<td>
|
||||
- CVE-2021-27431 vulnerability mitigation.
|
||||
- Added OS Initialization for IAR.
|
||||
- Fixed osDelay/osDelayUntil error handling.
|
||||
- Fixed Round-Robin (timeout value is not reset when switching to higher priority threads).
|
||||
- Fixed osThreadJoin (when terminating thread which is waiting to be joined).
|
||||
- Fixed Message Queue Data allocation size when using object specific memory allocation.
|
||||
- Fixed Mutex priority inversion (when mixing mutexes with and without priority inherit).
|
||||
- Enhanced stack overrun checking.
|
||||
- Updated osKernelResume handling (processing past sleep ticks).
|
||||
- Updated configuration (Event Recorder).
|
||||
- Reorganized and optimized IRQ modules.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.2</td>
|
||||
<td>
|
||||
- Added support for Cortex-M55.
|
||||
- Fixed thread priority restore on mutex acquire timeout (when priority inherit is used).
|
||||
- Enhanced support for Armv8-M (specifying thread TrustZone module identifier is optional).
|
||||
- Updated configuration default values (Global Dynamic Memory and Thread Stack).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.1</td>
|
||||
<td>
|
||||
- Fixed osMutexRelease issue (thread owning multiple mutexes).
|
||||
- Improved osThreadJoin robustness (user programing errors).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.5.0</td>
|
||||
<td>
|
||||
- Updated and enhanced generated events (reorganized components).
|
||||
- Updated configuration (Event Recorder).
|
||||
- Updated Component Viewer (improved performance).
|
||||
- Minor code optimizations.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.4.0</td>
|
||||
<td>
|
||||
- Based on CMSIS-RTOS API V2.1.3.
|
||||
- Added support for Event Recorder initialization and filter setup.
|
||||
- Added support to use RTOS as Event Recorder Time Stamp source.
|
||||
- Fixed osDelayUntil longest delay (limited to 2^31-1).
|
||||
- Fixed optimization issue when using GCC optimization level 3.
|
||||
- Fixed osMemoryPoolAlloc to avoid potential race condition.
|
||||
- Restructured exception handling for Cortex-A devices.
|
||||
- Minor code optimizations (removed unnecessary checks).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.3.0</td>
|
||||
<td>
|
||||
- Added Object Memory usage counters.
|
||||
- Added support for additional external configuration file.
|
||||
- Added user configurable names for system threads (Idle and Timer).
|
||||
- Added support for OS sections when using ARMCC5.
|
||||
- Added callback for MPU integration (experimental)
|
||||
- Increased default thread stack sizes to 256 bytes.
|
||||
- Fixed stack context display for running thread in SCVD.
|
||||
- Enhanced MISRA Compliance.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.2.3</td>
|
||||
<td>
|
||||
- Based on CMSIS-RTOS API V2.1.2.
|
||||
- Added TrustZone Module Identifier configuration for Idle and Timer Thread.
|
||||
- Moved SVC/PendSV handler priority setup from osKernelInitialize to osKernelStart (User Priority Grouping can be updated after osKernelInitialize but before osKernelStart).
|
||||
- Corrected SysTick and PendSV handlers for ARMv8-M Baseline.
|
||||
- Corrected memory allocation for stack and data when "Object specific Memory allocation" configuration is used.
|
||||
- Added support for ARMv8-M IAR compiler.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.2.2</td>
|
||||
<td>
|
||||
- Corrected IRQ and SVC exception handlers for Cortex-A.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.2.1</td>
|
||||
<td>
|
||||
- Corrected SysTick and SVC Interrupt Priority for Cortex-M.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.2.0</td>
|
||||
<td>
|
||||
- Based on CMSIS-RTOS API V2.1.1.
|
||||
- Added support for Cortex-A.
|
||||
- Using OS Tick API for RTX Kernel Timer Tick.
|
||||
- Fixed potential corruption of terminated threads list.
|
||||
- Corrected MessageQueue to use actual message length (before padding).
|
||||
- Corrected parameters for ThreadEnumerate and MessageQueueInserted events.
|
||||
- Timer Thread creation moved to osKernelStart.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.1.0</td>
|
||||
<td>
|
||||
- Based on CMSIS-RTOS API V2.1.0.
|
||||
- Added support for Event recording.
|
||||
- Added support for IAR compiler.
|
||||
- Updated configuration files: RTX_Config.h for the configuration settings and RTX_config.c for implementing the \ref rtx5_specific.
|
||||
- osRtx name-space for RTX specific symbols.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>V5.0.0</td>
|
||||
<td>
|
||||
Initial release compliant to CMSIS-RTOS2.\n
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
*/
|
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/API_Structure.png
vendored
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/API_Structure.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/CMSIS_RTOS_Files.png
vendored
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/KernelStackUsage.png
vendored
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MailQueue.png
vendored
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MemAllocGlob.png
vendored
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MemAllocSpec.png
vendored
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MemAllocStat.png
vendored
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MessageQueue.png
vendored
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/MessageQueue.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/Mutex.png
vendored
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/Mutex.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/PC-Lint.png
vendored
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/RTX5_Migrate1.PNG
vendored
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/Semaphore.png
vendored
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/Semaphores.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/TheoryOfOperation.pptx
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/ThreadStatus.png
vendored
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/ThreadStatus.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/Timer.png
vendored
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/TimerValues.png
vendored
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/TimerValues.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/add_item.png
vendored
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/cmsis_rtos_file_structure.vsd
vendored
Normal file
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard.png
vendored
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_eventFlags.png
vendored
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_evtrec.png
vendored
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_evtrecGeneration.png
vendored
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_evtrecGlobEvtFiltSetup.png
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_evtrecGlobIni.png
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_evtrecRTOSEvtFilterSetup.png
vendored
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_memPool.png
vendored
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_msgQueue.png
vendored
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_mutex.png
vendored
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_semaphore.png
vendored
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_system.png
vendored
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_threads.png
vendored
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/config_wizard_timer.png
vendored
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/event_recorder_rte.png
vendored
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/manage_rte_cortex-a.png
vendored
Normal file
After Width: | Height: | Size: 109 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/manage_rte_output.png
vendored
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/mempool.png
vendored
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/mutex_states.png
vendored
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/own_lib_projwin.png
vendored
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/project_window.png
vendored
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/rtos_components.png
vendored
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/rtos_mpu.png
vendored
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/scheduling.png
vendored
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/semaphore_states.png
vendored
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/simple_signal.png
vendored
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/images/thread_watchdogs.png
vendored
Normal file
After Width: | Height: | Size: 74 KiB |
78
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/mainpage.txt
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\mainpage
|
||||
|
||||
The <b>CMSIS-RTOS v2 (CMSIS-RTOS2)</b> provides generic RTOS interfaces for Arm® Cortex® processor-based
|
||||
devices. It provides a standardized API for software components that require RTOS functionality and gives therefore serious
|
||||
benefits to the users and the software industry:
|
||||
- CMSIS-RTOS2 provides basic features that are required in many applications.
|
||||
- The unified feature set of the CMSIS-RTOS2 reduces learning efforts and simplifies sharing of software components.
|
||||
- Middleware components that use the CMSIS-RTOS2 are RTOS agnostic and are easier to adapt.
|
||||
- Standard project templates of the CMSIS-RTOS2 may be shipped with freely available CMSIS-RTOS2 implementations.
|
||||
|
||||
\note The CMSIS-RTOS API Version 2 defines a minimum feature set. Implementations with extended features may be provided by
|
||||
the RTOS vendors.
|
||||
|
||||
The CMSIS-RTOS2 manages the resources of the microcontroller system and implements the concept of parallel threads that run
|
||||
concurrently.
|
||||
|
||||
Applications frequently require several concurrent activities. CMSIS-RTOS2 can manage multiple concurrent activities at the
|
||||
time when they are needed. Each activity gets a separate thread which executes a specific task and this simplifies the
|
||||
overall program structure. The CMSIS-RTOS2 system is scalable and additional threads can be added easily at a later time.
|
||||
Threads have a priority allowing faster execution of time-critical parts of a user application.
|
||||
|
||||
The CMSIS-RTOS2 offers services needed in many real-time applications, for example, periodical activation of timer functions,
|
||||
memory management, and message exchange between threads with time limits.
|
||||
|
||||
The CMSIS-RTOS2 addresses the following new requirements:
|
||||
- Dynamic object creation no longer requires static memory, static memory buffers are now optional.
|
||||
\if ARMv8M
|
||||
- Support for Armv8-M architecture that provides a secure and non-secure state of code execution.
|
||||
\endif
|
||||
- Provisions for message passing in multi-core systems.
|
||||
- Full support of C++ run-time environments.
|
||||
- C interface which is binary compatible across
|
||||
<a href="http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.abi/index.html">ABI compatible compilers</a>.
|
||||
|
||||
As a consequence of these requirements the CMSIS-RTOS2 has the following fundamental modifications:
|
||||
- The functions osXxxxNew replace osXxxxCreate functions; osXxxxNew and osXxxxDelete create and destroy objects.
|
||||
- The C function \c main is no longer started as a thread (this was an optional feature in CMSIS-RTOS v1).
|
||||
- Functions that return osEvent have been replaced.
|
||||
|
||||
CMSIS-RTOS2 provides an translation layer to <a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS v1</a>. It
|
||||
is possible to intermix \ref rtos_api2 and <a class="el" href="../../RTOS/html/functionOverview.html">CMSIS-RTOS C API v1</a>
|
||||
within the same application. Over time, you may migrate to the new API as explained in \ref os2Migration.
|
||||
|
||||
CMSIS-RTOS2 is not POSIX compliant, but has provisions to enable a C++11/C++14 interface.
|
||||
|
||||
The following sections provide further details about CMSIS-RTOS2 and the RTX reference implementation.
|
||||
- \subpage rtos_revisionHistory documents changes made in each version for CMSIS-RTOS v2 and RTX v5.
|
||||
- \subpage genRTOS2IF provides an overview about the APIs available with CMSIS-RTOS v2.
|
||||
- \subpage functionOverview lists the CMSIS-RTOS2 API functions and the header file %cmsis_os2.h.
|
||||
\ifnot FuSaRTS
|
||||
- \subpage rtosValidation describes the validation suite that is publicly available.
|
||||
- \subpage os2Migration shows how to use CMSIS-RTOS2 in existing projects and lists function differences to CMSIS-RTOS v1.
|
||||
\endif
|
||||
- \subpage rtx5_impl provides general information about the operation and usage of RTX v5.
|
||||
\if FuSaRTS
|
||||
- \subpage rtx_safety provides comprehensive instructions for highly reliable applications.
|
||||
\endif
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
CMSIS-RTOS2 in ARM::CMSIS Pack
|
||||
------------------------------
|
||||
\anchor directory
|
||||
|
||||
The following files relevant to CMSIS-RTOS2 are present in the <b>ARM::CMSIS</b> Pack directories:
|
||||
Directory | Content
|
||||
:----------------------------|:-----------------------------------------------------------------------
|
||||
\b CMSIS/Documentation/RTOS2 | This documentation
|
||||
\b CMSIS/RTOS2/Include | \ref cmsis_os2_h
|
||||
\b CMSIS/RTOS2/RTX | CMSIS-RTOS2 reference implementation based on RTX version 5
|
||||
\b CMSIS/RTOS2/Source | Generic <b>OS tick</b> implementations for various processors based on \ref rtos_os_tick_api
|
||||
\b CMSIS/RTOS2/Template | Compatibility layer to <a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS v1</a>
|
||||
*/
|
||||
|
||||
|
2131
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/rtx_evr.txt
vendored
Normal file
359
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/rtx_os.txt
vendored
Normal file
@ -0,0 +1,359 @@
|
||||
|
||||
/**
|
||||
\addtogroup rtx5_specific RTX v5 Specific API
|
||||
\brief RTX v5 implementation specific definitions and functions defined in <b>%rtx_os.h</b>.
|
||||
\details
|
||||
|
||||
The RTX5 kernel can be customized for different application requirements:
|
||||
|
||||
- The function \ref osRtxIdleThread implements the idle thread and allows set the system into sleep modes for \ref lowPower or
|
||||
\ref TickLess for ultra-low power operation.
|
||||
|
||||
- The function \ref osRtxErrorNotify may be extended to handle system runtime errors.
|
||||
|
||||
RTX5 interfaces to the <a href="https://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>
|
||||
and provides event information that helps to analyze the operation. Refer to \ref rtx_evr for more information.
|
||||
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\defgroup rtx5_specific_defines Macros
|
||||
\brief RTX5 macros
|
||||
\details
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxThreadCbSize
|
||||
\brief Thread Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Thread Control Block,
|
||||
see osThreadAttr_t::cb_mem and \ref osThreadAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for thread control block
|
||||
static uint32_t thread_cb[osRtxThreadCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxTimerCbSize
|
||||
\brief Timer Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Timer Control Block,
|
||||
see osTimerAttr_t::cb_mem and \ref osTimerAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for timer control block
|
||||
static uint32_t timer_cb[osRtxTimerCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxEventFlagsCbSize
|
||||
\brief Event Flags Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Event Flags Control Block,
|
||||
see osEventFlagsAttr_t::cb_mem and \ref osEventFlagsAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for event flags control block
|
||||
static uint32_t evflags_cb[osRtxEventFlagsCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxMutexCbSize
|
||||
\brief Mutex Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Mutex Control Block,
|
||||
see osMutexAttr_t::cb_mem and \ref osMutexAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for mutex control block
|
||||
static uint32_t mutex_cb[osRtxMutexCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxSemaphoreCbSize
|
||||
\brief Semaphore Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Semaphore Control Block,
|
||||
see osSemaphoreAttr_t::cb_mem and osSemaphoreAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for semaphore control block
|
||||
static uint32_t sema_cb[osRtxSemaphoreCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxMemoryPoolCbSize
|
||||
\brief Memory Pool Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Memory Pool Control Block,
|
||||
see osMemoryPoolAttr_t::cb_mem and osMemoryPoolAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for memory pool control block
|
||||
static uint32_t mempool_cb[osRtxMemoryPoolCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxMessageQueueCbSize
|
||||
\brief Message Queue Control Block size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Message Queue Control Block,
|
||||
see osMessageQueueAttr_t::cb_mem and osMessageQueueAttr_t::cb_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Used-defined memory for message queue control block
|
||||
static uint32_t msgqueue_cb[osRtxMessageQueueCbSize/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxMemoryPoolMemSize
|
||||
\brief Memory Pool Memory size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Memory Pool Memory,
|
||||
see osMemoryPoolAttr_t::mp_mem and osMemoryPoolAttr_t::mp_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Maximum number of objects
|
||||
#define OBJ_COUNT 8U
|
||||
|
||||
// Object type
|
||||
typedef struct {
|
||||
uint32_t value1;
|
||||
uint8_t value2;
|
||||
} object_t;
|
||||
|
||||
// Used-defined memory for memory pool memory
|
||||
static uint32_t mempool_mem[osRtxMemoryPoolMemSize(OBJ_COUNT, sizeof(object_t))/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxMessageQueueMemSize
|
||||
\brief Message Queue Memory size
|
||||
\details
|
||||
This macro exposes the minimum amount of memory needed for an RTX5 Message Queue Memory,
|
||||
see osMessageQueueAttr_t::mq_mem and osMessageQueueAttr_t::mq_size.
|
||||
|
||||
Example:
|
||||
\code
|
||||
// Maximum number of messages
|
||||
#define MSG_COUNT 16U
|
||||
|
||||
// Message data type
|
||||
typedef struct {
|
||||
uint32_t value1;
|
||||
uint8_t value2;
|
||||
} msg_item_t;
|
||||
|
||||
// Used-defined memory for message queue
|
||||
static uint32_t mq_mem[osRtxMessageQueueMemSize(MSG_COUNT, sizeof(msg_item_t))/4U];
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorStackUnderflow
|
||||
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorStackOverflow
|
||||
\brief Stack overflow, i.e. stack pointer below its lower memory limit for descending stacks.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 detects a thread stack overflow.
|
||||
The object_id announced along this error can be used to identify the affected thread.
|
||||
|
||||
\ref threadConfig_watermark used together with larger stack sizes can help to figure out actual
|
||||
memory requirements for threads.
|
||||
|
||||
\attention Whenever this error identifier is signaled memory corruption has already happened.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorISRQueueOverflow
|
||||
\brief ISR Queue overflow detected when inserting object.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 detects an overflow of the
|
||||
interrupt post processing message queue. The object_id can be used to identify the affected
|
||||
object.
|
||||
|
||||
\attention Whenever this error identifier is signaled the system state is already inconsistent.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorTimerQueueOverflow
|
||||
\brief User Timer Callback Queue overflow detected for timer.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 detects an overflow of the
|
||||
timer callback queue. The object_id can be used to identify the affected timer.
|
||||
|
||||
\attention Whenever this error identifier is signaled a timer callback is already lost.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorClibSpace
|
||||
\brief Standard C/C++ library libspace not available.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 detects usage of libspace
|
||||
but not enough memory was reserved using \c OS_THREAD_LIBSPACE_NUM.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorClibMutex
|
||||
\brief Standard C/C++ library mutex initialization failed.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 fails to create mutexes needed
|
||||
to lock global C/C++ library resources.
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\def osRtxErrorSVC
|
||||
\brief Invalid SVC function called.
|
||||
\details
|
||||
This error identifier is used with \ref osRtxErrorNotify when RTX5 detects SVC function pointer that is not properly aligned
|
||||
or is located outside of the RTX5 SVC function table.
|
||||
*/
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
\defgroup rtx5_specific_functions Functions
|
||||
\brief RTX5 functions
|
||||
\details
|
||||
@{
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn uint32_t osRtxErrorNotify (uint32_t code, void *object_id);
|
||||
\param[in] code The code to identify the error condition.
|
||||
\param[in] object_id A reference to any RTX object to identify the object that caused the issue, can be \token{NULL}.
|
||||
\details
|
||||
Some system error conditions can be detected during runtime. If the RTX kernel detects a runtime error, it calls the runtime
|
||||
error function \b osRtxErrorNotify for an object specified by parameter \a object_id.
|
||||
|
||||
The parameter \a code passes the actual error code to this function:
|
||||
| Error Code | Description |
|
||||
|-----------------------------------|-----------------------------------------------------------------------------------|
|
||||
| \ref osRtxErrorStackOverflow | Stack overflow detected for thread (thread_id=object_id) |
|
||||
| \ref osRtxErrorISRQueueOverflow | ISR Queue overflow detected when inserting object (object_id) |
|
||||
| \ref osRtxErrorTimerQueueOverflow | User Timer Callback Queue overflow detected for timer (timer_id=object_id) |
|
||||
| \ref osRtxErrorClibSpace | Standard C/C++ library libspace not available: increase \c OS_THREAD_LIBSPACE_NUM |
|
||||
| \ref osRtxErrorClibMutex | Standard C/C++ library mutex initialization failed |
|
||||
| \ref osRtxErrorSVC | Invalid SVC function called (function=object_id) |
|
||||
|
||||
The function \b 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.
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "rtx_os.h"
|
||||
|
||||
uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
|
||||
(void)object_id;
|
||||
|
||||
switch (code) {
|
||||
case osRtxErrorStackOverflow:
|
||||
// Stack overflow detected for thread (thread_id=object_id)
|
||||
break;
|
||||
case osRtxErrorISRQueueOverflow:
|
||||
// ISR Queue overflow detected when inserting object (object_id)
|
||||
break;
|
||||
case osRtxErrorTimerQueueOverflow:
|
||||
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
|
||||
break;
|
||||
case osRtxErrorClibSpace:
|
||||
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
|
||||
break;
|
||||
case osRtxErrorClibMutex:
|
||||
// Standard C/C++ library mutex initialization failed
|
||||
break;
|
||||
case osRtxErrorSVC:
|
||||
// Invalid SVC function called (function=object_id)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (;;) {}
|
||||
//return 0U;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
|
||||
/**
|
||||
\fn void osRtxIdleThread (void *argument);
|
||||
\param[in] argument Unused parameter, always set to \token{NULL}.
|
||||
\details
|
||||
The function \b 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 \b osRtxIdleThread function to put the CPU into
|
||||
a power-saving or idle mode, see \ref TickLess.
|
||||
|
||||
The default stack size for this thread is defined in the file RTX_Config.h. Refer to \ref threadConfig.
|
||||
|
||||
\attention
|
||||
The idle thread should never be blocked nor terminated!
|
||||
<b>Do not</b> call
|
||||
<ul>
|
||||
<li>blocking functions,</li>
|
||||
<li>\ref osThreadTerminate, or </li>
|
||||
<li>\ref osThreadExit</li>
|
||||
</ul>
|
||||
and <b>do not</b> return from this function when providing a user defined implementation.
|
||||
|
||||
<b>Code Example</b>
|
||||
\code
|
||||
#include "rtx_os.h"
|
||||
|
||||
__NO_RETURN void osRtxIdleThread (void *argument) {
|
||||
(void)argument;
|
||||
|
||||
for (;;) {}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
||||
/// @}
|
8
external/CMSIS_5/CMSIS/DoxyGen/RTOS2/src/validation.txt
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
\page rtosValidation RTOS Validation
|
||||
|
||||
<a href="https://github.com/ARM-software/CMSIS-RTOS2_Validation" target="_blank"><b>CMSIS-RTOS2 Validation</b></a> framework is available to verify operation of CMSIS-RTOS2 implementations. The test cases validate the functional behavior, test invalid parameters and call management functions from Interrupt Service Routines (ISRs). The test projects are provided based on the <a href=" https://github.com/Open-CMSIS-Pack/devtools/tree/main/tools" target="_blank">CMSIS-Toolbox</a> and integrate well into CI workflows.
|
||||
|
||||
For details about the scope and usage, please, refer to the <a href="https://arm-software.github.io/CMSIS-RTOS2_Validation/main/index.html" target="_blank">CMSIS-RTOS2 Validation manual</a>.
|
||||
|
||||
*/
|