pio: Add = and ? pin commands for easier GPIO operation
This commit is contained in:
parent
bcdc4cd7ec
commit
8a2c09f575
78
pio.c
78
pio.c
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user