Skip to content
Snippets Groups Projects
Commit c9a840d2 authored by schneider's avatar schneider
Browse files

change(pycardium): Scale calls to epic_sleep based on systick interval

parent 08258739
No related branches found
No related tags found
1 merge request!480Pycardium: Use sleep API call while sleeping
...@@ -246,9 +246,18 @@ static void systick_delay(uint32_t us) ...@@ -246,9 +246,18 @@ static void systick_delay(uint32_t us)
while (final_time - systick_get_us() > SYSTICK_INTERVAL_US) { while (final_time - systick_get_us() > SYSTICK_INTERVAL_US) {
uint32_t sleep_time = uint32_t sleep_time =
(final_time - systick_get_us()) / 1000; (final_time - systick_get_us()) / 1000;
if (sleep_time > 100)
sleep_time = 100; /* We need to wake up at least in SYSTICK_INTERVAL_US to make
* sure we serve the systick interrupt.
* Add some error margin to avoid issues with the clock accuracy
* of epicardium */
if (sleep_time > SYSTICK_INTERVAL_US / 1000 / 2) {
sleep_time = SYSTICK_INTERVAL_US / 1000 / 2;
}
epic_sleep(sleep_time); epic_sleep(sleep_time);
/* epic_sleep() can return early if there was an interrupt
* coming from epicardium side.
* Give MP a chance to handle them. */
mp_handle_pending(true); mp_handle_pending(true);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment