]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Wait.txt
Changed wording on osThreadFlagsSet and added diagrams for better understanding.
[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 certain period of time.
8 \details 
9 The generic wait functions provide means for a time delay.
10
11 \note Generic wait functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
12 @{
13 */
14
15 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
16 /** 
17 \fn osStatus_t osDelay (uint32_t ticks)
18 \details
19 The function \b osDelay waits for a time period specified in kernel \a ticks. For a value of \token{1} the system waits
20 until the next timer tick occurs. The actual time delay may be up to one timer tick less than specified, i.e. calling 
21 \c osDelay(1) right before the next system tick occurs the thread is rescheduled immediately.
22
23 The delayed thread is put into the \ref ThreadStates "BLOCKED" state and a context switch occurs immediately. The thread
24 is automatically put back to the \ref ThreadStates "READY" state after the given amount of ticks has elapsed. If the thread
25 will have the highest priority in \ref ThreadStates "READY" state it will being scheduled immediately.
26
27 Possible \ref osStatus_t return values:
28  - \em osOK: the time delay is executed.
29  - \em osErrorISR: \ref osDelay cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
30
31 \note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
32
33 <b>Code Example</b>
34 \code
35 #include "cmsis_os2.h"
36  
37 void Thread_1 (void *arg) {             // Thread function
38   osStatus_t status;                    // capture the return status
39   uint32_t   delayTime;                 // delay time in milliseconds
40  
41   delayTime = 1000U;                    // delay 1 second
42   status = osDelay(delayTime);          // suspend thread execution
43 }
44 \endcode
45 */ 
46
47 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
48 /** 
49 \fn osStatus_t osDelayUntil (uint32_t ticks)
50 \details
51 The function \b osDelayUntil waits until an absolute time (specified in kernel \a ticks) is reached.
52
53 The corner case when the kernel tick counter overflows is handled by \b osDelayUntil. Thus it is absolutely legal
54 to provide a value which is lower than the current tick value, i.e. returned by \ref osKernelGetTickCount. Typically
55 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
56 maximum delay is limited to (2<sup>31</sup>)-1 ticks.
57
58 The delayed thread is put into the \ref ThreadStates "BLOCKED" state and a context switch occurs immediately. The thread
59 is automatically put back to the \ref ThreadStates "READY" state when the given time is reached. If the thread will
60 have the highest priority in \ref ThreadStates "READY" state it will being scheduled immediately.
61
62 Possible \ref osStatus_t return values:
63  - \em osOK: the time delay is executed.
64  - \em osParameter: the time cannot be handled (out of bounds).
65  - \em osErrorISR: \ref osDelayUntil cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
66
67 \note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
68
69 <b>Code Example</b>
70 \code
71 #include "cmsis_os2.h"
72  
73 void Thread_1 (void *arg) {             // Thread function
74   uint32_t tick;
75  
76   tick = osKernelGetTickCount();        // retrieve the number of system ticks
77   for (;;) {
78     tick += 1000U;                      // delay 1000 ticks periodically
79     osDelayUntil(tick);
80     // ...
81   }
82 }
83 \endcode
84 */
85 /// @}