samples: boards: nrf: update battery sample for new GPIO API

Replace legacy API and configuration.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-02-04 08:08:38 -06:00 committed by Carles Cufí
commit 86d1b7d2c8

View file

@ -90,11 +90,8 @@ static int divider_setup(void)
LOG_ERR("Failed to get GPIO %s", gcp->label); LOG_ERR("Failed to get GPIO %s", gcp->label);
return -ENOENT; return -ENOENT;
} }
rc = gpio_pin_write(ddp->gpio, gcp->pin, 0); rc = gpio_pin_configure(ddp->gpio, gcp->pin,
if (rc == 0) { GPIO_OUTPUT_INACTIVE | gcp->flags);
rc = gpio_pin_configure(ddp->gpio, gcp->pin,
gcp->flags | GPIO_DIR_OUT);
}
if (rc != 0) { if (rc != 0) {
LOG_ERR("Failed to control feed %s.%u: %d", LOG_ERR("Failed to control feed %s.%u: %d",
gcp->label, gcp->pin, rc); gcp->label, gcp->pin, rc);
@ -152,7 +149,7 @@ int battery_measure_enable(bool enable)
rc = 0; rc = 0;
if (ddp->gpio) { if (ddp->gpio) {
rc = gpio_pin_write(ddp->gpio, gcp->pin, enable); rc = gpio_pin_set(ddp->gpio, gcp->pin, enable);
} }
} }
return rc; return rc;