2 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3 // ==== Generic Wait Functions ====
5 \addtogroup CMSIS_RTOS_Wait Generic Wait Functions
7 \brief Wait for a time period or unspecified events.
9 The Generic Wait function group provides means for a time delay and allow to wait for unspecified events.
14 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
16 \fn osStatus_t osDelay (uint32_t ticks)
18 Wait for a specified time period in \a kernel ticks.
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.
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.
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.
30 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
34 #include "cmsis_os2.h"
36 void Thread_1 (void *arg) { // Thread function
37 osStatus_t status; // capture the return status
38 uint32_t delayTime; // delay time in milliseconds
40 delayTime = 1000; // delay 1 second
41 status = osDelay (delayTime); // suspend thread execution
48 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
50 \fn osStatus_t osDelayUntil (uint64_t ticks)
52 Wait until an absolute time - specified in kernel ticks - is reached.
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.
57 \ref osKernelGetSysTimerCount can be used to retrieve the current elapsed time of the kernel in .
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.
63 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
67 #include "cmsis_os2.h"
69 void Thread_1 (void *arg) { // Thread function
70 osStatus_t status; // capture the return status
71 uint32_t delayTime; // delay time in milliseconds
73 delayTime = osKernelGetTime() + 2000; // 2 seconds from now.
74 status = osDelay (delayTime); // suspend thread execution