Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Verbose error message on GPIO signal change failure
Browse files Browse the repository at this point in the history
  • Loading branch information
romansavrulin authored and tormodvolden committed Apr 17, 2017
1 parent d5df420 commit 7b5b33a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions init.c
Expand Up @@ -32,6 +32,7 @@
#include "serial.h"
#include "stm32.h"
#include "port.h"
#include "utils.h"

struct gpio_list {
struct gpio_list *next;
Expand Down Expand Up @@ -237,11 +238,13 @@ static int gpio_sequence(struct port_interface *port, const char *s, size_t l)
if (!delimiter) { /* actual gpio/port signal driving */
if (gpio < 0) {
gpio = -gpio;
fprintf(stdout, " setting port signal %.3s to %i\n", sig_str, level);
fprintf(stdout, " setting port signal %.3s to %i... ", sig_str, level);
ret = (port->gpio(port, gpio, level) != PORT_ERR_OK);
printStatus(stdout, ret);
} else {
fprintf(stdout, " setting gpio %i to %i\n", gpio, level);
fprintf(stdout, " setting gpio %i to %i... ", gpio, level);
ret = (drive_gpio(gpio, level, &gpio_to_release) != 1);
printStatus(stdout, ret);
}
}

Expand Down
7 changes: 7 additions & 0 deletions utils.c
Expand Up @@ -43,3 +43,10 @@ uint32_t le_u32(const uint32_t v) {
((v & 0x000000FF) << 24);
return v;
}

void printStatus(FILE *fd, int condition){
if(condition)
fprintf(fd, "Error!\n");
else
fprintf(fd, "OK\n");
}
3 changes: 3 additions & 0 deletions utils.h
Expand Up @@ -22,9 +22,12 @@
#define _H_UTILS

#include <stdint.h>
#include <stdio.h>

char cpu_le();
uint32_t be_u32(const uint32_t v);
uint32_t le_u32(const uint32_t v);

void printStatus(FILE *fd, int condition);

#endif

0 comments on commit 7b5b33a

Please sign in to comment.