aboutsummaryrefslogtreecommitdiff
path: root/task.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-04-29 23:24:37 -0400
committerPaul Selkirk <paul@psgd.org>2017-04-29 23:24:37 -0400
commit73b784eac101085b8734d2188ae59b5295a80839 (patch)
treebe0fc88813aaf5c7c8198e2ab35caa7748897a02 /task.c
parente0e97a5217bbb2a198d23ac632de97b4ebe0e44a (diff)
Add minimal mutexes to the minimal tasking system
Diffstat (limited to 'task.c')
-rw-r--r--task.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/task.c b/task.c
index 600b679..bc6eded 100644
--- a/task.c
+++ b/task.c
@@ -326,3 +326,16 @@ void task_delay(uint32_t delay)
while ((HAL_GetTick() - tickstart) < delay)
task_yield();
}
+
+void task_mutex_lock(task_mutex_t *mutex)
+{
+ while (mutex->locked)
+ task_yield();
+ mutex->locked = 1;
+}
+
+void task_mutex_unlock(task_mutex_t *mutex)
+{
+ if (mutex != NULL)
+ mutex->locked = 0;
+}