]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fixed tune problem. Started adding code for LimeSDR (unused)
authorJohn Melton g0orx/n6lyt <john.d.melton@googlemail.com>
Tue, 10 May 2016 11:35:41 +0000 (11:35 +0000)
committerJohn Melton g0orx/n6lyt <john.d.melton@googlemail.com>
Tue, 10 May 2016 11:35:41 +0000 (11:35 +0000)
14 files changed:
Makefile
band.c
band.h
discovered.h
lime_discovery.c [new file with mode: 0644]
lime_discovery.h [new file with mode: 0644]
main.c
old_protocol.c
pihpsdr
radio.c
release/pihpsdr.tar
release/pihpsdr/libSoapySDR.so [new file with mode: 0755]
release/pihpsdr/pihpsdr
wdsp_init.c

index 4b824fcc96c932f90cf2d6171a3921446683dcfc..952b62142ca45a9511a62ed29ba2b50e2ed74591 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,24 +1,35 @@
 UNAME_N := $(shell uname -n)
-
 CC=gcc
 LINK=gcc
-OPTIONS=-g -D $(UNAME_N) -O3
+
+#required for LimeSDR (uncomment lines below)
+#LIMESDR_OPTIONS=-D LIMESDR
+#SOAPYSDRLIBS=-lSoapySDR
+#LIMESDR_SOURCES= \
+#lime_discovery.c
+#LIMESDR_HEADERS= \
+#lime_discovery.h
+#LIMESDR_OBJS= \
+#lime_discovery.o
+
+OPTIONS=-g -D $(UNAME_N) $(LIMESDR_OPTIONS) -O3
 GTKINCLUDES=`pkg-config --cflags gtk+-3.0`
 GTKLIBS=`pkg-config --libs gtk+-3.0`
+
+
 ifeq ($(UNAME_N),raspberrypi)
-GPIO_LIBS=-lwiringPi -lpigpio
+GPIOLIBS=-lwiringPi -lpigpio
 endif
 ifeq ($(UNAME_N),odroid)
-GPIO_LIBS=-lwiringPi
+GPIOLIBS=-lwiringPi
 endif
-LIBS=-lrt -lm -lwdsp -lpthread $(GTKLIBS)
+LIBS=-lrt -lm -lwdsp -lpthread $(GTKLIBS) $(GPIOLIBS) $(SOAPYSDRLIBS)
 INCLUDES=$(GTKINCLUDES)
 
 COMPILE=$(CC) $(OPTIONS) $(INCLUDES)
 
 PROGRAM=pihpsdr
 
-
 SOURCES= \
 band.c \
 frequency.c \
@@ -45,6 +56,7 @@ vfo.c \
 waterfall.c \
 wdsp_init.c
 
+
 HEADERS= \
 agc.h \
 alex.h \
@@ -74,6 +86,7 @@ waterfall.h \
 wdsp_init.h \
 xvtr.h
 
+
 OBJS= \
 band.o \
 frequency.o \
@@ -100,13 +113,13 @@ vfo.o \
 waterfall.o \
 wdsp_init.o
 
-all: prebuild $(PROGRAM) $(HEADERS) $(SOURCES)
+all: prebuild $(PROGRAM) $(HEADERS) $(LIMESDR_HEADERS) $(SOURCES) $(LIMESDR_SOURCES)
 
 prebuild:
        rm -f version.o
 
-$(PROGRAM): $(OBJS)
-       $(LINK) -o $(PROGRAM) $(OBJS) $(GPIO_LIBS) $(LIBS)
+$(PROGRAM): $(OBJS) $(LIMESDR_OBJS)
+       $(LINK) -o $(PROGRAM) $(OBJS) $(LIMESDR_OBJS) $(LIBS)
 
 .c.o:
        $(COMPILE) -c -o $@ $<
diff --git a/band.c b/band.c
index d50da614cc2a3ea853313ae13f40ca213121bb7a..daf9569b492cac4d8a4c1d3fcf8639780f1eb5f6 100644 (file)
--- a/band.c
+++ b/band.c
@@ -27,6 +27,8 @@
 #include "alex.h"
 #include "property.h"
 
+#define LINESDR
+
 int band=band20;
 int xvtr_band=band160;
 
@@ -92,6 +94,48 @@ BANDSTACK_ENTRY bandstack_entries50[] =
      {50125000LL,modeUSB,filterF5,200,2800,200,2800},
      {50200000LL,modeUSB,filterF5,200,2800,200,2800}};
 
