Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions samples/drivers/espi/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down