Skip to content

Commit

Permalink
Merge pull request #7584 from SenRamakri/sen_wait_us_Enhancement
Browse files Browse the repository at this point in the history
Minor enhancement to wait_us
  • Loading branch information
Cruz Monrreal authored Jul 26, 2018
2 parents b170e1c + 7cedccc commit c5680b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions platform/mbed_wait_api_rtos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ void wait_us(int us)
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()) {
if ((us >= 1000) && core_util_are_interrupts_enabled()) {
// Use the RTOS to wait for millisecond delays if possible
sleep_manager_lock_deep_sleep();
Thread::wait((uint32_t)ms);
Thread::wait((uint32_t)us / 1000);
sleep_manager_unlock_deep_sleep();
}
// Use busy waiting for sub-millisecond delays, or for the whole
Expand Down

0 comments on commit c5680b5

Please sign in to comment.