-
Notifications
You must be signed in to change notification settings - Fork 3k
Use RTOS wait primitive where possible #6969
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,18 @@ | |
#include "platform/mbed_power_mgmt.h" | ||
|
||
void wait(float s) { | ||
wait_us(s * 1000000.0f); | ||
wait_ms(s * 1000.0f); | ||
} | ||
|
||
void wait_ms(int ms) { | ||
wait_us(ms * 1000); | ||
// Shouldn't be calling a wait function from a critical section, | ||
// but in case someone does... | ||
if (core_util_are_interrupts_enabled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait_us calls thread::wait (no busy wait), if the input is a multiple of 1000, which it is if the input is in milliseconds. So the behavior of your implementation is the same as in the current one besides that you are not surrounding it with sleep_manager_lock_deep_sleep - sleep_manager_unlock_deep_sleep. |
||
Thread::wait((uint32_t)ms); | ||
} else { | ||
wait_us(ms * 1000); | ||
} | ||
|
||
} | ||
|
||
void wait_us(int us) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks the interface of wait(float s) as you can no longer wait sub ms time deltas