Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AsyncArt
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
AsyncArt
Commits
22b98a70
Commit
22b98a70
authored
Aug 24, 2019
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simple program to control the pipeline by using the iCEstick UART
parent
f298b2b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
Makefile
demo/software/Makefile
+21
-0
micropipeline-control.c
demo/software/micropipeline-control.c
+77
-0
No files found.
demo/software/Makefile
0 → 100644
View file @
22b98a70
IDIR
=
./
CFLAGS
=
-Wall
-I
$(IDIR)
LDFLAGS
=
LIBS
=
SOURCES
=
micropipeline-control.c
OBJECTS
=
$
(
SOURCES:.c
=
.o
)
EXECUTABLE
=
micropipeline-control
all
:
$(SOURCES) $(EXECUTABLE)
$(EXECUTABLE)
:
$(OBJECTS)
$(CC)
$(LDFLAGS)
$(OBJECTS)
-o
$@
$(CFLAGS)
$(LIBS)
.c.o
:
$(CC)
-c
$(CFLAGS)
$<
-o
$@
clean
:
rm
-f
$(EXECUTABLE)
*
.o
.PHONY
:
clean
demo/software/micropipeline-control.c
0 → 100644
View file @
22b98a70
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
int
configure_uart
(
int
fd
,
int
baudrate
)
{
struct
termios
tty
;
if
(
tcgetattr
(
fd
,
&
tty
)
<
0
)
{
printf
(
"Error from tcgetattr: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
cfsetospeed
(
&
tty
,
(
speed_t
)
baudrate
);
cfsetispeed
(
&
tty
,
(
speed_t
)
baudrate
);
tty
.
c_cflag
|=
(
CLOCAL
|
CREAD
);
tty
.
c_cflag
&=
~
CSIZE
;
tty
.
c_cflag
|=
CS8
;
tty
.
c_cflag
&=
~
PARENB
;
tty
.
c_cflag
&=
~
CSTOPB
;
tty
.
c_cflag
&=
~
CRTSCTS
;
tty
.
c_iflag
&=
~
(
IGNBRK
|
BRKINT
|
PARMRK
|
ISTRIP
|
INLCR
|
IGNCR
|
ICRNL
|
IXON
);
tty
.
c_lflag
&=
~
(
ECHO
|
ECHONL
|
ICANON
|
ISIG
|
IEXTEN
);
tty
.
c_oflag
&=
~
OPOST
;
tty
.
c_cc
[
VMIN
]
=
1
;
tty
.
c_cc
[
VTIME
]
=
1
;
if
(
tcsetattr
(
fd
,
TCSANOW
,
&
tty
)
!=
0
)
{
printf
(
"Error from tcsetattr: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
int
wlen
;
char
value
;
if
(
argc
!=
3
)
{
fprintf
(
stderr
,
"
\n
Usage:
\t
%s portname data
\n
"
"
\t
portname : serial port device
\n
"
"
\t
data : data to be written
\n\n
"
,
argv
[
0
]);
exit
(
1
);
}
char
*
portname
=
argv
[
1
];
value
=
(
char
)
strtoul
(
argv
[
2
],
0
,
0
);
fd
=
open
(
portname
,
O_RDWR
|
O_NOCTTY
|
O_SYNC
);
if
(
fd
<
0
)
{
printf
(
"Error opening %s: %s
\n
"
,
portname
,
strerror
(
errno
));
return
-
1
;
}
configure_uart
(
fd
,
B115200
);
char
command_write
[
1
]
=
{
value
};
wlen
=
write
(
fd
,
command_write
,
1
);
if
(
wlen
!=
1
)
{
printf
(
"Error from write: %d, %d
\n
"
,
wlen
,
errno
);
}
tcdrain
(
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