Skip to content

Commit

Permalink
drivers/gpio: changed the way the mode is configured
Browse files Browse the repository at this point in the history
- joined pushpull and dir into one single mode parameter
- with this enabled the configuration of open-drain mode
  • Loading branch information
haukepetersen committed Feb 20, 2016
1 parent 4ea1a56 commit 57ba62e
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions drivers/include/periph/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 57ba62e

Please sign in to comment.