Commit 8a2c09f5 authored by Henrik Nordstrom's avatar Henrik Nordstrom
Browse files

pio: Add = and ? pin commands for easier GPIO operation

parent bcdc4cd7
......@@ -149,9 +149,11 @@ static void usage(int rc )
fprintf(stderr, "usage: %s -i input [-o output] pin..\n", argv0);
fprintf(stderr, " print Show all pins\n");
fprintf(stderr, " Pxx Show pin\n");
fprintf(stderr, " Pxx<mode><pull><drive><data>\n Configure pin\n");
fprintf(stderr, " Pxx<mode><pull><drive><data>\n Configure pin\n");
fprintf(stderr, " Pxx=data,drive,pull\n Configure GPIO output\n");
fprintf(stderr, " Pxx?pull\n Configure GPIO input\n");
fprintf(stderr, " clean Clean input pins\n");
fprintf(stderr, "\n mode 0-7, 0=input, 1=ouput, 2-7 I/O\n");
fprintf(stderr, "\n mode 0-7, 0=input, 1=ouput, 2-7 I/O function\n");
fprintf(stderr, " pull 0=none, 1=up, 2=down\n");
fprintf(stderr, " drive 0-3, I/O drive level\n");
......@@ -196,29 +198,55 @@ static void cmd_set_pin(char *buf, const char *pin)
parse_pin(&port, &port_nr, pin);
if (!pio_get(buf, port, port_nr, &pio))
usage(1);
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.mul_sel, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.pull, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.drv_level, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.data, t);
if ((t = strchr(pin, '='))) {
pio.mul_sel = 1;
if (t) {
t++;
parse_int(&pio.data, t);
}
if (t)
t = strchr(t, ',');
if (t) {
t++;
parse_int(&pio.drv_level, t);
}
if (t)
t = strchr(t, ',');
if (t) {
t++;
parse_int(&pio.pull, t);
}
} else if ((t = strchr(pin, '?'))) {
pio.mul_sel = 0;
pio.data = 0;
pio.drv_level = 0;
if (t) {
t++;
parse_int(&pio.pull, t);
}
} else if ((t = strchr(pin, '<'))) {
if (t) {
t++;
parse_int(&pio.mul_sel, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.pull, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.drv_level, t);
}
if (t)
t = strchr(t, '<');
if (t) {
t++;
parse_int(&pio.data, t);
}
}
pio_set(buf, port, port_nr, &pio);
}
......
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