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