Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
salasidis opened this issue Jan 7, 2023 · 0 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@salasidis
Copy link

salasidis commented Jan 7, 2023

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).

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Feb 14, 2024
@per1234 per1234 changed the title Delay in _sleep_response_timeout() Use rtos::ThisThread::sleep_for as delay in _sleep_response_timeout() for Mbed OS boards Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants