diff options
Diffstat (limited to 'io-module/gpio.c')
-rw-r--r-- | io-module/gpio.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/io-module/gpio.c b/io-module/gpio.c index 4a2d963..9e643a4 100644 --- a/io-module/gpio.c +++ b/io-module/gpio.c @@ -13,6 +13,22 @@ struct gpio_pin *gpio_pin_by_name(const char *name) { return NULL; } +// A GPIO pin number must only occur once. +struct gpio_pin *gpio_pin_by_num(unsigned num) { + int ipin = 0; + while(*(gpio_pins[ipin].name)) { + if (gpio_pins[ipin].pin.gpio == num) { + return &(gpio_pins[ipin]); + } + ipin++; + } + + log_error("pin numbered %u not found", num); + + return NULL; +} + + struct gpio_pin *gpio_pin_by_attr_name(const char *name) { struct gpio_pin *pin; |