Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 4cha - Software
Commits
6ff1ace1
Commit
6ff1ace1
authored
May 02, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: added input config, functions and demo
parent
ac179582
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
0 deletions
+130
-0
.gitignore
lib/.gitignore
+2
-0
Makefile
lib/Makefile
+2
-0
fdelay-tdc.c
lib/fdelay-tdc.c
+54
-0
fdelay-term.c
lib/fdelay-term.c
+70
-0
fdelay.h
lib/fdelay.h
+2
-0
No files found.
lib/.gitignore
View file @
6ff1ace1
*.a
.depend
fdelay-list
fdelay-board-time
fdelay-term
lib/Makefile
View file @
6ff1ace1
...
...
@@ -3,12 +3,14 @@
LIB
=
libfdelay.a
LOBJ
:=
fdelay-init.o
LOBJ
+=
fdelay-time.o
LOBJ
+=
fdelay-tdc.o
CFLAGS
=
-Wall
-ggdb
-O2
-I
..
-I
$(ZIO)
/include
LDFLAGS
=
-L
.
-lfdelay
DEMOSRC
:=
fdelay-list.c
DEMOSRC
+=
fdelay-board-time.c
DEMOSRC
+=
fdelay-term.c
DEMOS
:=
$
(
DEMOSRC:.c
=)
...
...
lib/fdelay-tdc.c
0 → 100644
View file @
6ff1ace1
/*
* TDC-related functions
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/zio.h>
#include <linux/zio-user.h>
#include <fine-delay.h>
#define FDELAY_INTERNAL
#include "fdelay.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static
int
config_mask
=
FD_TDCF_DISABLE_INPUT
|
FD_TDCF_DISABLE_TSTAMP
|
FD_TDCF_TERM_50
;
int
fdelay_set_config_tdc
(
struct
fdelay_board
*
userb
,
int
flags
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
if
(
flags
&
~
config_mask
)
{
errno
=
EINVAL
;
return
-
1
;
}
val
=
flags
;
return
fdelay_sysfs_set
(
b
,
"fd-input/flags"
,
&
val
);
}
int
fdelay_get_config_tdc
(
struct
fdelay_board
*
userb
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
int
ret
;
ret
=
fdelay_sysfs_get
(
b
,
"fd-input/flags"
,
&
val
);
if
(
ret
)
return
ret
;
return
val
;
}
lib/fdelay-term.c
0 → 100644
View file @
6ff1ace1
/* Simple demo that acts on the termination of the first board */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fine-delay.h>
#include "fdelay.h"
int
main
(
int
argc
,
char
**
argv
)
{
struct
fdelay_board
*
b
;
int
i
,
hwval
,
newval
;
if
(
argc
>
2
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s 1|0
\n
"
,
argv
[
0
],
argv
[
0
]);
exit
(
1
);
}
newval
=
-
1
;
if
(
argc
>
1
)
{
if
(
!
strcmp
(
argv
[
1
],
"0"
))
newval
=
0
;
else
if
(
!
strcmp
(
argv
[
1
],
"1"
))
newval
=
1
;
else
{
fprintf
(
stderr
,
"%s: arg
\"
%s
\"
is not 0 nor 1
\n
"
,
argv
[
0
],
argv
[
1
]);
exit
(
1
);
}
}
i
=
fdelay_init
();
if
(
i
<
0
)
{
fprintf
(
stderr
,
"%s: fdelay_init(): %s
\n
"
,
argv
[
0
],
strerror
(
errno
));
exit
(
1
);
}
if
(
i
==
0
)
{
fprintf
(
stderr
,
"%s: no boards found
\n
"
,
argv
[
0
]);
exit
(
1
);
}
if
(
i
!=
1
)
{
fprintf
(
stderr
,
"%s: found %i boards, using first one
\n
"
,
argv
[
0
],
i
);
}
b
=
fdelay_open
(
0
,
-
1
);
if
(
!
b
)
{
fprintf
(
stderr
,
"%s: fdelay_open(): %s
\n
"
,
argv
[
0
],
strerror
(
errno
));
exit
(
1
);
}
hwval
=
fdelay_get_config_tdc
(
b
);
switch
(
newval
)
{
case
1
:
hwval
|=
FD_TDCF_TERM_50
;
break
;
case
0
:
hwval
&=
~
FD_TDCF_TERM_50
;
break
;
}
fdelay_set_config_tdc
(
b
,
hwval
);
hwval
=
fdelay_get_config_tdc
(
b
);
printf
(
"%s: termination is %s
\n
"
,
argv
[
0
],
hwval
&
FD_TDCF_TERM_50
?
"on"
:
"off"
);
fdelay_close
(
b
);
fdelay_exit
();
return
0
;
}
lib/fdelay.h
View file @
6ff1ace1
...
...
@@ -38,6 +38,8 @@ extern int fdelay_set_time(struct fdelay_board *b, struct fdelay_time *t);
extern
int
fdelay_get_time
(
struct
fdelay_board
*
b
,
struct
fdelay_time
*
t
);
extern
int
fdelay_set_host_time
(
struct
fdelay_board
*
b
);
extern
int
fdelay_set_config_tdc
(
struct
fdelay_board
*
b
,
int
flags
);
extern
int
fdelay_get_config_tdc
(
struct
fdelay_board
*
b
);
#ifdef FDELAY_INTERNAL
/* Libray users should ignore what follows */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment