mbed library sources. Supersedes mbed-src.

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

Embed: (wiki syntax)

« Back to documentation index

wait_api functions

wait_api functions
[Platform]

Functions

void wait (float s)
 Generic wait functions.
void wait_ms (int ms)
 Waits a number of milliseconds.
void wait_us (int us)
 Waits a number of microseconds.

Function Documentation

void wait ( float  s )

Generic wait functions.

These provide simple NOP type wait capabilities.

Example:

 #include "mbed.h"

 DigitalOut heartbeat(LED1);

 int main() {
     while (1) {
         heartbeat = 1;
         wait(0.5);
         heartbeat = 0;
         wait(0.5);
     }
 }

Waits for a number of seconds, with microsecond resolution (within the accuracy of single precision floating point).

Parameters:
snumber of seconds to wait
Note:
If the RTOS is present, this function spins to get the exact number of microseconds for microsecond precision up to 10 milliseconds. If delay is larger than 10 milliseconds and not in ISR, it is the same as `wait_ms`. We recommend `wait_us` and `wait_ms` over `wait`.

Definition at line 25 of file mbed_wait_api_no_rtos.c.

void wait_ms ( int  ms )

Waits a number of milliseconds.

Parameters:
msthe whole number of milliseconds to wait
Note:
If the RTOS is present, it calls ThisThread::sleep_for(), which is same as CMSIS osDelay(). You can't call this from interrupts, and it doesn't lock hardware sleep.

Definition at line 30 of file mbed_wait_api_no_rtos.c.

void wait_us ( int  us )

Waits a number of microseconds.

Parameters:
usthe whole number of microseconds to wait
Note:
This function always spins to get the exact number of microseconds. If RTOS is present, this will affect power (by preventing deep sleep) and multithread performance. Therefore, spinning for millisecond wait is not recommended.

Definition at line 35 of file mbed_wait_api_no_rtos.c.