Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Manchev
osie
Commits
b6f1c28c
Commit
b6f1c28c
authored
Mar 02, 2023
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sample latency program for Lime2.
parent
ee6b6bc3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
coupler/test_latency.c
coupler/test_latency.c
+59
-0
No files found.
coupler/test_latency.c
0 → 100644
View file @
b6f1c28c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* Simple C program which tests system latency by writing every cycle 1 or 0
* to respective GPIO (configured to STMP157-OLinuXino-LIME2 with STMP15X-SHIELD)
*/
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/gpio.h>
int
main
()
{
int
fd
;
struct
gpiohandle_request
led
;
struct
gpiohandle_data
data
;
/* Schema
* GND: pin 2
* : pin 9
* */
fd
=
open
(
"/dev/gpiochip1"
,
O_RDWR
);
if
(
fd
<
0
)
{
perror
(
"Error opening gpiochip"
);
return
-
1
;
}
/* Setup LED to output */
led
.
flags
=
GPIOHANDLE_REQUEST_OUTPUT
;
strcpy
(
led
.
consumer_label
,
"LED"
);
memset
(
led
.
default_values
,
0
,
sizeof
(
led
.
default_values
));
led
.
lines
=
1
;
led
.
lineoffsets
[
0
]
=
7
;
if
(
ioctl
(
fd
,
GPIO_GET_LINEHANDLE_IOCTL
,
&
led
)
<
0
)
{
perror
(
"Error setting GPIO to output"
);
close
(
fd
);
return
-
1
;
}
/* Let's set the LED */
int
i
;
int
b
=
1
;
for
(
i
=
1
;
i
<
100000000
;
++
i
)
{
data
.
values
[
0
]
=
b
;
if
(
b
)
b
=
0
;
else
b
=
1
;
if
(
ioctl
(
led
.
fd
,
GPIOHANDLE_SET_LINE_VALUES_IOCTL
,
&
data
)
<
0
)
perror
(
"Error setting GPIO to 1"
);
//printf("b=%d\n", b);
//sleep(2);
}
// close fds
close
(
fd
);
close
(
led
.
fd
);
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