Skip to content

Use rtos::ThisThread::sleep_for as delay in _sleep_response_timeout() for Mbed OS boards #107

Open
@salasidis

Description

@salasidis

The code currently present is as follows

#elif defined(_MBED) - or ir could reference actual boards PORTENTA_H7 etc
    delay(ctx->response_timeout.tv_sec * 1000);
    delayMicroseconds(ctx->response_timeout.tv_usec);
#else

I would like if possible to add an #ifdef _MBED (as used by Portenta and others)

In there the delay can be changed to:

rtos::ThisThread::sleep_for(mbed::chrono::milliseconds_u32(sec * 1000));
rtos::ThisThread::sleep_for(mbed::chrono::milliseconds_u32(usec / 1000));
delayMicroseconds(usec % 1000);

This way delays are task switch implemented - not wasting CPU time, The sub ms delay will be done in the usal Arduino way, as MBed does not allow sub ms sleep intervals (ticker res 1mS).

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions