Skip to content

Commit

Permalink
Revert "VNA application added"
Browse files Browse the repository at this point in the history
This reverts commit 5939a6c.
  • Loading branch information
Alexey Kaygorodov committed Apr 18, 2018
1 parent 64c7b9e commit 0759d71
Show file tree
Hide file tree
Showing 143 changed files with 3,771 additions and 3,632 deletions.
2 changes: 1 addition & 1 deletion Applications
2 changes: 1 addition & 1 deletion Bazaar/nginx/ngx_ext_modules/ngx_http_rp_module/config
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
$rp_src_dir/rp_data_cmd.c \
$rp_src_dir/cJSON.c"

CORE_LIBS="$CORE_LIBS -Wl,--no-as-needed -L$ngx_addon_dir/../ws_server -lws_server -lm -ldl -lssl -lcryptopp -lcurl -lboost_system -lboost_regex -lboost_thread"
CORE_LIBS="$CORE_LIBS -Wl,--no-as-needed -L$ngx_addon_dir/../ws_server -lws_server -lm -ldl -lcryptopp -lcurl -lboost_system -lboost_regex -lboost_thread"
CFLAGS="$CFLAGS -I $rp_include_dir -I$ngx_addon_dir/../ws_server"
CFLAGS="$CFLAGS -DVERSION=$VERSION -DREVISION=$REVISION"

Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ int rp_bazaar_start(ngx_http_request_t *r,

/* Get FPGA config file in <app_dir>/<app_id>/fpga.conf */
char *fpga_name = NULL;
if (system("/opt/redpitaya/rmamba_pl.sh"))
fprintf(stderr, "Problem running /opt/redpitaya/rmamba_pl.sh\n");
if (system("/opt/redpitaya/sbin/rmoverlay.sh"))
fprintf(stderr, "Problem running /opt/redpitaya/sbin/rmoverlay.sh\n");
if(get_fpga_path((const char *)argv[0], (const char *)lc->bazaar_dir.data, &fpga_name) == 0) { // FIXME !!!
/* Here we do not have application running anymore - load new FPGA */
fprintf(stderr, "Loading specific FPGA from: '%s'\n", fpga_name);
Expand Down
6 changes: 1 addition & 5 deletions Test/uio/Makefile → Examples/gpio_sysfs/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#Cross compiler definition
CC = $(CROSS_COMPILE)gcc

CFLAGS = -g -std=gnu99 -Wall -Werror
CFLAGS += -I../include
CFLAGS += -I../src -I../include
CFLAGS += -L ../lib -lm -lpthread
CFLAGS += -lm -lpthread

SRCS=$(wildcard *.c)
OBJS=$(SRCS:.c=)

all: $(OBJS)

%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

Expand Down
21 changes: 21 additions & 0 deletions Examples/gpio_sysfs/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Simple C gpio test application shows how to export/unexport different pins and
set direction on exported pins.

Requierment for using sysfs gpio interface for working with gpios is to load appropriate fpga bitstream
/opt/redpitaya/fpga/classic/fpga.bit and /opt/redpitaya/mercury/fpga.bit fit that requierments.
You can load bitstream using "cat /opt/redpitaya/fpga/classic/fpga.bit > /dev/xdevcfg" command.

Usaly exporting and setting direction to pins is done in external script that sets up all
required gpio in this example that is done using "system" call(same can also be achived using calls to functions open read and write).

Actual read and writes on /sys/class/gpio/gpio_PIN_NO_/value (where _PIN_NO_ represents pin number of
exported pin) is done with simple open, read and write comands.

If you connect pins DIO0_N to DIO0_P using jumper wire, value read from PIN DIO0_P
should match value written to POUT DIO0_P.

Documentation related to numbering of GPIO pins on redpitaya board is available at:
https://github.com/RedPitaya/RedPitaya/blob/master/doc/developerGuide/gpio/gpio.rst

General documentation related to gpio/sysfs interface is available at:
https://github.com/RedPitaya/linux-xlnx/blob/master/Documentation/gpio/sysfs.txt
135 changes: 135 additions & 0 deletions Examples/gpio_sysfs/gpioblink.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define IN 0
#define OUT 1

#define LOW 0
#define HIGH 1

#define PIN 976
#define POUT 968

#define VALUE_MAX 30
#define BUFFER_MAX 3

#define MAX_PATH 64


static int pin_export(int pin)
{
char shell[MAX_PATH];
sprintf(shell,"echo %d > /sys/class/gpio/export", pin);
system(shell);
return 0;
}

static int pin_unexport(int pin)
{
char shell[MAX_PATH];
sprintf(shell,"echo %d > /sys/class/gpio/unexport", pin);
system(shell);

return 0;
}

static int pin_direction(int pin, int dir){

char shell[MAX_PATH];
snprintf(shell, MAX_PATH, "echo %s > /sys/class/gpio/gpio%d/direction",((dir==IN)?"in":"out"),pin);
system(shell);

return 0;
}

static int pin_read(int pin){

char path[VALUE_MAX];
char value_str[3];
int fd;

snprintf(path, VALUE_MAX, "/sys/class/gpio/gpio%d/value", pin);

// get pin file descriptor for reading its state
fd = open(path, O_RDONLY);
if (-1 == fd) {
fprintf(stderr, "Unable to open gpio sysfs pin value file %s for reading\n",path);
return -1;
}

// read value
if (-1 == read(fd, value_str, 3)) {
fprintf(stderr, "Unable to read value\n");
return -1;
}

// close file
close(fd);

// return integar value
return atoi(value_str);
}

static int pin_write(int pin, int value)
{
char path[VALUE_MAX];
int fd;

snprintf(path, VALUE_MAX, "/sys/class/gpio/gpio%d/value", pin);
// get pin value file descrptor
fd = open(path, O_WRONLY);
if (-1 == fd) {
fprintf(stderr, "Unable to to open sysfs pins value file %s for writing\n",path);
return -1;
}
if(value==LOW){
//write low
if (1 != write(fd, "0", 1)) {
fprintf(stderr, "Unable to write value\n");
return -1;
}
}
else if(value==HIGH){
//write high
if (1 != write(fd, "1", 1)) {
fprintf(stderr, "Unable to write value\n");
return -1;
}
}else fprintf(stderr, "Nonvalid pin value requested\n");

//close file
close(fd);
return 0;
}

int main(int argc, char *argv[])
{
// apply required fpga bitstream mercury or classic
// system("cat /opt/redpitaya/fpga/fpga_classic.bit > /dev/xdevcfg");

int repeat = 10;
if (argc==2)
repeat=atoi(argv[1]);
// export pins
if (-1 == pin_export(POUT) || -1 == pin_export(PIN)) return 1;

// set pin direction
if (-1 == pin_direction(POUT, OUT) || -1 == pin_direction(PIN, IN)) return 2;
int i;
for (i = 1; i <= repeat; i++){
// set pin value
if (-1 == pin_write( POUT, i % 2)) return 3;
printf("Setting pin %d to %d\n", POUT,i % 2);
// read and printout pin value
printf("Reading pin %d got %d\n", PIN,pin_read(PIN));
usleep(10000);
}
// unexport pins on exit
if (-1 == pin_unexport(POUT) || -1 == pin_unexport(PIN))
return 4;
return 0;
}
70 changes: 43 additions & 27 deletions Examples/scpi/MATLAB/gen_arbitrary_signal.m
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
% %% Define Red Pitaya as TCP/IP object
clc
close all
IP= '192.168.178.103'; % Input IP of your Red Pitaya...
% IP= '192.168.101.108'; % IP of your Red Pitaya...
IP= 'rp-f01b63.local'; % rp-MAC.local MAC are the last 6 characters of your Red Pitaya
port = 5000; % If you are using WiFi then IP is:
RP=tcpip(IP, port,'OutputBufferSize',32784*5); % 192.168.128.1

RP=tcpip(IP, port,'OutputBufferSize',32784*5);
fopen(RP);
RP.Terminator = 'CR/LF';

%% Prepare an arbitrary waveform
% Values of arbitrary waveform must be in range from -1 to 1.
length = 2^14;

% select data transmittion BIN/ASCII (0 - binary, any other value - ASCII)
bin=1;
% select buffer length (max = 2^14)
length = 2^3;
% STEMlab 14 - 1 sign + 13 data bits
bitsize= 0;

% generates x axis in range 0 to 6 with length number of points
X0=0;
XN=6;
XN=length-1;
x = X0:(XN-X0)/(length-1):XN ;
% Values of arbitrary waveform must be in range from -1 to 1.
y1 = 0.8 * sin(x); % the first sinus signal with the amplitude 0.8
y2 = 0.2 * sin(21*x); % the second sinus signal with a frequency 20 times higher than the first one and the amplitude of 0.2
y_sum = y1+y2;
% y2 = 0.2 * sin(5*x); % the second sinus signal with a frequency 20 times higher than the first one and the amplitude of 0.2
y_sum = x;

% plot(x,y_sum);
% uncomment the following line to show the plot of the arbitrary function
plot(x,y_sum);

%% transmit data and configure genertor

%%% transmit data in binary format
% binary write still needs to be debuged
% disp(y_sum)
% binblockwrite(RP, y_sum,'int16','SOURce1:TRACe:DATA:RAW ');
% fprintf(RP,'\n');

%%% transmit data in ascii format
% convert float to string
waveform_ch_1_0 = num2str(y_sum,'%1.5f,');
% remove the last “,”.
waveform_ch_1 = waveform_ch_1_0(1,1: size(waveform_ch_1_0,2)-3);

% set output amplitude and offset
fprintf(RP,'SOURce1:VOLTage:IMMediate:AMPlitude 1');
fprintf(RP,'SOURce1:VOLTage:IMMediate:OFFSet 0');

% # specify peridic mode, sinusoidal waveform and 1kHZ frequency
% specify peridic mode
fprintf(RP,'SOURce1:MODE PERiodic');

fprintf(RP,['SOURce1:TRACe:DATA:DATA ' waveform_ch_1]);
fprintf(RP,'SOURce1:FREQuency:FIXed 1000');
%
% # reset and start state machine
%%% transmit arbitrary waveform in either BINARY or ASCII format
if bin
disp('INFO: Sending data in BINARY format');
binblockwrite(RP, y_sum * (2^bitsize),'int16','SOURce1:TRACe:DATA:RAW ');
fprintf(RP,''); %binblockwrite does not complete with /n, hence one is added here

y_sum * (2^bitsize)
fprintf(RP,'SOURce1:TRACe:DATA:RAW? 8 ');
data1 = binblockread(RP,'int16')
else
disp('INFO: Sending data in ASCII format');
% convert float to string
waveform_ch_1_0 = num2str(y_sum,'%1.5f,');
% remove the last “,”.
waveform_ch_1 = waveform_ch_1_0(1,1: size(waveform_ch_1_0,2)-1);
fprintf(RP,['SOURce1:TRACe:DATA:DATA ' waveform_ch_1]);
end

% set 1kHZ frequency
fprintf(RP,'SOURce1:FREQuency:FIXed 2000');

% reset and start state machine
fprintf(RP,'SOURce1:RESET');
fprintf(RP,'SOURce1:START');
%

% # enable output
fprintf(RP,'OUTPUT1:STATe ON');
%

% # trigger state machine
fprintf(RP,'SOURce1:TRIGger');

% RA = binblockread(RP,'int16');

%% Close connection to the Red Pitaya
fclose(RP);

5 changes: 3 additions & 2 deletions Examples/scpi/MATLAB/gen_burst.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
%% Define Red Pitaya as TCP/IP object
clc
close all
IP= '192.168.178.103'; % Input IP of your Red Pitaya...
% IP= '192.168.101.108'; % IP of your Red Pitaya...
IP= 'rp-f01b63.local'; % rp-MAC.local MAC are the last 6 characters of your Red Pitaya
port = 5000; % If you are using WiFi then IP is:
RP=tcpip(IP, port); % 192.168.128.1
RP=tcpip(IP, port);

fopen(RP);
RP.Terminator = 'CR/LF';
Expand Down
7 changes: 4 additions & 3 deletions Examples/scpi/MATLAB/gen_sine_signal.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
%% Define Red Pitaya as TCP/IP object
clc
close all
IP= '192.168.178.103'; % Input IP of your Red Pitaya...
% IP= '192.168.101.108'; % IP of your Red Pitaya...
IP= 'rp-f01b63.local'; % rp-MAC.local MAC are the last 6 characters of your Red Pitaya
port = 5000; % If you are using WiFi then IP is:
RP=tcpip(IP, port); % 192.168.128.1
RP=tcpip(IP, port);

fopen(RP);
RP.Terminator = 'CR/LF';

% specify peridic mode, sinusoidal waveform and 1kHZ frequency
fprintf(RP,'SOURce1:MODE PERiodic'); % periodic
fprintf(RP,'SOURce1:FUNCtion:SHAPe SINusoid'); % select signal shape as sinusoid
fprintf(RP,'SOURce1:FREQuency:FIXed 1000'); % Set frequency of output signal to 3kHz
fprintf(RP,'SOURce1:FREQuency:FIXed 10000'); % Set frequency of output signal to 3kHz

% set output amplitude and offset
fprintf(RP,'SOURce1:VOLTage:IMMediate:AMPlitude 1'); % Set amplitude of the output signal
Expand Down
5 changes: 3 additions & 2 deletions Examples/scpi/MATLAB/gen_sync_two_channel.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
%% Define Red Pitaya as TCP/IP object
clc
close all
IP= '192.168.178.103'; % Input IP of your Red Pitaya...
% IP= '192.168.101.108'; % IP of your Red Pitaya...
IP= 'rp-f01b63.local'; % rp-MAC.local MAC are the last 6 characters of your Red Pitaya
port = 5000; % If you are using WiFi then IP is:
RP=tcpip(IP, port); % 192.168.128.1
RP=tcpip(IP, port);

fopen(RP);
RP.Terminator = 'CR/LF';
Expand Down
Loading

0 comments on commit 0759d71

Please sign in to comment.