From 0f9fb09a53fc930b2b4eefe2f6c52776b4c11b34 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 1 Aug 2016 12:09:00 -0600 Subject: [PATCH] GPIO driver: Add an IOCTL command to get the pin type --- drivers/ioexpander/gpio.c | 15 +++++++++++++++ include/nuttx/ioexpander/gpio.h | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/ioexpander/gpio.c b/drivers/ioexpander/gpio.c index c19539bacc..137d988ee8 100644 --- a/drivers/ioexpander/gpio.c +++ b/drivers/ioexpander/gpio.c @@ -211,6 +211,21 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + /* Command: GPIOC_PINTYPE + * Description: Return the GPIO pin type. + * Argument: A pointer to an instance of type enum gpio_pintype_e + */ + + case GPIOC_PINTYPE: + { + FAR enum gpio_pintype_e *ptr = (FAR enum gpio_pintype_e *)((uintptr_t)arg); + DEBUGASSERT(ptr != NULL); + + *ptr = dev->gp_pintype; + ret = OK; + } + break; + /* Command: GPIOC_REGISTER * Description: Register to receive a signal whenever there an * interrupt is received on an input gpio pin. This diff --git a/include/nuttx/ioexpander/gpio.h b/include/nuttx/ioexpander/gpio.h index 682b12e1f3..7d8028e86f 100644 --- a/include/nuttx/ioexpander/gpio.h +++ b/include/nuttx/ioexpander/gpio.h @@ -60,6 +60,10 @@ * Argument: A pointer to an bool value to receive the result: * false=low value; true=high value. * + * Command: GPIOC_PINTYPE + * Description: Return the GPIO pin type. + * Argument: A pointer to an instance of type enum gpio_pintype_e + * * Command: GPIOC_REGISTER * Description: Register to receive a signal whenever there an interrupt * is received on an input gpio pin. This feature, of course, @@ -70,7 +74,8 @@ #define GPIOC_WRITE _GPIOC(1) #define GPIOC_READ _GPIOC(2) -#define GPIOC_REGISTER _GPIOC(3) +#define GPIOC_PINTYPE _GPIOC(3) +#define GPIOC_REGISTER _GPIOC(4) /**************************************************************************** * Public Types