From cf7c06297d04bade9cd04c056f9ed510e64dd7bd Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 5 Aug 2020 03:39:22 +0200 Subject: code -> fw --- fw/fe310/eos/event.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 fw/fe310/eos/event.c (limited to 'fw/fe310/eos/event.c') diff --git a/fw/fe310/eos/event.c b/fw/fe310/eos/event.c new file mode 100644 index 0000000..6953dca --- /dev/null +++ b/fw/fe310/eos/event.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include + +#include "encoding.h" +#include "platform.h" + +#include "msgq.h" +#include "event.h" + +EOSMsgQ _eos_event_q; +static EOSMsgItem event_q_array[EOS_EVT_SIZE_Q]; + +static eos_evt_handler_t evt_handler[EOS_EVT_MAX_EVT + 1]; + +static void evtq_handler(unsigned char type, unsigned char *buffer, uint16_t len) { + unsigned char idx = (type & EOS_EVT_MASK) >> 4; + + if (idx && (idx <= EOS_EVT_MAX_EVT)) { + evt_handler[idx](type, buffer, len); + } else { + eos_evtq_bad_handler(type, buffer, len); + } +} + +void eos_evtq_init(void) { + int i; + + evt_handler[0] = evtq_handler; + for (i=0; i> 4; + + if (idx <= EOS_EVT_MAX_EVT) evt_handler[idx] = handler; +} + +eos_evt_handler_t eos_evtq_get_handler(unsigned char type) { + unsigned char idx = (type & EOS_EVT_MASK) >> 4; + + if (idx <= EOS_EVT_MAX_EVT) return evt_handler[idx]; + return NULL; +} -- cgit v1.2.3