diff --git a/cpu/atmega_common/include/periph_cpu_common.h b/cpu/atmega_common/include/periph_cpu_common.h index bf6627072f..3b5a5756b9 100644 --- a/cpu/atmega_common/include/periph_cpu_common.h +++ b/cpu/atmega_common/include/periph_cpu_common.h @@ -231,6 +231,16 @@ typedef enum { GPIO_TRIGGER_LEVEL_HIGH = 0xff, /**< not supported */ } gpio_irq_trig_t; +#define HAVE_GPIO_STATE_T +typedef enum { + GPIO_INPUT, + GPIO_OUTPUT_PUSH_PULL, + GPIO_OUTPUT_OPEN_DRAIN, /**< not supported */ + GPIO_OUTPUT_OPEN_SOURCE, /**< not supported */ + GPIO_USED_BY_PERIPHERAL, /**< not supported */ + GPIO_DISCONNECT = GPIO_INPUT, +} gpio_state_t; + #define HAVE_GPIO_LL_PREPARE_WRITE_ALL_PINS #define HAVE_GPIO_LL_PREPARE_WRITE diff --git a/cpu/atmega_common/periph/gpio_ll.c b/cpu/atmega_common/periph/gpio_ll.c index 3bd5eec653..f47beb5a60 100644 --- a/cpu/atmega_common/periph/gpio_ll.c +++ b/cpu/atmega_common/periph/gpio_ll.c @@ -40,7 +40,7 @@ static void _set_dir(gpio_port_t port, uint8_t pin, bool output) p->ddr |= 1U << pin; } else { - p-> ddr &= ~(1U << pin); + p->ddr &= ~(1U << pin); } } @@ -59,8 +59,7 @@ static void _set_pull_config(gpio_port_t port, uint8_t pin, gpio_pull_t pull) int gpio_ll_init(gpio_port_t port, uint8_t pin, gpio_conf_t conf) { if ((conf.pull > GPIO_PULL_UP) - || (conf.state == GPIO_OUTPUT_OPEN_DRAIN) - || (conf.state == GPIO_OUTPUT_OPEN_SOURCE)) { + || (conf.state > GPIO_OUTPUT_PUSH_PULL)) { return -ENOTSUP; }