Skip to content

wait_us: why need lock deep sleep? #6574

@woodsking2

Description

@woodsking2

Question

I saw the wait_us() in mbed_wait_api_rtos.cpp

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 ((ticker_read(ticker) - start) < (uint32_t)us);

Why need lock deep sleep?
@c1728p9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions