[Cryptech-Commits] [sw/stm32] 05/05: Add task_delay.
git at cryptech.is
git at cryptech.is
Sat Apr 29 19:55:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch no-rtos
in repository sw/stm32.
commit e234cacf79a496d20a113d1141e7607089fc6e8e
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Sat Apr 29 15:44:30 2017 -0400
Add task_delay.
---
task.c | 10 ++++++++++
task.h | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/task.c b/task.c
index 980ca1d..600b679 100644
--- a/task.c
+++ b/task.c
@@ -316,3 +316,13 @@ tcb_t *task_iterate(tcb_t *t)
return t->next;
}
+
+/* Delay a number of 1ms ticks.
+ */
+void task_delay(uint32_t delay)
+{
+ uint32_t tickstart = HAL_GetTick();
+
+ while ((HAL_GetTick() - tickstart) < delay)
+ task_yield();
+}
diff --git a/task.h b/task.h
index ee0dc61..9178c2d 100644
--- a/task.h
+++ b/task.h
@@ -49,6 +49,8 @@ typedef void (*funcp_t)(void);
extern tcb_t *task_add(char *name, funcp_t func, void *cookie, void *stack, size_t stack_len);
+extern void task_set_idle_hook(funcp_t func);
+
extern void task_yield(void);
extern void task_sleep(void);
extern void task_wake(tcb_t *t);
@@ -63,6 +65,6 @@ extern size_t task_get_stack_highwater(tcb_t *t);
extern tcb_t *task_iterate(tcb_t *t);
-extern void task_set_idle_hook(funcp_t func);
+extern void task_delay(uint32_t delay);
#endif /* _TASK_H_ */
More information about the Commits
mailing list