From: John Melton g0orx/n6lyt Date: Tue, 10 May 2016 11:35:41 +0000 (+0000) Subject: fixed tune problem. Started adding code for LimeSDR (unused) X-Git-Url: https://git.rkrishnan.org/pf/components/$rel_link?a=commitdiff_plain;h=a325bf2123b99c5180dd3d0fb476e0b3561c9c2c;p=pihpsdr.git fixed tune problem. Started adding code for LimeSDR (unused) --- diff --git a/Makefile b/Makefile index 4b824fc..952b621 100644 --- 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 d50da61..daf9569 100644 --- 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 ec5037d..61e61ae 100644 --- a/band.h +++ b/band.h @@ -31,11 +31,25 @@ #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 /* --------------------------------------------------------------------------*/ /** diff --git a/discovered.h b/discovered.h index 429b523..110561e 100644 --- a/discovered.h +++ b/discovered.h @@ -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 index 0000000..9414208 --- /dev/null +++ b/lime_discovery.c @@ -0,0 +1,19 @@ +#include +#include +#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;ikeys[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 index 0000000..999944e --- /dev/null +++ b/lime_discovery.h @@ -0,0 +1 @@ +void lime_discovery(); diff --git a/main.c b/main.c index db3d116..b7e64eb 100644 --- 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); } diff --git a/old_protocol.c b/old_protocol.c index a335289..88bee25 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -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 721102c..e3eb205 100755 Binary files a/pihpsdr and b/pihpsdr differ diff --git a/radio.c b/radio.c index b5fdb11..8be22cf 100644 --- 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; } diff --git a/release/pihpsdr.tar b/release/pihpsdr.tar index 8d4edbb..a2ad1a0 100644 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 index 0000000..3c0232f Binary files /dev/null and b/release/pihpsdr/libSoapySDR.so differ diff --git a/release/pihpsdr/pihpsdr b/release/pihpsdr/pihpsdr index 721102c..e3eb205 100755 Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ diff --git a/wdsp_init.c b/wdsp_init.c index 7ffd8dc..1add75c 100644 --- a/wdsp_init.c +++ b/wdsp_init.c @@ -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) {