From ae0beee99e9f520cd75e71dbea89d695e596fe3e Mon Sep 17 00:00:00 2001 From: crasbe Date: Wed, 14 May 2025 00:02:46 +0200 Subject: [PATCH] cpu/cc2538: distinguish between GPIO_OD and GPIO_OD_PU The CC2538 does not support "Open Drain" or "Open Drain with Pullup" outputs. However problems can arrise from setting both macros to the same value. This commit sets them to separate values which are both invalid to avoid conflicts with other applications. --- cpu/cc2538/include/periph_cpu.h | 2 +- cpu/cc2538/periph/gpio.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu/cc2538/include/periph_cpu.h b/cpu/cc2538/include/periph_cpu.h index 2ded24080c27..4e29617b3607 100644 --- a/cpu/cc2538/include/periph_cpu.h +++ b/cpu/cc2538/include/periph_cpu.h @@ -153,7 +153,7 @@ typedef enum { GPIO_IN_PD = ((uint8_t)OVERRIDE_PULLDOWN), /**< input, pull-down */ GPIO_IN_PU = ((uint8_t)OVERRIDE_PULLUP), /**< input, pull-up */ GPIO_OUT = ((uint8_t)OVERRIDE_ENABLE), /**< output */ - GPIO_OD = (0xff), /**< not supported */ + GPIO_OD = (0xfe), /**< not supported */ GPIO_OD_PU = (0xff) /**< not supported */ } gpio_mode_t; /** @} */ diff --git a/cpu/cc2538/periph/gpio.c b/cpu/cc2538/periph/gpio.c index 82bf84e416e7..4ed0cd709229 100644 --- a/cpu/cc2538/periph/gpio.c +++ b/cpu/cc2538/periph/gpio.c @@ -31,7 +31,7 @@ #define ENABLE_DEBUG 0 #include "debug.h" -#define MODE_NOTSUP (0xff) +#define MODE_NOTSUP (0xf0) #ifdef MODULE_PERIPH_GPIO_IRQ static gpio_isr_ctx_t isr_ctx[4][8]; @@ -100,7 +100,7 @@ static inline uint8_t _pp_num(gpio_t pin) int gpio_init(gpio_t pin, gpio_mode_t mode) { /* check if mode is valid */ - if (mode == MODE_NOTSUP) { + if (mode >= MODE_NOTSUP) { return -1; }