Changeset View
Changeset View
Standalone View
Standalone View
./usr.sbin/gpioctl/gpioctl.c
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | static struct flag_desc gpio_flags[] = { | ||||
{ "OD", GPIO_PIN_OPENDRAIN }, | { "OD", GPIO_PIN_OPENDRAIN }, | ||||
{ "PP", GPIO_PIN_PUSHPULL }, | { "PP", GPIO_PIN_PUSHPULL }, | ||||
{ "TS", GPIO_PIN_TRISTATE }, | { "TS", GPIO_PIN_TRISTATE }, | ||||
{ "PU", GPIO_PIN_PULLUP }, | { "PU", GPIO_PIN_PULLUP }, | ||||
{ "PD", GPIO_PIN_PULLDOWN }, | { "PD", GPIO_PIN_PULLDOWN }, | ||||
{ "II", GPIO_PIN_INVIN }, | { "II", GPIO_PIN_INVIN }, | ||||
{ "IO", GPIO_PIN_INVOUT }, | { "IO", GPIO_PIN_INVOUT }, | ||||
{ "PULSE", GPIO_PIN_PULSATE }, | { "PULSE", GPIO_PIN_PULSATE }, | ||||
{ "INTR_LL", GPIO_INTR_LEVEL_LOW }, | |||||
{ "INTR_LH", GPIO_INTR_LEVEL_HIGH }, | |||||
{ "INTR_ER", GPIO_INTR_EDGE_RISING }, | |||||
{ "INTR_EF", GPIO_INTR_EDGE_FALLING }, | |||||
{ "INTR_EB", GPIO_INTR_EDGE_BOTH }, | |||||
{ NULL, 0 }, | { NULL, 0 }, | ||||
}; | }; | ||||
int str2cap(const char *str); | int str2cap(const char *str); | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
} | } | ||||
if (config) { | if (config) { | ||||
flags = 0; | flags = 0; | ||||
for (i = 1; i < argc; i++) { | for (i = 1; i < argc; i++) { | ||||
flag = str2cap(argv[i]); | flag = str2cap(argv[i]); | ||||
if (flag < 0) | if (flag < 0) | ||||
fail("Invalid flag: %s\n", argv[i]); | fail("Invalid flag: %s\n", argv[i]); | ||||
else if ((flag & GPIO_INTR_MASK) != 0) | |||||
fail("Interrupt capability %s cannot be set as configuration flag\n", argv[i]); | |||||
flags |= flag; | flags |= flag; | ||||
} | } | ||||
pin.g_pin = pinn; | pin.g_pin = pinn; | ||||
pin.g_flags = flags; | pin.g_flags = flags; | ||||
if (gpio_pin_set_flags(handle, &pin) < 0) { | if (gpio_pin_set_flags(handle, &pin) < 0) { | ||||
perror("gpio_pin_set_flags"); | perror("gpio_pin_set_flags"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
Show All 38 Lines |