diff options
author | Uros Majstorovic <majstor@majstor.org> | 2019-12-07 17:18:37 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2019-12-07 17:18:37 +0100 |
commit | 256db0fba03232ab4ad9a151487677f8d538e69a (patch) | |
tree | 790e2e2c104b3fa6c56a15952923bdd4fa1dfb24 /code/fe310/eos/cell.c | |
parent | 2e6facf66ee3d6aa37f2fb41096b1763261506a7 (diff) |
addded uart driver and cell stub driver
Diffstat (limited to 'code/fe310/eos/cell.c')
-rw-r--r-- | code/fe310/eos/cell.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/code/fe310/eos/cell.c b/code/fe310/eos/cell.c new file mode 100644 index 0000000..b2d62f8 --- /dev/null +++ b/code/fe310/eos/cell.c @@ -0,0 +1,46 @@ +#include <stdlib.h> +#include <stdint.h> +#include <string.h> + +#include "eos.h" +#include "event.h" +#include "net.h" + +#include "cell.h" + +static eos_evt_fptr_t evt_handler[EOS_CELL_MAX_MTYPE]; +static uint16_t evt_handler_flags_buf_free = 0; +static uint16_t evt_handler_flags_buf_acq = 0; + +static void cell_handler_evt(unsigned char type, unsigned char *buffer, uint16_t len) { + if ((buffer == NULL) || (len < 1)) { + eos_evtq_bad_handler(type, buffer, len); + eos_net_free(buffer, 0); + return; + } + + uint8_t mtype = buffer[0]; + if (mtype >= EOS_CELL_MAX_MTYPE) { + eos_evtq_bad_handler(type, buffer, len); + eos_net_free(buffer, 0); + return; + } + + _eos_net_handle(type, buffer, len, mtype, evt_handler, &evt_handler_flags_buf_free, &evt_handler_flags_buf_acq); +} + +void eos_cell_init(void) { + int i; + + for (i=0; i<EOS_CELL_MAX_MTYPE; i++) { + evt_handler[i] = eos_evtq_bad_handler; + } + eos_net_set_handler(EOS_NET_MTYPE_CELL, cell_handler_evt, 0); +} + +void eos_cell_set_handler(int mtype, eos_evt_fptr_t handler, uint8_t flags) { + if (mtype >= EOS_CELL_MAX_MTYPE) { + return; + } + _eos_net_set_handler(mtype, handler, evt_handler, flags, &evt_handler_flags_buf_free, &evt_handler_flags_buf_acq); +} |