Skip to content

Commit

Permalink
Added SoapySDR support for Receive
Browse files Browse the repository at this point in the history
  • Loading branch information
g0orx committed Oct 5, 2019
1 parent 951b575 commit 6ac8af8
Show file tree
Hide file tree
Showing 69 changed files with 4,826 additions and 1,305 deletions.
58 changes: 35 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
GIT_DATE := $(firstword $(shell git --no-pager show --date=short --format="%ai" --name-only))
GIT_VERSION := $(shell git describe --abbrev=0 --tags)

# uncomment the line below to include CONTROLLER2 (Also include GPIO and I2C)
#CONTROLLER2_INCLUDE=CONTROLLER2

# uncomment the line below to include GPIO
#GPIO_INCLUDE=GPIO
GPIO_INCLUDE=GPIO

# uncomment the line below to include MCP23017 I2C
#I2C_INCLUDE=I2C
Expand All @@ -19,7 +22,7 @@ GIT_VERSION := $(shell git describe --abbrev=0 --tags)
#FREEDV_INCLUDE=FREEDV

# uncomment the line below to include Pure Signal support
#PURESIGNAL_INCLUDE=PURESIGNAL
PURESIGNAL_INCLUDE=PURESIGNAL

# uncomment the line to below include support for sx1509 i2c expander
#SX1509_INCLUDE=sx1509
Expand Down Expand Up @@ -52,6 +55,10 @@ LINK=gcc
# uncomment the line below for various debug facilities
#DEBUG_OPTION=-D DEBUG

ifeq ($(CONTROLLER2_INCLUDE),CONTROLLER2)
CONTROLLER2_OPTIONS=-D CONTROLLER2
endif

ifeq ($(MIDI_INCLUDE),MIDI)
MIDI_OPTIONS=-D MIDI
MIDI_SOURCES= alsa_midi.c midi2.c midi3.c
Expand Down Expand Up @@ -94,27 +101,28 @@ USBOZY_OBJS= \
ozyio.o
endif

# uncomment the line below for LimeSDR (uncomment line below)
#LIMESDR_INCLUDE=LIMESDR

# uncomment the line below when Radioberry radio cape is plugged in (for now use emulator and old protocol)
#RADIOBERRY_INCLUDE=RADIOBERRY
ifeq ($(RADIOBERRY_INCLUDE),RADIOBERRY)
RADIOBERRY_OPTIONS=-D RADIOBERRY
endif

ifeq ($(LIMESDR_INCLUDE),LIMESDR)
LIMESDR_OPTIONS=-D LIMESDR
# uncomment the line below for SoapySDR
SOAPYSDR_INCLUDE=SOAPYSDR

ifeq ($(SOAPYSDR_INCLUDE),SOAPYSDR)
SOAPYSDR_OPTIONS=-D SOAPYSDR
SOAPYSDRLIBS=-lSoapySDR
LIMESDR_SOURCES= \
lime_discovery.c \
lime_protocol.c
LIMESDR_HEADERS= \
lime_discovery.h \
lime_protocol.h
LIMESDR_OBJS= \
lime_discovery.o \
lime_protocol.o
SOAPYSDR_SOURCES= \
soapy_discovery.c \
soapy_protocol.c
SOAPYSDR_HEADERS= \
soapy_discovery.h \
soapy_protocol.h
SOAPYSDR_OBJS= \
soapy_discovery.o \
soapy_protocol.o
endif


Expand Down Expand Up @@ -159,13 +167,16 @@ ifeq ($(GPIO_INCLUDE),GPIO)
GPIO_LIBS=-lwiringPi
GPIO_SOURCES= \
gpio.c \
encoder_menu.c
encoder_menu.c \
switch_menu.c
GPIO_HEADERS= \
gpio.h \
encoder_menu.h
encoder_menu.h \
switch_menu.h
GPIO_OBJS= \
gpio.o \
encoder_menu.o
encoder_menu.o \
switch_menu.o
endif

ifeq ($(I2C_INCLUDE),I2C)
Expand Down Expand Up @@ -210,8 +221,9 @@ AUDIO_LIBS=-lasound
#AUDIO_LIBS=-lsoundio

OPTIONS=-g -Wno-deprecated-declarations $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
$(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) \
$(I2C_OPTIONS) $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) \
$(PI_SDR_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) \
$(CONTROLLER2_OPTIONS) \
-D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3

LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS)
Expand Down Expand Up @@ -431,17 +443,17 @@ ext.o \
error_handler.o \
cwramp.o