+#ifdef LIMESDR
+BANDSTACK_ENTRY bandstack_entries70[] =
+    {{70010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {70200000LL,modeUSB,filterF5,200,2800,200,2800},
+     {70250000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries144[] =
+    {{144010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {144200000LL,modeUSB,filterF5,200,2800,200,2800},
+     {144250000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries220[] =
+    {{220010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {220200000LL,modeUSB,filterF5,200,2800,200,2800},
+     {220250000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries430[] =
+    {{430010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {432100000LL,modeUSB,filterF5,200,2800,200,2800},
+     {432300000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries902[] =
+    {{902010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {902100000LL,modeUSB,filterF5,200,2800,200,2800},
+     {902300000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries1240[] =
+    {{1240010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {1240100000LL,modeUSB,filterF5,200,2800,200,2800},
+     {1240300000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries2300[] =
+    {{2300010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {2300100000LL,modeUSB,filterF5,200,2800,200,2800},
+     {2300300000LL,modeUSB,filterF5,200,2800,200,2800}};
+
+BANDSTACK_ENTRY bandstack_entries3400[] =
+    {{3400010000LL,modeCWU,filterF0,200,2800,200,2800},
+     {3400100000LL,modeUSB,filterF5,200,2800,200,2800},
+     {3400300000LL,modeUSB,filterF5,200,2800,200,2800}};
+#endif
+
 BANDSTACK_ENTRY bandstack_entriesGEN[] =
     {{909000LL,modeAM,filterF6,-6000,6000,-6000,60000},
      {5975000LL,modeAM,filterF6,-6000,6000,-6000,60000},
@@ -115,6 +159,16 @@ BANDSTACK bandstack15={3,1,bandstack_entries15};
 BANDSTACK bandstack12={3,1,bandstack_entries12};
 BANDSTACK bandstack10={3,1,bandstack_entries10};
 BANDSTACK bandstack50={3,1,bandstack_entries50};
+#ifdef LIMESDR
+BANDSTACK bandstack70={3,1,bandstack_entries70};
+BANDSTACK bandstack144={3,1,bandstack_entries144};
+BANDSTACK bandstack220={3,1,bandstack_entries220};
+BANDSTACK bandstack430={3,1,bandstack_entries430};
+BANDSTACK bandstack902={3,1,bandstack_entries902};
+BANDSTACK bandstack1240={3,1,bandstack_entries1240};
+BANDSTACK bandstack2300={3,1,bandstack_entries2300};
+BANDSTACK bandstack3400={3,1,bandstack_entries3400};
+#endif
 BANDSTACK bandstackGEN={3,1,bandstack_entriesGEN};
 BANDSTACK bandstackWWV={5,1,bandstack_entriesWWV};
 
@@ -130,6 +184,16 @@ BAND bands[BANDS] =
      {"12",&bandstack12,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
      {"10",&bandstack10,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
      {"50",&bandstack50,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+#ifdef LIMESDR
+     {"70",&bandstack70,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"144",&bandstack144,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"220",&bandstack144,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"430",&bandstack430,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"902",&bandstack430,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"1240",&bandstack1240,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"2300",&bandstack2300,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+     {"3400",&bandstack3400,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,30},
+#endif
      {"GEN",&bandstackGEN,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,0},
      {"WWV",&bandstackWWV,0,0,0,ALEX_RX_ANTENNA_NONE,ALEX_TX_ANTENNA_1,ALEX_ATTENUATION_0dB,0}};
 
@@ -153,7 +217,7 @@ BAND_LIMITS bandLimits[NUM_BAND_LIMITS] = {
     {902000000LL,928000000LL},
     {1240000000LL,1300000000LL},
     {2300000000LL,2450000000LL},
-    {3456000000LL,3456400000LL},
+    {3400000000LL,3410000000LL},
     {5760000000LL,5760400000LL},
     {10368000000LL,10368400000LL},
     {24192000000LL,24192400000LL},
diff --git a/band.h b/band.h
index ec5037db17ae5d2c86f46565b2b9723a8beae854..61e61ae950a808d916612324a105f15779e6acf0 100644 (file)
--- a/band.h
+++ b/band.h
 #define band12 8
 #define band10 9
 #define band6 10
+#ifdef LIMESDR
+#define band70 11
+#define band144 12
+#define band220 13
+#define band430 14
+#define band902 15
+#define band1240 16
+#define band2300 17
+#define band3400 18
+#define bandGen 19
+#define bandWWV 20
+#define BANDS 21
+#define HAM_BANDS 19
+#else
 #define bandGen 11
 #define bandWWV 12
-
 #define BANDS 13
 #define HAM_BANDS 11
+#endif
 
 /* --------------------------------------------------------------------------*/
 /**
index 429b5236815e3c119be641b2a726f4ab66aaeffe..110561e456f8e388b7ef4308006f37bc87ea09f3 100644 (file)
@@ -41,6 +41,7 @@
 
 #define ORIGINAL_PROTOCOL 0
 #define NEW_PROTOCOL 1
+#define LIME_SDR 2
 
 struct _DISCOVERED {
     int protocol;
diff --git a/lime_discovery.c b/lime_discovery.c
new file mode 100644 (file)
index 0000000..9414208
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <SoapySDR/Device.h>
+#include "lime_discovery.h"
+
+void lime_discovery() {
+  SoapySDRKwargs args;
+  size_t length;
+  int i;
+  args.size=0;
+  SoapySDRKwargs *devices=SoapySDRDevice_enumerate(&args, &length);
+
+fprintf(stderr,"lime_discovery: length=%d devices->size=%d\n",length,devices->size);
+
+  for(i=0;i<length;i++) {
+fprintf(stderr,"lime_discovery: key=%s val=%s\n",devices->keys[i], devices->vals[i]);
+  }
+
+  fprintf(stderr,"lime_discovery found %d devices\n",length);
+}
diff --git a/lime_discovery.h b/lime_discovery.h
new file mode 100644 (file)
index 0000000..999944e
--- /dev/null
@@ -0,0 +1 @@
+void lime_discovery();
diff --git a/main.c b/main.c
index db3d11699ceedf54bc2b037b3e97045a209482c6..b7e64ebef8e564eb991849edfbe97b5919f4a630 100644 (file)
--- a/main.c
+++ b/main.c
@@ -33,6 +33,7 @@
 #include "gpio.h"
 #include "old_discovery.h"
 #include "new_discovery.h"
+#include "lime_discovery.h"
 #include "new_protocol.h"
 #include "wdsp.h"
 #include "vfo.h"
@@ -731,6 +732,10 @@ gint init(void* arg) {
       old_discovery();
       splash_status("New Protocol ... Discovering Devices");
       new_discovery();
+#ifdef LIMESDR
+      splash_status("LimeSDR ... Discovering Devices");
+      lime_discovery();
+#endif
       splash_status("Discovery");
       if(devices==0) {
           gdk_window_set_cursor(gdk_splash_window,cursor_arrow);
@@ -796,12 +801,12 @@ gint init(void* arg) {
               GtkWidget *label=gtk_label_new(text);
               gtk_widget_override_font(label, pango_font_description_from_string("Arial 12"));
               gtk_widget_show(label);
-              gtk_grid_attach(GTK_GRID(grid),label,0,i,4,1);
+              gtk_grid_attach(GTK_GRID(grid),label,0,i,3,1);
 
               GtkWidget *start_button=gtk_button_new_with_label("Start");
               gtk_widget_override_font(start_button, pango_font_description_from_string("Arial 18"));
               gtk_widget_show(start_button);
-              gtk_grid_attach(GTK_GRID(grid),start_button,4,i,1,1);
+              gtk_grid_attach(GTK_GRID(grid),start_button,3,i,1,1);
               g_signal_connect(start_button,"pressed",G_CALLBACK(start_cb),(gpointer *)i);
 
               // if not available then cannot start it
@@ -819,7 +824,7 @@ gint init(void* arg) {
               GtkWidget *configure_button=gtk_button_new_with_label("Configure");
               gtk_widget_override_font(configure_button, pango_font_description_from_string("Arial 18"));
               gtk_widget_show(configure_button);
-              gtk_grid_attach(GTK_GRID(grid),configure_button,5,i,1,1);
+              gtk_grid_attach(GTK_GRID(grid),configure_button,4,i,1,1);
               g_signal_connect(configure_button,"pressed",G_CALLBACK(configure_cb),(gpointer *)i);
           }
 
index a3352890a5060269a45d1fc5683c7cd3a744bfbb..88bee2583df88ce32ab9f28f977d34339cf3b12a 100644 (file)
@@ -455,7 +455,6 @@ static void process_ozy_input_buffer(char  *buffer) {
           if(tune) {
             double tunefrequency = (double)((filterHigh - filterLow) / 2);
             phase=sineWave(micinputbuffer, BUFFER_SIZE, phase, (float)tunefrequency);
-          } else if(mode==modeCWU || mode==modeCWL) {
           }
           // process the output
           fexchange0(CHANNEL_TX, micinputbuffer, micoutputbuffer, &error);
@@ -756,14 +755,14 @@ void ozy_send_buffer() {
       break;
     case 7:
       output_buffer[C0]=0x1E;
-      if(cw_keyer_internal==1) {
-        if(isTransmitting() || (mode!=modeCWU && mode!=modeCWL)) {
-          output_buffer[C1]=0x00;
+      if(mode!=modeCWU && mode!=modeCWL) {
+        // output_buffer[C1]|=0x00;
+      } else {
+        if((tune==1) || (cw_keyer_internal==0)) {
+          // output_buffer[C1]|=0x00;
         } else {
-          output_buffer[C1]=0x01;
+          output_buffer[C1]|=0x01;
         }
-      } else {
-        output_buffer[C1]=0x00;
       }
       output_buffer[C2]=cw_keyer_sidetone_volume;
       output_buffer[C3]=cw_keyer_ptt_delay;
@@ -777,16 +776,29 @@ void ozy_send_buffer() {
       output_buffer[C4]=cw_keyer_sidetone_frequency>>8;
       break;
   }
-  command++;
-  if(command>8) {
-    command=0;
-  }
 
   // set mox
-  output_buffer[C0]|=isTransmitting();
+  if((mode!=modeCWU && mode!=modeCWL)) {
+    if(isTransmitting()) {
+      output_buffer[C0]|=0x01;
+    }
+  } else {
+    if(tune==1) {
+      output_buffer[C0]|=0x01;
+    } else {
+      if(cw_keyer_internal==0) {
+        output_buffer[C0]|=0x01;
+      }
+    }
+  }
 
   metis_write(0x02,output_buffer,OZY_BUFFER_SIZE);
 
+  command++;
+  if(command>8) {
+    command=0;
+  }
+
   //fprintf(stderr,"C0=%02X C1=%02X C2=%02X C3=%02X C4=%02X\n",
   //                output_buffer[C0],output_buffer[C1],output_buffer[C2],output_buffer[C3],output_buffer[C4]);
 }
diff --git a/pihpsdr b/pihpsdr
index 721102ce2178d9e2a408cdaf11a6012ca3910c71..e3eb205d7f45c1e489bec15b50a7a3aa84b1cb0c 100755 (executable)
Binary files a/pihpsdr and b/pihpsdr differ
diff --git a/radio.c b/radio.c
index b5fdb1105127981110d6a3c4a539103dfdc1ee73..8be22cfe8d85776b2307e72c8caa448a56cd2345 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -222,6 +222,13 @@ fprintf(stderr,"setTune: protocol=%d\n", protocol);
       schedule_high_priority(4);
       schedule_general();
     }
+    if(tune) {
+      SetChannelState(CHANNEL_RX0,0,1);
+      SetChannelState(CHANNEL_TX,1,0);
+    } else {
+      SetChannelState(CHANNEL_TX,0,1);
+      SetChannelState(CHANNEL_RX0,1,0);
+    }
   }
 }
 
@@ -230,11 +237,13 @@ int getTune() {
 }
 
 int isTransmitting() {
+/*
   BANDSTACK_ENTRY *entry;
   entry=bandstack_entry_get_current();
-  if((entry->mode==modeCWL || entry->mode==modeCWU) && cw_keyer_internal==1) {
+  if((entry->mode==modeCWL || entry->mode==modeCWU) && cw_keyer_internal==1 && ptt==1) {
     return 0;
   }
+*/
   return ptt!=0 || mox!=0 || tune!=0;
 }
 
index 8d4edbb7833fe1a6f2b4d7f72e69b31c924f1eaa..a2ad1a0fd330ac51676bdf7c81bed46a29dfbdec 100644 (file)
Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ
diff --git a/release/pihpsdr/libSoapySDR.so b/release/pihpsdr/libSoapySDR.so
new file mode 100755 (executable)
index 0000000..3c0232f
Binary files /dev/null and b/release/pihpsdr/libSoapySDR.so differ
index 721102ce2178d9e2a408cdaf11a6012ca3910c71..e3eb205d7f45c1e489bec15b50a7a3aa84b1cb0c 100755 (executable)
Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ
index 7ffd8dcf194f39edc4e64a869e9dd7a32ce31716..1add75c18d5149b8cd0db61a2d48ac6e1ce6bbb2 100644 (file)
@@ -236,6 +236,9 @@ void wdsp_init(int rx,int pixels,int protocol) {
     SetTXAPreGenRun(CHANNEL_TX, 0);
     SetTXAPostGenRun(CHANNEL_TX, 0);
 
+    SetChannelState(CHANNEL_TX,0,0);
+    SetChannelState(CHANNEL_RX0,1,0);
+
 }
 
 static void initAnalyzer(int channel,int buffer_size) {