Mistake on this page?
Report an issue in GitHub or email us
mbed_wait_api.h
1 
2 /** \addtogroup platform */
3 /** @{*/
4 /**
5  * \defgroup platform_wait_api wait_api functions
6  * @{
7  */
8 
9 /* mbed Microcontroller Library
10  * Copyright (c) 2006-2013 ARM Limited
11  * SPDX-License-Identifier: Apache-2.0
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  */
25 #ifndef MBED_WAIT_API_H
26 #define MBED_WAIT_API_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** Generic wait functions.
33  *
34  * These provide simple NOP type wait capabilities.
35  *
36  * Example:
37  * @code
38  * #include "mbed.h"
39  *
40  * DigitalOut heartbeat(LED1);
41  *
42  * int main() {
43  * while (1) {
44  * heartbeat = 1;
45  * wait(0.5);
46  * heartbeat = 0;
47  * wait(0.5);
48  * }
49  * }
50  * @endcode
51  */
52 
53 /** Waits for a number of seconds, with microsecond resolution (within
54  * the accuracy of single precision floating point).
55  *
56  * @param s number of seconds to wait
57  *
58  * @note
59  * If the RTOS is present, this function spins to get the exact number of microseconds for
60  * microsecond precision up to 10 milliseconds. If delay is larger than 10 milliseconds and not in ISR, it is the same as
61  * `wait_ms`. We recommend `wait_us` and `wait_ms` over `wait`.
62  */
63 void wait(float s);
64 
65 /** Waits a number of milliseconds.
66  *
67  * @param ms the whole number of milliseconds to wait
68  *
69  * @note
70  * If the RTOS is present, it calls ThisThread::sleep_for(), which is same as CMSIS osDelay().
71  * You can't call this from interrupts, and it doesn't lock hardware sleep.
72  */
73 void wait_ms(int ms);
74 
75 /** Waits a number of microseconds.
76  *
77  * @param us the whole number of microseconds to wait
78  *
79  * @note
80  * This function always spins to get the exact number of microseconds.
81  * If RTOS is present, this will affect power (by preventing deep sleep) and
82  * multithread performance. Therefore, spinning for millisecond wait is not recommended.
83  */
84 void wait_us(int us);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
91 
92 /** @}*/
93 /** @}*/
void wait_us(int us)
Waits a number of microseconds.
void wait_ms(int ms)
Waits a number of milliseconds.
void wait(float s)
Generic wait functions.
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.