Skip to content

Commit ac450be

Browse files
committed
i2c: gpio_i2c_switch: fix gpio api misuse
Use GPIO_OUTPUT_INACTIVE to initialize the pin so that the ACTIVE_LOW DT flag is honored and use the gpio_pin_set_dt functions to set the (logical) value of the pin instead of gpio_pin_configure_dt, that tries to reconfigure the pin each time. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 9a44f7f commit ac450be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/i2c/gpio_i2c_switch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ static int gpio_i2c_switch_transfer(const struct device *dev, struct i2c_msg *ms
5151
}
5252

5353
/* enable switch */
54-
gpio_pin_configure_dt(&config->gpio, GPIO_OUTPUT_HIGH);
54+
gpio_pin_set_dt(&config->gpio, 1);
5555
k_busy_wait(GPIO_I2C_TOGGLE_DELAY_US);
5656

5757
res = i2c_transfer(config->bus, msgs, num_msgs, addr);
5858

5959
/* disable switch */
60-
gpio_pin_configure_dt(&config->gpio, GPIO_OUTPUT_LOW);
60+
gpio_pin_set_dt(&config->gpio, 0);
6161
k_busy_wait(GPIO_I2C_TOGGLE_DELAY_US);
6262
k_mutex_unlock(&data->lock);
6363

@@ -76,7 +76,7 @@ static int gpio_i2c_switch_init(const struct device *dev)
7676

7777
k_mutex_init(&data->lock);
7878

79-
return gpio_pin_configure_dt(&config->gpio, GPIO_OUTPUT_LOW);
79+
return gpio_pin_configure_dt(&config->gpio, GPIO_OUTPUT_INACTIVE);
8080
}
8181

8282
#define DEFINE_GPIO_I2C_SWITCH(inst) \

0 commit comments

Comments
 (0)