summaryrefslogtreecommitdiff
path: root/code/esp32/components/eos/msgq.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2019-12-04 06:12:15 +0100
committerUros Majstorovic <majstor@majstor.org>2019-12-04 06:12:15 +0100
commit4c28fb525edc64fa16c6c3bf10929dca65d9c77c (patch)
tree2531b3bcc2d06c655f6eb9a6233696f5eadfa089 /code/esp32/components/eos/msgq.c
parent31578e285a21a749a49e3ac146feb8b02fcc7b52 (diff)
esp32 refactoring
Diffstat (limited to 'code/esp32/components/eos/msgq.c')
-rw-r--r--code/esp32/components/eos/msgq.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/code/esp32/components/eos/msgq.c b/code/esp32/components/eos/msgq.c
index 0160bf5..6fda261 100644
--- a/code/esp32/components/eos/msgq.c
+++ b/code/esp32/components/eos/msgq.c
@@ -1,5 +1,4 @@
-#include <stddef.h>
-#include <string.h>
+#include <stdlib.h>
#include "eos.h"
#include "msgq.h"
@@ -13,26 +12,28 @@ void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size) {
msgq->size = size;
}
-int eos_msgq_push(EOSMsgQ *msgq, unsigned char cmd, unsigned char *buffer, uint16_t len) {
+int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, unsigned char *buffer, uint16_t len, uint8_t flags) {
if ((uint8_t)(msgq->idx_w - msgq->idx_r) == msgq->size) return EOS_ERR_Q_FULL;
uint8_t idx = EOS_MSGQ_IDX_MASK(msgq->idx_w, msgq->size);
- msgq->array[idx].cmd = cmd;
- memcpy(msgq->array[idx].buffer, buffer, len);
+ msgq->array[idx].type = type;
+ msgq->array[idx].buffer = buffer;
msgq->array[idx].len = len;
+ msgq->array[idx].flags = flags;
msgq->idx_w++;
return EOS_OK;
}
-void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *cmd, unsigned char **buffer, uint16_t *len) {
+void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, uint16_t *len, uint8_t *flags) {
if (msgq->idx_r == msgq->idx_w) {
- *cmd = 0;
+ *type = 0;
*buffer = NULL;
} else {
uint8_t idx = EOS_MSGQ_IDX_MASK(msgq->idx_r, msgq->size);
- *cmd = msgq->array[idx].cmd;
+ *type = msgq->array[idx].type;
*buffer = msgq->array[idx].buffer;
*len = msgq->array[idx].len;
+ *flags = msgq->array[idx].flags;
msgq->idx_r++;
}
}