Commit 27a6774b authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

software/lib: added sweep test program

parent fbb998a3
......@@ -5,7 +5,7 @@ CFLAGS = -I../include -g -Imini_bone -Ispll
OBJS_LIB = fdelay_lib.o i2c_master.o onewire.o mini_bone/minibone_lib.o mini_bone/ptpd_netif.o spec_common.o spec/speclib.o fdelay_dmtd_calibration.o
all: testprog lib gs rp-test
all: testprog lib gs rp-test sweep-test
lib: $(OBJS_LIB)
gcc -shared -o libfinedelay.so $(OBJS_LIB)
......@@ -19,5 +19,9 @@ gs: lib fdelay-gs.o
rp-test: lib random_pulse_test.o
gcc -o fdelay-random-test $(OBJS_LIB) random_pulse_test.o -lm
sweep-test: lib sweep_test.o
gcc -o fdelay-sweep-test $(OBJS_LIB) sweep_test.o -lm
clean:
rm -f *.o fdelay-random-test fdelay-gs fdelay_pps_demo fdelay_test
\ No newline at end of file
/* Simple demo that reads samples using the read call */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
#include <signal.h>
#include <sys/select.h>
#define FDELAY_INTERNAL // for sysfs_get/set
#include "fdelay_lib.h"
int configure_board(fdelay_device_t *b, int argc, char *argv[])
{
fdelay_time_t t;
if(spec_fdelay_init(b,argc,argv) < 0)
{
printf("Init failed\n");
exit(-1);
}
fdelay_configure_sync(b, FDELAY_SYNC_LOCAL);
fdelay_get_time(b, &t);
t.frac = 0;
t.coarse = 0;
t.utc += 2;
sleep(1);
fdelay_configure_pulse_gen(b, 1, 1, t, 10 * 1000000, 99999990, -1);
fdelay_configure_trigger(b, 0, 1);
fdelay_raw_readout(b, 0);
fdelay_configure_readout(b, 0);
fdelay_configure_readout(b, 1);
fdelay_configure_trigger(b, 1, 0);
printf("Configuration complete\n");
fflush(stdout);
return 0;
}
void handle_readout(fdelay_device_t *b, int n_samples)
{
int64_t t_ps;
fdelay_time_t t;
static time_t start;
static int64_t t_prev;
static int prev_seq = -1;
int done;
for(;;)
while(fdelay_read(b, &t, 1) == 1)
{
t_ps = (t.coarse * 8000LL) + ((t.frac * 8000LL) >> 12);
int64_t delta = t_ps-t_prev;
if(delta < 0)
delta += 1000000000000LL;
if(prev_seq >= 0)
printf("Samp %lli.%03lli %lli\n", t_ps / 1000LL, t_ps % 1000LL, delta) ;
prev_seq = t.seq_id;
t_prev=t_ps;
n_samples--;
if(!n_samples) return;
}
}
int main(int argc, char *argv[])
{
fdelay_device_t b;
configure_board(&b, argc, argv);
handle_readout(&b, 40000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment