From c5dad05775feb34501e4c61eead0483d1929bbb4 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 1 Jun 2020 13:05:09 +0200 Subject: [PATCH] Fixed FIFO16 buffer and inits --- device.h | 6 +++--- protocol/KISS.c | 9 +++++---- util/FIFO.h | 2 +- util/FIFO16.h | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/device.h b/device.h index 049ad88..6c34ec1 100755 --- a/device.h +++ b/device.h @@ -5,7 +5,7 @@ // Version info #define MAJ_VERSION 0x01 -#define MIN_VERSION 0x01 +#define MIN_VERSION 0x02 // CPU settings #define TARGET_CPU m1284p @@ -26,8 +26,8 @@ // Serial settings #define SERIAL_DEBUG false #define TX_MAXWAIT 2UL -#define CONFIG_QUEUE_SIZE 6000 -#define CONFIG_QUEUE_MAX_LENGTH 15 +#define CONFIG_QUEUE_SIZE 5760 +#define CONFIG_QUEUE_MAX_LENGTH 32 #define CONFIG_UART0_BUFFER_SIZE 1536 #define CONFIG_UART1_BUFFER_SIZE 128 #define CONFIG_SERIAL_TIMEOUT_MS 10 diff --git a/protocol/KISS.c b/protocol/KISS.c index 853de2d..c8e2310 100755 --- a/protocol/KISS.c +++ b/protocol/KISS.c @@ -52,11 +52,12 @@ void kiss_init(AX25Ctx *ax25, Afsk *afsk, Serial *ser) { channel = afsk; memset(packet_queue, 0, sizeof(packet_queue)); - memset(packet_starts_buf, 0, sizeof(packet_starts)); - memset(packet_lengths_buf, 0, sizeof(packet_lengths)); - fifo16_init(&packet_starts, packet_starts_buf, sizeof(packet_starts_buf)); - fifo16_init(&packet_lengths, packet_lengths_buf, sizeof(packet_lengths_buf)); + memset(packet_starts_buf, 0, sizeof(packet_starts)); + fifo16_init(&packet_starts, packet_starts_buf, CONFIG_QUEUE_MAX_LENGTH); + + memset(packet_lengths_buf, 0, sizeof(packet_lengths)); + fifo16_init(&packet_lengths, packet_lengths_buf, CONFIG_QUEUE_MAX_LENGTH); } void kiss_poll(void) { diff --git a/util/FIFO.h b/util/FIFO.h index ee1abf8..4849986 100755 --- a/util/FIFO.h +++ b/util/FIFO.h @@ -75,7 +75,7 @@ static inline unsigned char fifo_pop_locked(FIFOBuffer *f) { inline void fifo_init(FIFOBuffer *f, unsigned char *buffer, size_t size) { f->head = f->tail = f->begin = buffer; - f->end = buffer + size -1; + f->end = buffer + size; } inline size_t fifo_len(FIFOBuffer *f) { diff --git a/util/FIFO16.h b/util/FIFO16.h index 3c1c5f7..b60eecc 100644 --- a/util/FIFO16.h +++ b/util/FIFO16.h @@ -77,11 +77,11 @@ static inline size_t fifo16_pop_locked(FIFOBuffer16 *f) { inline void fifo16_init(FIFOBuffer16 *f, size_t *buffer, size_t size) { f->head = f->tail = f->begin = buffer; - f->end = buffer + (size/sizeof(size_t)) - 2; + f->end = buffer + size; } inline size_t fifo16_len(FIFOBuffer16 *f) { - return ((f->end - f->begin))/sizeof(size_t); + return (f->end - f->begin); } #endif