$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) \
$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) $(FREEDV_OBJS) \
$(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \
$(MIDI_OBJS) $(STEMLAB_OBJS)
$(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) \
$(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \
$(SOAPYSDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \
$(MIDI_OBJS) $(STEMLAB_OBJS) $(LIBS)

all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) \
all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \
$(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) \
$(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) \
$(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \
$(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \
$(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(MIDI_SOURCES)$(STEMLAB_SOURCES)

prebuild:
Expand Down
4 changes: 3 additions & 1 deletion about_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void about_menu(GtkWidget *parent) {
lines++;
sprintf(text,"%s\n Ken Hopper, N9VV, Testing and Documentation",text);
lines++;
sprintf(text,"%s\n Christoph v. Wüllen, DL1YCF, Pure Signal, Diversity, MIDI",text);
lines++;
lines++;

sprintf(text,"%s\n\nBuild date: %s", text, build_date);
Expand All @@ -117,7 +119,7 @@ void about_menu(GtkWidget *parent) {
sprintf(text,"%s\nBuild version: %s", text, version);
lines++;

sprintf(text,"%s\n\nWDSP v%d.%02d", text, GetWDSPVersion()/100, GetWDSPVersion()%100);
sprintf(text,"%s\nWDSP version: %d.%02d", text, GetWDSPVersion()/100, GetWDSPVersion()%100);
lines++;

sprintf(text,"%s\n\nDevice: %s Protocol %s v%d.%d",text,radio->name,radio->protocol==ORIGINAL_PROTOCOL?"1":"2",radio->software_version/10,radio->software_version%10);
Expand Down
72 changes: 72 additions & 0 deletions adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* Copyright (C)
* 2018 - John Melton, G0ORX/N6LYT
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/

#ifndef ADC_H
#define ADC_H

enum {
AUTOMATIC=0,
MANUAL
};

enum {
BYPASS=0,
HPF_1_5,
HPF_6_5,
HPF_9_5,
HPF_13,
HPF_20
};

enum {
LPF_160=0,
LPF_80,
LPF_60_40,
LPF_30_20,
LPF_17_15,
LPF_12_10,
LPF_6
};

enum {
ANTENNA_1=0,
ANTENNA_2,
ANTENNA_3,
ANTENNA_XVTR,
ANTENNA_EXT1,
ANTENNA_EXT2
};

typedef struct _adc {
gint filters;
gint hpf;
gint lpf;
gint antenna;
gboolean dither;
gboolean random;
gboolean preamp;
gint attenuation;
gboolean enable_step_attenuation;
#ifdef SOAPYSDR
gint *rx_gain;
gboolean agc;
#endif
} ADC;

#endif
1 change: 1 addition & 0 deletions agc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
#define AGC_SLOW 2
#define AGC_MEDIUM 3
#define AGC_FAST 4
#define AGC_LAST AGC_FAST

#endif
85 changes: 50 additions & 35 deletions ant_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@
#include "ant_menu.h"
#include "band.h"
#include "radio.h"
#include "new_protocol.h"
#ifdef SOAPYSDR
#include "soapy_protocol.h"
#endif


static GtkWidget *parent_window=NULL;
static GtkWidget *menu_b=NULL;
static GtkWidget *dialog=NULL;
static GtkWidget *grid=NULL;
static GtkWidget *adc0_antenna_combo_box;

static void cleanup() {
if(dialog!=NULL) {
Expand Down Expand Up @@ -62,6 +68,18 @@ static void rx_ant_cb(GtkWidget *widget, gpointer data) {
}
}

static void adc0_antenna_cb(GtkComboBox *widget,gpointer data) {
ADC *adc=(ADC *)data;
adc->antenna=gtk_combo_box_get_active(widget);
if(radio->protocol==NEW_PROTOCOL) {
schedule_high_priority();
#ifdef SOAPYSDR
} else if(radio->device==SOAPYSDR_USB_DEVICE) {
soapy_protocol_set_rx_antenna(receiver[0],adc[0].antenna);
#endif
}
}

static void rx_lime_ant_cb(GtkWidget *widget, gpointer data) {
int ant=((uintptr_t)data)&0xF;
BAND *band=band_get_current_band();
Expand Down Expand Up @@ -277,14 +295,21 @@ void ant_menu(GtkWidget *parent) {
g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);

GtkWidget *hf_rb=gtk_radio_button_new_with_label(NULL,"HF");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hf_rb),TRUE);
g_signal_connect(hf_rb,"toggled",G_CALLBACK(hf_rb_cb),NULL);
gtk_grid_attach(GTK_GRID(grid),hf_rb,1,0,1,1);
#ifdef SOAPYSDR
if(radio->device!=SOAPYSDR_USB_DEVICE) {
#endif
GtkWidget *hf_rb=gtk_radio_button_new_with_label(NULL,"HF");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hf_rb),TRUE);
g_signal_connect(hf_rb,"toggled",G_CALLBACK(hf_rb_cb),NULL);
gtk_grid_attach(GTK_GRID(grid),hf_rb,1,0,1,1);

GtkWidget *xvtr_rb=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(hf_rb),"XVTR");
g_signal_connect(xvtr_rb,"toggled",G_CALLBACK(xvtr_rb_cb),NULL);
gtk_grid_attach(GTK_GRID(grid),xvtr_rb,2,0,1,1);

GtkWidget *xvtr_rb=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(hf_rb),"XVTR");
g_signal_connect(xvtr_rb,"toggled",G_CALLBACK(xvtr_rb_cb),NULL);
gtk_grid_attach(GTK_GRID(grid),xvtr_rb,2,0,1,1);
#ifdef SOAPYSDR
}
#endif

if ((protocol == NEW_PROTOCOL && (device == NEW_DEVICE_HERMES || device == NEW_DEVICE_ANGELIA || device == NEW_DEVICE_ORION)) ||
(protocol == ORIGINAL_PROTOCOL && (device == DEVICE_HERMES || device == DEVICE_ANGELIA || device == DEVICE_ORION))) {
Expand Down Expand Up @@ -360,37 +385,27 @@ void ant_menu(GtkWidget *parent) {
show_hf();
}

#ifdef LIMESDR
if(protocol==LIMESDR_PROTOCOL) {
BAND *band=band_get_current_band();

GtkWidget *rx1_none=gtk_radio_button_new_with_label(NULL,"RX 1: NONE");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_none), band->alexRxAntenna==0);
gtk_widget_show(rx1_none);
gtk_grid_attach(GTK_GRID(grid),rx1_none,0,1,1,1);
g_signal_connect(rx1_none,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)(long)0);

GtkWidget *rx1_lnah=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_none),"RX1: LNAH");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnah), band->alexRxAntenna==1);
gtk_widget_show(rx1_lnah);
gtk_grid_attach(GTK_GRID(grid),rx1_lnah,0,2,1,1);
g_signal_connect(rx1_lnah,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)(long)+1);

