aboutsummaryrefslogtreecommitdiff
path: root/include/sys/semaphore.h
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-06-30 17:18:49 +0200
committerKarel Kočí <cynerd@email.cz>2016-06-30 17:18:49 +0200
commit4e1ce86af16307bf7d42657db07600867c7c4bbc (patch)
tree5d0dfddea221c91545a9bd57ac7face5842291d4 /include/sys/semaphore.h
parent147cb7f0e67d1f3c3274effa5476607e24664182 (diff)
downloadavr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.tar.gz
avr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.tar.bz2
avr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.zip
Add some more progress and split non-core functionality to separate repo
More progress to implementation and some changes in project it self. This library will implement only drivers for features on chip but nothing else. Everything connected externally is now in separate repository.
Diffstat (limited to 'include/sys/semaphore.h')
-rw-r--r--include/sys/semaphore.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/sys/semaphore.h b/include/sys/semaphore.h
new file mode 100644
index 0000000..0a25af3
--- /dev/null
+++ b/include/sys/semaphore.h
@@ -0,0 +1,31 @@
+#include <avr/io.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#ifndef _IOE_SYS_SEMAPHORE_H_
+#define _IOE_SYS_SEMAPHORE_H_
+#ifdef CONFIG_IOE_SEMAPHORE
+
+#define semaphore_t volatile struct Semaphore
+struct Semaphore {
+ uint8_t flags;
+ uint8_t _count;
+ Task **_tasks;
+ uint8_t _tasks_len;
+};
+int8_t semaphore_init(struct Semaphore * sem, uint8_t count);
+int8_t semaphore_free(struct Semaphore * sem);
+int8_t semaphore_take(struct Semaphore * sem, uint16_t timeout);
+int8_t semaphore_give(Semaphore * sem);
+
+#else /* CONFIG_IOE_SEMAPHORE */
+
+#define semaphore_t struct { }
+// TODO implement for single processor
+#define semaphore_init(SEM, FLAGS, COUNT)
+#define semaphore_free(SEM)
+#define semaphore_take(SEM, TIMEOUT)
+#define semaphore_give(SEM)
+
+#endif /* CONFIG_IOE_SEMAPHORE */
+#endif /* _IOE_SYS_SEMAPHORE_H_ */