summaryrefslogtreecommitdiff
path: root/common/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/timer.c')
-rw-r--r--common/timer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/timer.c b/common/timer.c
index b4c31360b6..6a210ee9da 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -6,6 +6,7 @@
/* Timer module for Chrome EC operating system */
#include "atomic.h"
+#include "common.h"
#include "console.h"
#include "hooks.h"
#include "hwtimer.h"
@@ -15,6 +16,13 @@
#include "timer.h"
#include "watchdog.h"
+#ifdef CONFIG_ZEPHYR
+#include <kernel.h> /* For k_usleep() */
+#else
+extern __error("k_usleep() should only be called from Zephyr code")
+int32_t k_usleep(int32_t);
+#endif /* CONFIG_ZEPHYR */
+
#define TIMER_SYSJUMP_TAG 0x4d54 /* "TM" */
/* High 32-bits of the 64-bit timestamp counter. */
@@ -154,7 +162,15 @@ void timer_cancel(task_id_t tskid)
void usleep(unsigned us)
{
uint32_t evt = 0;
- uint32_t t0 = __hw_clock_source_read();
+ uint32_t t0;
+
+ if (IS_ENABLED(CONFIG_ZEPHYR)) {
+ while (us)
+ us = k_usleep(us);
+ return;
+ }
+
+ t0 = __hw_clock_source_read();
/* If task scheduling has not started, just delay */
if (!task_start_called()) {