2018-09-14 22:20:11 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
#include "zephyr/types.h"
|
|
|
|
#include "fake_timer.h"
|
|
|
|
#include "time_machine.h"
|
2019-10-24 23:08:21 +08:00
|
|
|
#include <arch/posix/posix_soc_if.h>
|
2018-09-14 22:20:11 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
|
|
|
|
/**
|
|
|
|
* Replacement to the kernel k_busy_wait()
|
|
|
|
* Will block this thread (and therefore the whole zephyr) during usec_to_wait
|
|
|
|
*
|
|
|
|
* Note that interrupts may be received in the meanwhile and that therefore this
|
2018-11-15 06:29:24 +08:00
|
|
|
* thread may lose context
|
2018-09-14 22:20:11 +08:00
|
|
|
*/
|
2020-05-28 00:26:57 +08:00
|
|
|
void arch_busy_wait(uint32_t usec_to_wait)
|
2018-09-14 22:20:11 +08:00
|
|
|
{
|
|
|
|
bs_time_t time_end = tm_get_hw_time() + usec_to_wait;
|
|
|
|
|
|
|
|
while (tm_get_hw_time() < time_end) {
|
|
|
|
/*There may be wakes due to other interrupts*/
|
|
|
|
fake_timer_wake_in_time(time_end);
|
|
|
|
posix_halt_cpu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|