Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - 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 TDC 1ns 5cha - Software
Commits
b7eab1d2
Commit
b7eab1d2
authored
Aug 17, 2013
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: splitted headers into public and private parts
parent
662a3834
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
fmctdc-lib-private.h
lib/fmctdc-lib-private.h
+102
-0
No files found.
lib/fmctdc-lib-private.h
0 → 100644
View file @
b7eab1d2
/*
* The "official" fmc-tdc API
*
* Copyright (C) 2012-2013 CERN (www.cern.ch)
* Author: Tomasz Włostowski <tomasz.wlostowski@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.
*/
#ifndef __FMCTDC_LIB_PRIVATE_H__
#define __FMCTDC_LIB_PRIVATE_H__
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fmc-tdc.h>
/* Internal structure */
struct
__fmctdc_board
{
int
dev_id
;
char
*
devbase
;
char
*
sysbase
;
int
fdc
[
5
];
/* The 5 control channels */
int
fdd
[
5
];
/* The 5 data channels */
};
static
inline
int
fmctdc_is_verbose
(
void
)
{
return
getenv
(
"FMCTDC_LIB_VERBOSE"
)
!=
0
;
}
#define __define_board(b, ub) struct __fmctdc_board *b = (void *)(ub)
/* These two from ../tools/fdelay-raw.h, used internally */
static
inline
int
__fmctdc_sysfs_get
(
char
*
path
,
uint32_t
*
resp
)
{
FILE
*
f
=
fopen
(
path
,
"r"
);
if
(
!
f
)
return
-
1
;
errno
=
0
;
if
(
fscanf
(
f
,
"%i"
,
resp
)
!=
1
)
{
fclose
(
f
);
if
(
!
errno
)
errno
=
EINVAL
;
return
-
1
;
}
fclose
(
f
);
return
0
;
}
static
inline
int
__fmctdc_sysfs_set
(
char
*
path
,
uint32_t
*
value
)
{
char
s
[
16
];
int
fd
,
ret
,
len
;
len
=
sprintf
(
s
,
"%i
\n
"
,
*
value
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
return
-
1
;
ret
=
write
(
fd
,
s
,
len
);
close
(
fd
);
if
(
ret
<
0
)
return
-
1
;
if
(
ret
==
len
)
return
0
;
errno
=
EINVAL
;
return
-
1
;
}
/* And these two for the board structure */
static
inline
int
fmctdc_sysfs_get
(
struct
__fmctdc_board
*
b
,
char
*
name
,
uint32_t
*
resp
)
{
char
pathname
[
128
];
sprintf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fmctdc_sysfs_get
(
pathname
,
resp
);
}
static
inline
int
fmctdc_sysfs_set
(
struct
__fmctdc_board
*
b
,
char
*
name
,
uint32_t
*
value
)
{
char
pathname
[
128
];
sprintf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fmctdc_sysfs_set
(
pathname
,
value
);
}
static
inline
int
__fmctdc_command
(
struct
__fmctdc_board
*
b
,
uint32_t
cmd
)
{
return
fmctdc_sysfs_set
(
b
,
"command"
,
&
cmd
);
}
#endif
/* __FMCTDC_LIB_PRIVATE_H__ */
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