Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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 ADC 100M 14b 4cha - Software
Commits
89968003
Commit
89968003
authored
Sep 05, 2012
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: add parport-burst
Signed-off-by:
Federico Vaga
<
federico.vaga@gmail.com
>
parent
26f339fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
Makefile
tools/Makefile
+2
-1
parport-burst.c
tools/parport-burst.c
+88
-0
No files found.
tools/Makefile
View file @
89968003
...
...
@@ -6,6 +6,7 @@ HOSTCC ?= gcc
hostprogs-y
:=
fau-trg-config
hostprogs-y
+=
fau-acq-time
hostprogs-y
+=
parport-burst
# we are not in the kernel, so we need to piggy-back on "make modules"
modules
:
$(hostprogs-y)
...
...
@@ -18,4 +19,4 @@ module_install:
# we need this as we are out of the kernel
%
:
%.c
$(HOSTCC)
$(HOST_EXTRACFLAGS)
-O2
-Wall
$^
-o
$@
\ No newline at end of file
$(HOSTCC)
$(HOST_EXTRACFLAGS)
-O2
-Wall
$^
-o
$@
tools/parport-burst.c
0 → 100644
View file @
89968003
/*
* a simple output tool to make a burst on a parallel port
*
* 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 <glob.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
/* Returns the numer of microsecond timer ticks (Tomasz Wlostowski) */
static
int64_t
get_tics
()
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
return
(
int64_t
)
tv
.
tv_sec
*
1000
*
1000
+
tv
.
tv_usec
;
}
/* Microsecond-accurate delay-to */
static
void
delay_to
(
int64_t
until
)
{
while
(
get_tics
()
<
until
)
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
,
addr
,
count
,
usec
;
int64_t
tics
;
if
(
argc
!=
4
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s <hexaddr> <count> <period-usec>
\"\n
"
,
argv
[
0
],
argv
[
0
]);
exit
(
1
);
}
if
(
sscanf
(
argv
[
1
],
"%x"
,
&
addr
)
!=
1
)
{
fprintf
(
stderr
,
"%s: wrong hex
\"
%s
\"\n
"
,
argv
[
0
],
argv
[
1
]);
exit
(
1
);
}
if
(
sscanf
(
argv
[
2
],
"%i"
,
&
count
)
!=
1
)
{
fprintf
(
stderr
,
"%s: wrong count
\"
%s
\"\n
"
,
argv
[
0
],
argv
[
2
]);
exit
(
1
);
}
if
(
sscanf
(
argv
[
3
],
"%i"
,
&
usec
)
!=
1
)
{
fprintf
(
stderr
,
"%s: wrong period
\"
%s
\"\n
"
,
argv
[
0
],
argv
[
3
]);
exit
(
1
);
}
fprintf
(
stderr
,
"%s: using port 0x%x, %i pulses, period %i us
\n
"
,
argv
[
0
],
addr
,
count
,
usec
);
fd
=
open
(
"/dev/port"
,
O_RDWR
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"%s: /dev/port: %s
\n
"
,
argv
[
0
],
strerror
(
errno
));
exit
(
1
);
}
tics
=
get_tics
();
do
{
char
b
[]
=
{
0x00
,
0xff
};
lseek
(
fd
,
addr
,
SEEK_SET
);
write
(
fd
,
b
+
1
,
1
);
lseek
(
fd
,
addr
,
SEEK_SET
);
write
(
fd
,
b
+
0
,
1
);
if
(
count
>
1
)
{
tics
+=
usec
;
delay_to
(
tics
);
}
}
while
(
--
count
);
return
0
;
}
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