GtkWidget *rx1_lnal=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_lnah),"RX1: LNAL");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnal), band->alexRxAntenna==2);
gtk_widget_show(rx1_lnal);
gtk_grid_attach(GTK_GRID(grid),rx1_lnal,0,3,1,1);
g_signal_connect(rx1_lnal,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)(long)2);

GtkWidget *rx1_lnaw=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_lnal),"RX1: LNAW");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnaw), band->alexRxAntenna==3);
gtk_widget_show(rx1_lnaw);
gtk_grid_attach(GTK_GRID(grid),rx1_lnaw,0,4,1,1);
g_signal_connect(rx1_lnaw,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)(long)3);
#ifdef SOAPYSDR
if(radio->device==SOAPYSDR_USB_DEVICE) {
int i;

g_print("rx_antennas=%d\n",radio->info.soapy.rx_antennas);
if(radio->info.soapy.rx_antennas>0) {
GtkWidget *antenna_label=gtk_label_new("RX Antenna:");
gtk_grid_attach(GTK_GRID(grid),antenna_label,0,1,1,1);
adc0_antenna_combo_box=gtk_combo_box_text_new();

for(i=0;i<radio->info.soapy.rx_antennas;i++) {
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(adc0_antenna_combo_box),NULL,radio->info.soapy.rx_antenna[i]);
}

gtk_combo_box_set_active(GTK_COMBO_BOX(adc0_antenna_combo_box),adc[0].antenna);
g_signal_connect(adc0_antenna_combo_box,"changed",G_CALLBACK(adc0_antenna_cb),&adc[0]);
gtk_grid_attach(GTK_GRID(grid),adc0_antenna_combo_box,1,1,1,1);
}
}
#endif


gtk_container_add(GTK_CONTAINER(content),grid);

sub_menu=dialog;
Expand Down
Loading

0 comments on commit 6ac8af8

Please sign in to comment.