about summary refs log tree commit diff stats
path: root/tools/iso/kernel.soso/sleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/iso/kernel.soso/sleep.c')
-rw-r--r--tools/iso/kernel.soso/sleep.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/iso/kernel.soso/sleep.c b/tools/iso/kernel.soso/sleep.c
new file mode 100644
index 00000000..bc769698
--- /dev/null
+++ b/tools/iso/kernel.soso/sleep.c
@@ -0,0 +1,16 @@
+#include "sleep.h"
+#include "timer.h"
+
+void sleepMilliseconds(Thread* thread, uint32 ms) {
+    uint32 uptime = getUptimeMilliseconds();
+
+    //target uptime to wakeup
+    uint32 target = uptime + ms;
+
+    thread->state = TS_SLEEP;
+    thread->state_privateData = (void*)target;
+
+    enableInterrupts();
+
+    halt();
+}