Commit 46c920f8 authored by Miguel Gómez Sexto's avatar Miguel Gómez Sexto Committed by Samuel Iglesias Gonsálvez

Added zalloc and free methods to lib. Also adapted compilation to spec changes

Signed-off-by: Miguel Gómez Sexto's avatarMiguel Gomez <magomez@igalia.com>
Signed-off-by: Samuel Iglesias Gonsálvez's avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
parent 5b333eb5
......@@ -2,9 +2,9 @@ LINUX ?= /lib/modules/$(shell uname -r)/build
ZIO ?= $(HOME)/zio
SPEC_SW ?= $(HOME)/spec-sw
KBUILD_EXTRA_SYMBOLS := $(ZIO)/Module.symvers $(SPEC_SW)/kernel/Module.symvers
KBUILD_EXTRA_SYMBOLS := $(ZIO)/Module.symvers $(SPEC_SW)/kernel/Module.symvers $(SPEC_SW)/fmc-bus/kernel/Module.symvers
ccflags-y = -I$(ZIO)/include -I$(SPEC_SW)/kernel -I$M -I$(SPEC_SW)/kernel/include
ccflags-y = -I$(ZIO)/include -I$(SPEC_SW)/kernel -I$M -I$(SPEC_SW)/kernel -I$(SPEC_SW)/fmc-bus/kernel/include
#ccflags-y += -DDEBUG
......
......@@ -186,6 +186,16 @@ int tdc_close(struct tdc_board *b)
return 0;
}
struct tdc_time *tdc_zalloc(unsigned int events)
{
return calloc(events, sizeof(struct tdc_time));
}
void tdc_free(struct tdc_time *buffer)
{
free(buffer);
}
int tdc_start_acquisition(struct tdc_board *b)
{
return __tdc_sysfs_set(b, "activate_acquisition", 1);
......
......@@ -31,6 +31,9 @@ enum {
extern struct tdc_board *tdc_open(int lun);
extern int tdc_close(struct tdc_board *b);
extern struct tdc_time *tdc_zalloc(unsigned int events);
extern void tdc_free(struct tdc_time *buffer);
extern int tdc_start_acquisition(struct tdc_board *b);
extern int tdc_stop_acquisition(struct tdc_board *b);
......
......@@ -9,7 +9,7 @@
int main(int argc, char **argv)
{
struct tdc_board *b;
struct tdc_time t;
struct tdc_time *t;
uint32_t set, get;
int res;
int i;
......@@ -158,12 +158,13 @@ int main(int argc, char **argv)
tdc_set_time_threshold(b, 10);
tdc_set_timestamp_threshold(b, 10);
tdc_start_acquisition(b);
t = tdc_zalloc(1);
for (i = 0; i <100; i++) {
/* this should be a blocking read */
res = tdc_read(b, CHAN0, &t, 1, 0);
res = tdc_read(b, CHAN0, t, 1, 0);
if (res == 1) {
printf("Got sample: utc %"PRIu64" ticks %"PRIu64" bins %"PRIu64" dacapo %i\n",
t.utc, t.ticks, t.bins, t.da_capo);
t->utc, t->ticks, t->bins, t->da_capo);
} else {
printf("Error reading sample\n");
}
......
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