Rework lock_core / timers (#378)

- Add recursive_mutex
  - Make all locking primitives and sleep use common overridable wait/notify support to allow RTOS
    implementations to replace WFE/SEV with something more appropriate
  - Add busy_wait_ms
This commit is contained in:
Graham Sanderson
2021-05-05 11:46:25 -05:00
committed by GitHub
parent ec0dc7a88b
commit 6d87da4c59
15 changed files with 434 additions and 152 deletions

View File

@ -73,6 +73,15 @@ void busy_wait_us(uint64_t delay_us) {
busy_wait_until(t);
}
void busy_wait_ms(uint32_t delay_ms)
{
if (delay_ms <= 0x7fffffffu / 1000) {
busy_wait_us_32(delay_ms * 1000);
} else {
busy_wait_us(delay_ms * 1000ull);
}
}
void busy_wait_until(absolute_time_t t) {
uint64_t target = to_us_since_boot(t);
uint32_t hi_target = (uint32_t)(target >> 32u);