From e551551047b5c7f4e6445ad2744fa90151376380 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Tue, 28 Jan 2020 16:02:19 -0600 Subject: [PATCH] samples: drivers: espi: update to new GPIO API Treat Kconfig-specific GPIOs as active-high (default) and use the logic-level API to interact with them. Signed-off-by: Peter Bigot --- samples/drivers/espi/src/main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/samples/drivers/espi/src/main.c b/samples/drivers/espi/src/main.c index 7008efc973f7d..104f1251180fa 100644 --- a/samples/drivers/espi/src/main.c +++ b/samples/drivers/espi/src/main.c @@ -135,14 +135,13 @@ int espi_init(void) static int wait_for_pin(struct device *dev, u8_t pin, u16_t timeout, u32_t exp_level) { - int ret; + int level; u16_t loop_cnt = timeout; - u32_t level; do { - ret = gpio_pin_read(dev, pin, &level); - if (ret) { - printk("Failed to read %x %d\n", pin, ret); + level = gpio_pin_get(dev, pin); + if (level < 0) { + printk("Failed to read %x %d\n", pin, level); return -EIO; } @@ -292,19 +291,21 @@ int espi_test(void) LOG_INF("Hello eSPI test! %s\n", CONFIG_BOARD); #ifdef CONFIG_ESPI_GPIO_DEV_NEEDED - ret = gpio_pin_configure(gpio_dev0, CONFIG_PWRGD_PIN, GPIO_DIR_IN); + ret = gpio_pin_configure(gpio_dev0, CONFIG_PWRGD_PIN, + GPIO_INPUT | GPIO_ACTIVE_HIGH); if (ret) { printk("Unable to configure %d:%d\n", CONFIG_PWRGD_PIN, ret); return ret; } - ret = gpio_pin_configure(gpio_dev1, CONFIG_ESPI_INIT_PIN, GPIO_DIR_OUT); + ret = gpio_pin_configure(gpio_dev1, CONFIG_ESPI_INIT_PIN, + GPIO_OUTPUT | GPIO_ACTIVE_HIGH); if (ret) { LOG_WRN("Unable to config %d: %d\n", CONFIG_ESPI_INIT_PIN, ret); return ret; } - ret = gpio_pin_write(gpio_dev1, CONFIG_ESPI_INIT_PIN, 0); + ret = gpio_pin_set(gpio_dev1, CONFIG_ESPI_INIT_PIN, 0); if (ret) { LOG_WRN("Unable to initialize %d\n", CONFIG_ESPI_INIT_PIN); return -1; @@ -320,7 +321,7 @@ int espi_test(void) return ret; } - ret = gpio_pin_write(gpio_dev1, CONFIG_ESPI_INIT_PIN, 1); + ret = gpio_pin_set(gpio_dev1, CONFIG_ESPI_INIT_PIN, 1); if (ret) { printk("Failed to write %x %d\n", CONFIG_ESPI_INIT_PIN, ret); return ret;