Skip to content

Commit d8bafe4

Browse files
Glauber Maroto Ferreiracfriedt
authored andcommitted
esp32: drivers: gpio: remove pin offset
this allows using a pin numbering scheme as per Espressif's documentation and HAL usage, where pin counting does not wrap up when reaching a given number. Signed-off-by: Glauber Maroto Ferreira <[email protected]>
1 parent c67b44c commit d8bafe4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/gpio/gpio_esp32.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,13 @@ static inline bool gpio_pin_is_output_capable(uint32_t pin)
8787
return ((BIT(pin) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0);
8888
}
8989

90-
static inline int gpio_get_pin_offset(const struct device *dev)
91-
{
92-
struct gpio_esp32_config *const cfg = DEV_CFG(dev);
93-
94-
return ((cfg->gpio_port) ? 32 : 0);
95-
}
96-
9790
static int gpio_esp32_config(const struct device *dev,
9891
gpio_pin_t pin,
9992
gpio_flags_t flags)
10093
{
10194
struct gpio_esp32_config *const cfg = DEV_CFG(dev);
10295
struct gpio_esp32_data *data = dev->data;
103-
uint32_t io_pin = pin + gpio_get_pin_offset(dev);
96+
uint32_t io_pin = (uint32_t) pin;
10497
uint32_t key;
10598
int ret = 0;
10699

@@ -338,7 +331,7 @@ static int gpio_esp32_pin_interrupt_configure(const struct device *port,
338331
enum gpio_int_trig trig)
339332
{
340333
struct gpio_esp32_config *const cfg = DEV_CFG(port);
341-
uint32_t io_pin = pin + gpio_get_pin_offset(port);
334+
uint32_t io_pin = (uint32_t) pin;
342335
int intr_trig_mode = convert_int_type(mode, trig);
343336
uint32_t key;
344337

0 commit comments

Comments
 (0)