gpio: Add support for push-pull/open-drain output mode
This attribute is not part of gpio standard attributes so it's necessary to implement a custom version of this function Signed-off-by: Nicola Ponte <nicola.ponte@u-blox.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
be9fcf2b2d
commit
7d6164c136
@@ -92,6 +92,15 @@ typedef enum {
|
||||
MRAA_GPIO_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} mraa_gpio_input_mode_t;
|
||||
|
||||
|
||||
/**
|
||||
* Gpio output driver modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_OPEN_DRAIN = 0, /**< Open Drain Configuration */
|
||||
MRAA_GPIO_PUSH_PULL = 1, /**< Push Pull Configuration */
|
||||
} mraa_gpio_out_driver_mode_t;
|
||||
|
||||
/**
|
||||
* Initialise gpio_context, based on board number
|
||||
*
|
||||
@@ -235,6 +244,14 @@ int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
|
||||
*/
|
||||
mraa_result_t mraa_gpio_input_mode(mraa_gpio_context dev, mraa_gpio_input_mode_t);
|
||||
|
||||
/**
|
||||
* Set Gpio output driver mode. This is not a standard feature, it needs custom implementation for each board
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode Set output driver mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_out_driver_mode(mraa_gpio_context dev, mraa_gpio_out_driver_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -77,6 +77,14 @@ typedef enum {
|
||||
MODE_IN_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} InputMode;
|
||||
|
||||
/**
|
||||
* Gpio output driver modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_OUT_OPEN_DRAIN = 0, /**< Open Drain Configuration */
|
||||
MODE_OUT_PUSH_PULL = 1, /**< Push Pull Configuration */
|
||||
} OutputMode;
|
||||
|
||||
/**
|
||||
* @brief API to General Purpose IO
|
||||
*
|
||||
@@ -336,6 +344,17 @@ class Gpio
|
||||
return (Result )mraa_gpio_input_mode(m_gpio, (mraa_gpio_input_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Gpio output driver mode
|
||||
*
|
||||
* @param mode @param mode Set output driver mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
outputMode(OutputMode mode)
|
||||
{
|
||||
return (Result) mraa_gpio_out_driver_mode(m_gpio, (mraa_gpio_out_driver_mode_t) mode);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
|
||||
Reference in New Issue
Block a user