From 2e6facf66ee3d6aa37f2fb41096b1763261506a7 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sat, 7 Dec 2019 17:17:21 +0100 Subject: eos evtq flags refactor; net buf flags refator for all modules --- code/fe310/eos/sock.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'code/fe310/eos/sock.c') diff --git a/code/fe310/eos/sock.c b/code/fe310/eos/sock.c index 2c6ba5d..077c93d 100644 --- a/code/fe310/eos/sock.c +++ b/code/fe310/eos/sock.c @@ -8,9 +8,9 @@ #include "sock.h" -static eos_sock_fptr_t sock_handler[EOS_SOCK_MAX_SOCK]; -static uint16_t sock_handler_flags_buf_free = 0; -static uint16_t sock_handler_flags_buf_acq = 0; +static eos_evt_fptr_t evt_handler[EOS_SOCK_MAX_SOCK]; +static uint16_t evt_handler_flags_buf_free = 0; +static uint16_t evt_handler_flags_buf_acq = 0; static void sock_handler_evt(unsigned char type, unsigned char *buffer, uint16_t len) { if ((buffer == NULL) || (len < 2)) { @@ -28,24 +28,28 @@ static void sock_handler_evt(unsigned char type, unsigned char *buffer, uint16_t eos_net_free(buffer, 0); return; } - uint16_t buf_free = ((uint16_t)1 << sock) & sock_handler_flags_buf_free; - uint16_t buf_acq = ((uint16_t)1 << sock) & sock_handler_flags_buf_acq; - if (buf_free) { - eos_net_free(buffer, buf_acq); - buffer = NULL; - len = 0; - } - - sock_handler[sock](buffer, len); - - if (buf_free && buf_acq) eos_net_release(); + _eos_net_handle(type, buffer, len, sock, evt_handler, &evt_handler_flags_buf_free, &evt_handler_flags_buf_acq); } } void eos_sock_init(void) { + int i; + + for (i=0; i