mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: platform/mbed_wait_api_rtos.cpp
- Revision:
- 175:af195413fb11
- Parent:
- 160:d5399cc887bb
--- a/platform/mbed_wait_api_rtos.cpp Mon Oct 02 15:33:19 2017 +0100 +++ b/platform/mbed_wait_api_rtos.cpp Wed Oct 11 12:45:49 2017 +0100 @@ -22,6 +22,7 @@ #include "hal/us_ticker_api.h" #include "rtos/rtos.h" #include "platform/mbed_critical.h" +#include "platform/mbed_sleep.h" void wait(float s) { wait_us(s * 1000000.0f); @@ -32,15 +33,19 @@ } void wait_us(int us) { - uint32_t start = us_ticker_read(); + const ticker_data_t *const ticker = get_us_ticker_data(); + + uint32_t start = ticker_read(ticker); // Use the RTOS to wait for millisecond delays if possible int ms = us / 1000; if ((ms > 0) && core_util_are_interrupts_enabled()) { + sleep_manager_lock_deep_sleep(); Thread::wait((uint32_t)ms); + sleep_manager_unlock_deep_sleep(); } // Use busy waiting for sub-millisecond delays, or for the whole // interval if interrupts are not enabled - while ((us_ticker_read() - start) < (uint32_t)us); + while ((ticker_read(ticker) - start) < (uint32_t)us); } #endif // #if MBED_CONF_RTOS_PRESENT