From a34dcb3a6b575106c2de388c499d4649e67d1a46 Mon Sep 17 00:00:00 2001 From: baobrien Date: Fri, 1 Sep 2017 01:21:54 +0000 Subject: [PATCH] More work on TDMA git-svn-id: https://svn.code.sf.net/p/freetel/code@3356 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/tdma.c | 38 ++++++++++++++++++++++++++++++++++++++ codec2-dev/src/tdma.h | 25 +++++++++++++++++++++---- 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 codec2-dev/src/tdma.c diff --git a/codec2-dev/src/tdma.c b/codec2-dev/src/tdma.c new file mode 100644 index 00000000..f03e20fa --- /dev/null +++ b/codec2-dev/src/tdma.c @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: tdma.c + AUTHOR......: Brady O'Brien + DATE CREATED: 18 September 2016 + + Skeletion of the TDMA FSK modem + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2017 Brady O'Brien + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + + +#include "fsk.h" +#include "freedv_vhf_framing.h" +#include "tdma.h" +#include + +/* Structure for tracking basic TDMA modem config */ +struct TDMA_MODE_SETTINGS { + uint8_t n_slots; + +} \ No newline at end of file diff --git a/codec2-dev/src/tdma.h b/codec2-dev/src/tdma.h index 96e837cf..69a8811f 100644 --- a/codec2-dev/src/tdma.h +++ b/codec2-dev/src/tdma.h @@ -30,6 +30,7 @@ #include "fsk.h" #include "freedv_vhf_framing.h" +#include //typedef void (*tdma_cb_rx_frame)() @@ -67,19 +68,35 @@ struct TDMA_FRAME { struct TDMA_SLOT { struct FSK * fsk; /* The FSK modem for this slot */ enum slot_state state; /* Current local slot state */ - int slot_local_frame_offset; /* Where the RX frame starts, in samples, from the perspective of the modem */ + uint32_t slot_local_frame_offset; /* Where the RX frame starts, in samples, from the perspective of the modem */ struct TDMA_SLOT * next_slot; /* Next slot in a linked list of slots */ }; +/* Structure for tracking basic TDMA modem config */ +struct TDMA_MODE_SETTINGS { + uint32_t bit_rate; /* Modem bitrate */ + uint32_t samp_rate; /* Modem samplerate */ + uint32_t slot_size; /* Number of bits per slot, including quiet padding time */ + uint8_t n_slots; /* Number of TDMA slots */ + uint8_t frame_type; /* Frame type number for framer/deframer */ +} + +/* Declaration of basic 4800bps freedv tdma mode, defined in tdma.h */ +struct TDMA_MODE_SETTINGS FREEDV_4800T; + /* TDMA modem */ struct TDMA_MODEM { struct FSK * fsk_pilot; /* Pilot modem */ enum tdma_state state; /* Current state of modem */ struct TDMA_SLOT * slots; /* Linked list of slot structs */ - - int total_slot_count; - + struct TDMA_MODE_SETTINGS settings; /* Basic TDMA config parameters */ + float * sample_buffer; /* Buffer of incoming samples */ + size_t sample_sync_offset; /* Offset into the sample buffer where slot 1 starts */ }; +/* Allocate and setup a new TDMA modem */ +struct TDMA_MODEM * tdma_create(struct TDMA_MODE_SETTINGS mode); + +void tdma_destroy(struct TDMA_MODEM * tdma); #endif -- 2.25.1