diff options
| author | Luiz Otavio O Souza <loos@FreeBSD.org> | 2015-03-08 00:47:50 +0000 |
|---|---|---|
| committer | Luiz Otavio O Souza <loos@FreeBSD.org> | 2015-03-08 00:47:50 +0000 |
| commit | d752f0f69de80ecb93e4d64e8353218edbdbdccf (patch) | |
| tree | 9ddab736a8f0c968e0fae8da4325fc5853cdb54d /lib/libgpio | |
| parent | bf5d6cf0a970449cac82786a0dbd6c7e31adb181 (diff) | |
Notes
Diffstat (limited to 'lib/libgpio')
| -rw-r--r-- | lib/libgpio/gpio.3 | 10 | ||||
| -rw-r--r-- | lib/libgpio/gpio.c | 16 | ||||
| -rw-r--r-- | lib/libgpio/libgpio.h | 5 |
3 files changed, 29 insertions, 2 deletions
diff --git a/lib/libgpio/gpio.3 b/lib/libgpio/gpio.3 index 12b2d1eeed1f..67c988083b42 100644 --- a/lib/libgpio/gpio.3 +++ b/lib/libgpio/gpio.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 17, 2014 +.Dd March 7, 2015 .Dt GPIO 3 .Os .Sh NAME @@ -45,7 +45,9 @@ .Ft int .Fn gpio_pin_list "gpio_handle_t handle, gpio_config_t **pcfgs" .Ft int -.Fn gpio_pin_config "gpio_handle_t handle, gpio_config *cfg" +.Fn gpio_pin_config "gpio_handle_t handle, gpio_config_t *cfg" +.Ft int +.Fn gpio_pin_set_name "gpio_handle_t handle, gpio_pin_t pin, char *name" .Ft int .Fn gpio_pin_set_flags "gpio_handle_t handle, gpio_config_t *cfg" .Ft gpio_value_t @@ -111,6 +113,10 @@ variable which is part of the structure. .Pp The function +.Fn gpio_pin_set_name +sets the name used to describe a pin. +.Pp +The function .Fn gpio_pin_set_flags configures a pin with the flags passed in by the .Ft gpio_config_t diff --git a/lib/libgpio/gpio.c b/lib/libgpio/gpio.c index 8eb68712057a..7ec0955b096b 100644 --- a/lib/libgpio/gpio.c +++ b/lib/libgpio/gpio.c @@ -119,6 +119,22 @@ gpio_pin_config(gpio_handle_t handle, gpio_config_t *cfg) } int +gpio_pin_set_name(gpio_handle_t handle, gpio_pin_t pin, char *name) +{ + struct gpio_pin gppin; + + if (name == NULL) + return (-1); + bzero(&gppin, sizeof(gppin)); + gppin.gp_pin = pin; + strlcpy(gppin.gp_name, name, GPIOMAXNAME); + if (ioctl(handle, GPIOSETNAME, &gppin) < 0) + return (-1); + + return (0); +} + +int gpio_pin_set_flags(gpio_handle_t handle, gpio_config_t *cfg) { struct gpio_pin gppin; diff --git a/lib/libgpio/libgpio.h b/lib/libgpio/libgpio.h index b7486ebc5472..a832234ca13e 100644 --- a/lib/libgpio/libgpio.h +++ b/lib/libgpio/libgpio.h @@ -71,6 +71,11 @@ int gpio_pin_list(gpio_handle_t, gpio_config_t **); */ int gpio_pin_config(gpio_handle_t, gpio_config_t *); /* + * Sets the GPIO pin name. The pin number and pin name to be set are passed + * as parameters. + */ +int gpio_pin_set_name(gpio_handle_t, gpio_pin_t, char *); +/* * Sets the GPIO flags on a specific GPIO pin. The pin number and the flags * to be set are passed through the gpio_config_t structure. */ |
