From 14ac680fa0f88706be63cc681458c5dbd96c4599 Mon Sep 17 00:00:00 2001 From: baobrien Date: Sat, 23 Sep 2017 19:55:55 +0000 Subject: [PATCH] Got TDMA synchronized TX tested git-svn-id: https://svn.code.sf.net/p/freetel/code@3376 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/tdma.c | 14 ++++++++++++-- codec2-dev/src/tdma.h | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/codec2-dev/src/tdma.c b/codec2-dev/src/tdma.c index 9c1061e3..44f325d3 100644 --- a/codec2-dev/src/tdma.c +++ b/codec2-dev/src/tdma.c @@ -77,6 +77,8 @@ tdma_t * tdma_create(struct TDMA_MODE_SETTINGS mode){ tdma->sample_sync_offset = 960; tdma->slot_cur = 0; tdma->rx_callback = NULL; + tdma->tx_callback = NULL; + tdma->tx_burst_callback = NULL; /* Allocate buffer for incoming samples */ /* TODO: We may only need a single slot's worth of samps -- look into this */ @@ -168,7 +170,7 @@ u32 tdma_get_N(tdma_t * tdma){ } /* Convience function to look up a slot from it's index number */ -static slot_t * tdma_get_slot(tdma_t * tdma, u32 slot_idx){ +slot_t * tdma_get_slot(tdma_t * tdma, u32 slot_idx){ /* Don't try and index beyond the end */ if(slot_idx >= tdma->settings.n_slots) return NULL; @@ -247,7 +249,7 @@ void tdma_do_tx_frame(tdma_t * tdma, int slot_idx){ /* Send frame on to radio if callback is setup */ if(tdma->tx_burst_callback != NULL){ - tdma->tx_burst_callback(mod_samps,Ts*frame_size,tx_timestamp,tdma->tx_burst_cb_data); + tdma->tx_burst_callback(tdma,mod_samps,Ts*frame_size,tx_timestamp,tdma->tx_burst_cb_data); } } @@ -662,5 +664,13 @@ size_t tdma_nin(tdma_t * tdma){ return slot_samps; } +size_t tdma_nout(tdma_t * tdma){ + struct TDMA_MODE_SETTINGS mode = tdma->settings; + size_t frame_size = mode.frame_size; + u32 Rs = mode.sym_rate; + u32 Fs = mode.samp_rate; + u32 Ts = Fs/Rs; + return frame_size*Ts; +} #pragma GCC diagnostic pop diff --git a/codec2-dev/src/tdma.h b/codec2-dev/src/tdma.h index 7b70f0be..287fc069 100644 --- a/codec2-dev/src/tdma.h +++ b/codec2-dev/src/tdma.h @@ -122,7 +122,7 @@ typedef void (*tdma_cb_rx_frame)(u8* frame_bits,u32 slot_i, slot_t * slot, tdma_ typedef int (*tdma_cb_tx_frame)(u8* frame_bits,u32 slot_i, slot_t * slot, tdma_t * tdma, void * cb_data); /* Callback to the radio front end to schedule a burst of TX samples */ -typedef int (*tdma_cb_tx_burst)(COMP* samples, size_t n_samples,i64 timestamp,void * cb_data); +typedef int (*tdma_cb_tx_burst)(tdma_t * tdma,COMP* samples, size_t n_samples,i64 timestamp,void * cb_data); /* TDMA modem */ struct TDMA_MODEM { @@ -186,6 +186,10 @@ void tdma_stop_tx(tdma_t * tdma, int slot_idx); size_t tdma_nin(tdma_t * tdma); +size_t tdma_nout(tdma_t * tdma); + +/* Convience function to look up a slot from it's index number */ +slot_t * tdma_get_slot(tdma_t * tdma, u32 slot_idx); #endif -- 2.25.1