diff options
author | Karel Kočí <cynerd@email.cz> | 2016-06-30 17:18:49 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2016-06-30 17:18:49 +0200 |
commit | 4e1ce86af16307bf7d42657db07600867c7c4bbc (patch) | |
tree | 5d0dfddea221c91545a9bd57ac7face5842291d4 /include/sys/mutex.h | |
parent | 147cb7f0e67d1f3c3274effa5476607e24664182 (diff) | |
download | avr-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/mutex.h')
-rw-r--r-- | include/sys/mutex.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/sys/mutex.h b/include/sys/mutex.h new file mode 100644 index 0000000..f682e02 --- /dev/null +++ b/include/sys/mutex.h @@ -0,0 +1,32 @@ +#include <avr/io.h> +#include <stdint.h> +#include <stdlib.h> + +#include "../tasks.h" + +#ifndef _IOE_SYS_MUTEX_H_ +#define _IOE_SYS_MUTEX_H_ +#ifdef CONFIG_IOE_MUTEX + +#define MUTEX_F_TIMED (1<<0) +#define MUTEX_F_TAKEN (1<<7) +#define mutex_t volatile struct Mutex +struct Mutex { + uint8_t flags; + Task *_task_took; +}; +int8_t mutex_init(struct Mutex * mtx); +int8_t mutex_free(struct Mutex * mtx); +int8_t mutex_take(struct Mutex * mtx, uint16_t timeout); +int8_t mutex_give(struct Mutex * mtx); + +#else /* CONFIG_IOE_MUTEX */ + +#define mutex_t struct { } +#define mutex_init(MTX, FLAGS) +#define mutex_free(MTX) +#define mutex_take(MTX, TIMEOUT) +#define mutex_give(MTX); + +#endif /* CONFIG_IOE_MUTEX */ +#endif /* _IOE_SYS_MUTEX_H_ */ |