Skip to content
Snippets Groups Projects
Commit 2515a3f9 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

drivers/gpio: changed the way the mode is configured

- joined pushpull and dir into one single mode parameter
- with this enabled the configuration of open-drain mode
parent 0b2ffc21
No related branches found
No related tags found
No related merge requests found
......@@ -86,24 +86,24 @@ typedef unsigned int gpio_t;
#endif
/**
* @brief Definition of available pin directions
*/
#ifndef HAVE_GPIO_DIR_T
typedef enum {
GPIO_DIR_IN = 0, /**< configure pin as input */
GPIO_DIR_OUT = 1 /**< configure pin as output */
} gpio_dir_t;
#endif
/**
* @brief Definition of pull-up/pull-down modes
* @brief Available pin modes
*
* Generally, a pin can be configured to be input or output. In output mode, a
* pin can further be put into push-pull or open drain configuration. Though
* this is supported by most platforms, this is not always the case, so driver
* implementations may return an error code if a mode is not supported.
*/
#ifndef HAVE_GPIO_PP_T
#ifndef HAVE_GPIO_MODE_T
typedef enum {
GPIO_NOPULL = 0, /**< do not use internal pull resistors */
GPIO_PULLUP = 1, /**< enable internal pull-up resistor */
GPIO_PULLDOWN = 2 /**< enable internal pull-down resistor */
} gpio_pp_t;
GPIO_IN , /**< configure as input without pull resistor */
GPIO_IN_PD, /**< configure as input with pull-down resistor */
GPIO_IN_PU, /**< configure as input with pull-up resistor */
GPIO_OUT, /**< configure as output in push-pull mode */
GPIO_OD, /**< configure as output in open-drain mode without
* pull resistor */
GPIO_OD_PU /**< configure as output in open-drain mode with
* pull resistor enabled */
} gpio_mode_t;
#endif
/**
......@@ -146,7 +146,7 @@ typedef struct {
* @return 0 on success
* @return -1 on error
*/
int gpio_init(gpio_t pin, gpio_dir_t dir, gpio_pp_t pullup);
int gpio_init(gpio_t pin, gpio_mode_t mode);
/**
* @brief Initialize a GPIO pin for external interrupt usage
......@@ -165,8 +165,8 @@ int gpio_init(gpio_t pin, gpio_dir_t dir, gpio_pp_t pullup);
* @return 0 on success
* @return -1 on error
*/
int gpio_init_int(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank,
gpio_cb_t cb, void *arg);
int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
gpio_cb_t cb, void *arg);
/**
* @brief Enable pin's interrupt if configured as interrupt source
......
......@@ -31,8 +31,7 @@ extern "C" {
typedef struct {
const char *name; /**< name of the device connected to this pin */
gpio_t pin; /**< GPIO pin to initialize and expose */
gpio_dir_t dir; /**< use GPIO as input or output */
gpio_pp_t pull; /**< define the pull-up/pull-down mode */
gpio_mode_t mode; /**< pin mode to use */
} saul_gpio_params_t;
#ifdef __cplusplus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment