diff options
author | Robert Gustafsson <robg@student.chalmers.se> | 2017-09-28 13:41:45 +0200 |
---|---|---|
committer | Andreas Lindhé <andreas@lindhe.io> | 2017-10-09 12:14:35 +0200 |
commit | 2f5b120d90ce98676447df7fbf27397029d84ebd (patch) | |
tree | 3997b1cc0ba7ba94e53e6ddddbc5690982f26233 /includes | |
parent | a5cfcd3770e0860013bef2e2fdfe2ec4969bdab7 (diff) | |
download | midbro-2f5b120d90ce98676447df7fbf27397029d84ebd.tar.gz midbro-2f5b120d90ce98676447df7fbf27397029d84ebd.tar.bz2 |
Add basic fifoqueue to buffer events
Diffstat (limited to 'includes')
-rw-r--r-- | includes/fifoqueue.h | 15 | ||||
-rw-r--r-- | includes/types.h | 29 |
2 files changed, 44 insertions, 0 deletions
diff --git a/includes/fifoqueue.h b/includes/fifoqueue.h new file mode 100644 index 0000000..9ee5c53 --- /dev/null +++ b/includes/fifoqueue.h @@ -0,0 +1,15 @@ +#include <stdlib.h> +#include <stdio.h> +#include "types.h" + +Fifo_q * init_queue(int size); + +boolean is_full(Fifo_q * q); + +boolean is_empty(Fifo_q * q); + +int add_to_queue(Fifo_q * q, Sensor_t * sensor); + +Sensor_t * pop_from_queue(Fifo_q * q); + +void print_queue(Fifo_q * q); diff --git a/includes/types.h b/includes/types.h new file mode 100644 index 0000000..a8fa1cf --- /dev/null +++ b/includes/types.h @@ -0,0 +1,29 @@ +#ifndef TYPES_H +#define TYPES_H + +#define true 1 +#define false 0 + +typedef int boolean; +typedef struct sensor_t Sensor_t; +typedef struct queue_t Queue_t; +typedef struct fifo_q Fifo_q; + +struct sensor_t{ + int uid; + int value; +}; + +struct queue_t{ + Sensor_t * sensor; + Queue_t * next; +}; + +struct fifo_q{ + Queue_t * head; + Queue_t * tail; + int maxSize; + int currentSize; +}; + +#endif |