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 certain period of time.
9 The generic wait functions provide means for a time delay.
11 \note Generic wait functions cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
15 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
17 \fn osStatus_t osDelay (uint32_t ticks)
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. That means that the actual time delay may be up to one timer tick less.
22 Possible \ref osStatus_t return values:
23 - \em osOK: the time delay is executed.
24 - \em osErrorISR: \ref osDelay cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
26 \note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
30 #include "cmsis_os2.h"
32 void Thread_1 (void *arg) { // Thread function
33 osStatus_t status; // capture the return status
34 uint32_t delayTime; // delay time in milliseconds
36 delayTime = 1000; // delay 1 second
37 status = osDelay (delayTime); // suspend thread execution
42 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
44 \fn osStatus_t osDelayUntil (uint64_t ticks)
46 The function \b osDelayUntil waits until an absolute time (specified in kernel \a ticks) is reached.
48 Possible \ref osStatus_t return values:
49 - \em osOK: the time delay is executed.
50 - \em osParameter: the time is either in the past or cannot be handled (out of bounds).
51 - \em osErrorISR: \ref osDelayUntil cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
53 \note This function \b cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
57 #include "cmsis_os2.h"
59 void Thread_1 (void *arg) { // Thread function
62 tick = osKernelGetTickCount(); // retrieve the number of system ticks
64 tick += 1000; // delay 1000 ticks periodically