Mistake on this page?
Report an issue in GitHub or email us
mbed_thread.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_THREAD_H
18 #define MBED_THREAD_H
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /**
26  * \defgroup mbed_thread Mbed Thread
27  * \ingroup platform-public-api
28  * @{
29  */
30 
31 /** Generic thread functions.
32  *
33  * These are C versions of functions provided in C++ via rtos::Thread and rtos::ThisThread
34  */
35 
36 /** Read the current RTOS kernel millisecond tick count.
37  The tick count corresponds to the tick count the RTOS uses for timing
38  purposes. It increments monotonically from 0 at boot, so it effectively
39  never wraps. If the underlying RTOS only provides a 32-bit tick count,
40  this method expands it to 64 bits.
41  @return RTOS kernel current tick count
42  @note Mbed OS always uses millisecond RTOS ticks, and this could only wrap
43  after half a billion years.
44  @note In a non-RTOS build, this computes an equivalent time in milliseconds,
45  based on a HAL timer. The time may be referenced as 0 on first call.
46  @note You cannot call this function from ISR context.
47  @note The equivalent functionality is accessible in C++ via rtos::Kernel::get_ms_count.
48  */
49 uint64_t get_ms_count(void);
50 
51 /** Sleep for a specified time period in millisec:
52  @param millisec time delay value
53  @note You cannot call this function from ISR context.
54  @note The equivalent functionality is accessible in C++ via rtos::ThisThread::sleep_for.
55 */
56 void thread_sleep_for(uint32_t millisec);
57 
58 /** Sleep until a specified time in millisec
59  The specified time is according to Kernel::get_ms_count().
60  @param millisec absolute time in millisec
61  @note You cannot call this function from ISR context.
62  @note if millisec is equal to or lower than the current tick count, this
63  returns immediately.
64  @note The equivalent functionality is accessible in C++ via ThisThread::sleep_until.
65 */
66 void thread_sleep_until(uint64_t millisec);
67 
68 /** @}*/
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 
75 #endif //MBED_THREAD_H
uint64_t get_ms_count(void)
Generic thread functions.
void thread_sleep_for(uint32_t millisec)
Sleep for a specified time period in millisec:
void thread_sleep_until(uint64_t millisec)
Sleep until a specified time in millisec The specified time is according to Kernel::get_ms_count().
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.