gpio : Add support for input pull up/down modes
Make use of 'active_low' interface in sysfs for configuring input pin in pull up / pull down mode. C++ binding also has been added. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
3f932ac952
commit
bd3d9d8cab
@@ -84,6 +84,14 @@ typedef enum {
|
||||
MRAA_GPIO_EDGE_FALLING = 3 /**< Interrupt on falling only */
|
||||
} mraa_gpio_edge_t;
|
||||
|
||||
/**
|
||||
* Gpio input modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_ACTIVE_HIGH = 0, /**< Resistive High */
|
||||
MRAA_GPIO_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} mraa_gpio_input_mode_t;
|
||||
|
||||
/**
|
||||
* Initialise gpio_context, based on board number
|
||||
*
|
||||
@@ -218,6 +226,16 @@ int mraa_gpio_get_pin(mraa_gpio_context dev);
|
||||
*/
|
||||
int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Set Gpio input mode
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode Mode to set input pin state
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_input_mode(mraa_gpio_context dev, mraa_gpio_input_mode_t);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -69,6 +69,14 @@ typedef enum {
|
||||
EDGE_FALLING = 3 /**< Interrupt on falling only */
|
||||
} Edge;
|
||||
|
||||
/**
|
||||
* Gpio Input modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_IN_ACTIVE_HIGH = 0, /**< Resistive High */
|
||||
MODE_IN_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} InputMode;
|
||||
|
||||
/**
|
||||
* @brief API to General Purpose IO
|
||||
*
|
||||
@@ -316,6 +324,19 @@ class Gpio
|
||||
return mraa_gpio_get_pin(m_gpio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Gpio input mode
|
||||
*
|
||||
* @param mode The mode to change the gpio input
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
inputMode(InputMode mode)
|
||||
{
|
||||
return (Result )mraa_gpio_input_mode(m_gpio, (mraa_gpio_input_mode_t) mode);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
|
||||
Reference in New Issue
Block a user