]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Wait.txt
RTOS2 Doc
[cmsis] / CMSIS / DoxyGen / RTOS2 / src / cmsis_os2_Wait.txt
1
2 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3 //  ==== Generic Wait Functions ====
4 /** 
5 \addtogroup CMSIS_RTOS_Wait Generic Wait Functions
6 \ingroup CMSIS_RTOS
7 \brief Wait for a time period or unspecified events.
8 \details 
9 The Generic Wait function group provides means for a time delay and allow to wait for unspecified events.
10
11 @{
12 */
13
14 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
15 /** 
16 \fn osStatus_t osDelay (uint32_t ticks)
17 \details
18 Wait for a specified time period in \a kernel ticks.
19
20 The \ref CMSIS_RTOS_TimeOutValue "timeout" value represents a number of timer ticks and is an upper bound. The
21 exact time delay depends on the actual time elapsed since the last timer tick. 
22
23 For a value of <b>1</b>, the system waits until the next timer tick occurs. That means that the actual time delay may be up
24 to one timer tick less.
25
26 \ref osStatus_t return values:
27  - \em osEventTimeout: the time delay is executed.
28  - \em osErrorISR: \ref osDelay cannot be called from interrupt service routines.
29
30 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
31  
32 <b>Code Example</b>
33 \code{.c}
34 #include "cmsis_os2.h"
35  
36 void Thread_1 (void *arg)  {               // Thread function
37   osStatus_t status;                        // capture the return status
38   uint32_t   delayTime;                     // delay time in milliseconds
39  
40   delayTime = 1000;                         // delay 1 second
41   status = osDelay (delayTime);             // suspend thread execution
42   if (status != osOK) {
43     // handle error code
44   }  
45 }
46 \endcode
47 */ 
48 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
49 /** 
50 \fn osStatus_t osDelayUntil (uint64_t ticks)
51 \details
52 Wait until an absolute time - specified in kernel ticks - is reached. 
53
54 The \ref CMSIS_RTOS_TimeOutValue "timeout" value represents a number of timer ticks and is an upper bound. The
55 exact time delay depends on the actual time elapsed since the last timer tick. 
56
57 \ref osKernelGetSysTimerCount can be used to retrieve the current elapsed time of the kernel in .
58
59 \ref osStatus_t return values:
60  - \em osEventTimeout: the time delay is executed.
61  - \em osErrorISR: \ref osDelayUntil cannot be called from interrupt service routines.
62
63 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines". 
64
65 <b>Code Example</b>
66 \code{.c}
67 #include "cmsis_os2.h"
68  
69 void Thread_1 (void *arg)  {               // Thread function
70   osStatus_t status;                        // capture the return status
71   uint32_t   delayTime;                     // delay time in milliseconds
72  
73   delayTime = osKernelGetTime() + 2000;     // 2 seconds from now.
74   status = osDelay (delayTime);             // suspend thread execution
75   if (status != osOK) {
76     // handle error code
77   }  
78 }
79 \endcode
80 */
81 /// @}