mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

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