Commit e7b3a4a5 authored by Joanne Hugé's avatar Joanne Hugé

Rename GPIO variables

parent 578ce26a
...@@ -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 gpio86_fd; static int gpio_pulse_fd;
static int gpio84_fd; static int gpio_direction_fd;
static int gpio86_state; static int gpio_pulse_state;
static int gpio84_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) {
gpio84_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 {
gpio86_state = toggle_gpio(gpio86_fd, gpio86_state); gpio_pulse_state = toggle_gpio(gpio_pulse_fd, gpio_pulse_state);
usleep(3); usleep(3);
gpio86_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);
gpio86_state = enable_gpio(&gpio86_fd, 86); gpio_pulse_state = enable_gpio(&gpio_pulse_fd, GPIO_PULSE_NUMBER);
gpio84_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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment