Got TDMA synchronized TX tested
authorbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 23 Sep 2017 19:55:55 +0000 (19:55 +0000)
committerbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 23 Sep 2017 19:55:55 +0000 (19:55 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3376 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/tdma.c
codec2-dev/src/tdma.h

index 9c1061e3acd3f454ef6648f78682d17d14b04709..44f325d313f0eb9bf6789be70ed6aeadf9d670d0 100644 (file)
@@ -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
index 7b70f0be9062cad4af2473106b3033388d865087..287fc069942691caa0882e46def019f4a315d121 100644 (file)
@@ -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