aboutsummaryrefslogtreecommitdiff
path: root/include/sys/mutex.h
blob: f682e020d9f44cb7c840be761b7ae5e43a9716d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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_ */