Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
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
nexedi
tsn-measures
Commits
e7b3a4a5
Commit
e7b3a4a5
authored
Jul 16, 2021
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename GPIO variables
parent
578ce26a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
src/motor-control/src/server.c
src/motor-control/src/server.c
+15
-9
No files found.
src/motor-control/src/server.c
View file @
e7b3a4a5
...
@@ -30,6 +30,12 @@
...
@@ -30,6 +30,12 @@
#define ERROR_MARGIN_NS 400000
#define ERROR_MARGIN_NS 400000
// See this to compute the GPIO number based on port and pin number:
// https://olimex.wordpress.com/tag/gpio/
#define GPIO_DIRECTION_NUMBER 192 // PG0
#define GPIO_PULSE_NUMBER 193 // PG1
// Structs
// Structs
enum
TSNTask
{
RECV_PACKET_TASK
,
RTT_TASK
,
XDP_TASK
};
enum
TSNTask
{
RECV_PACKET_TASK
,
RTT_TASK
,
XDP_TASK
};
...
@@ -66,10 +72,10 @@ static pthread_cond_t emit_signal_ts_received;
...
@@ -66,10 +72,10 @@ static pthread_cond_t emit_signal_ts_received;
static
int
interval_us
;
static
int
interval_us
;
static
int
gpio
86
_fd
;
static
int
gpio
_pulse
_fd
;
static
int
gpio
84
_fd
;
static
int
gpio
_direction
_fd
;
static
int
gpio
86
_state
;
static
int
gpio
_pulse
_state
;
static
int
gpio
84
_state
;
static
int
gpio
_direction
_state
;
static
int
received_reverse_motor
=
0
;
static
int
received_reverse_motor
=
0
;
static
void
help
(
char
*
argv
[])
{
static
void
help
(
char
*
argv
[])
{
...
@@ -122,13 +128,13 @@ static void *emit_signal_thread(void *p) {
...
@@ -122,13 +128,13 @@ static void *emit_signal_thread(void *p) {
}
}
if
(
reverse_motor
)
{
if
(
reverse_motor
)
{
gpio
84_state
=
toggle_gpio
(
gpio84_fd
,
gpio84
_state
);
gpio
_direction_state
=
toggle_gpio
(
gpio_direction_fd
,
gpio_direction
_state
);
reverse_motor
=
0
;
reverse_motor
=
0
;
}
}
else
{
else
{
gpio
86_state
=
toggle_gpio
(
gpio86_fd
,
gpio86
_state
);
gpio
_pulse_state
=
toggle_gpio
(
gpio_pulse_fd
,
gpio_pulse
_state
);
usleep
(
3
);
usleep
(
3
);
gpio
86_state
=
toggle_gpio
(
gpio86_fd
,
gpio86
_state
);
gpio
_pulse_state
=
toggle_gpio
(
gpio_pulse_fd
,
gpio_pulse
_state
);
}
}
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
...
@@ -299,8 +305,8 @@ int main(int argc, char *argv[]) {
...
@@ -299,8 +305,8 @@ int main(int argc, char *argv[]) {
pthread_mutex_init
(
&
emit_signal_mutex
,
NULL
);
pthread_mutex_init
(
&
emit_signal_mutex
,
NULL
);
pthread_cond_init
(
&
emit_signal_ts_received
,
NULL
);
pthread_cond_init
(
&
emit_signal_ts_received
,
NULL
);
gpio
86_state
=
enable_gpio
(
&
gpio86_fd
,
86
);
gpio
_pulse_state
=
enable_gpio
(
&
gpio_pulse_fd
,
GPIO_PULSE_NUMBER
);
gpio
84_state
=
enable_gpio
(
&
gpio84_fd
,
84
);
gpio
_direction_state
=
enable_gpio
(
&
gpio_direction_fd
,
GPIO_DIRECTION_NUMBER
);
create_thread
(
tsn_thread
);
create_thread
(
tsn_thread
);
create_thread
(
emit_signal_thread
);
create_thread
(
emit_signal_thread
);
...
...
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