driver/sensor: lps22hh: update to use new GPIO API

Get rid of all the deprecated functions and definitions
replacing them with the new ones.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2019-12-06 14:15:37 +01:00 committed by Carles Cufí
commit cde71b4f75
5 changed files with 17 additions and 10 deletions

View file

@ -203,6 +203,7 @@ static const struct lps22hh_config lps22hh_config = {
#ifdef CONFIG_LPS22HH_TRIGGER #ifdef CONFIG_LPS22HH_TRIGGER
.drdy_port = DT_INST_0_ST_LPS22HH_DRDY_GPIOS_CONTROLLER, .drdy_port = DT_INST_0_ST_LPS22HH_DRDY_GPIOS_CONTROLLER,
.drdy_pin = DT_INST_0_ST_LPS22HH_DRDY_GPIOS_PIN, .drdy_pin = DT_INST_0_ST_LPS22HH_DRDY_GPIOS_PIN,
.drdy_flags = DT_INST_0_ST_LPS22HH_DRDY_GPIOS_FLAGS,
#endif #endif
#if defined(DT_ST_LPS22HH_BUS_SPI) #if defined(DT_ST_LPS22HH_BUS_SPI)
.bus_init = lps22hh_spi_init, .bus_init = lps22hh_spi_init,

View file

@ -36,6 +36,7 @@ struct lps22hh_config {
#ifdef CONFIG_LPS22HH_TRIGGER #ifdef CONFIG_LPS22HH_TRIGGER
const char *drdy_port; const char *drdy_port;
u8_t drdy_pin; u8_t drdy_pin;
u8_t drdy_flags;
#endif #endif
#ifdef DT_ST_LPS22HH_BUS_I2C #ifdef DT_ST_LPS22HH_BUS_I2C
u16_t i2c_slv_addr; u16_t i2c_slv_addr;

View file

@ -78,7 +78,8 @@ static void lps22hh_handle_interrupt(void *arg)
lps22hh->handler_drdy(dev, &drdy_trigger); lps22hh->handler_drdy(dev, &drdy_trigger);
} }
gpio_pin_enable_callback(lps22hh->gpio, cfg->drdy_pin); gpio_pin_interrupt_configure(lps22hh->gpio, cfg->drdy_pin,
GPIO_INT_EDGE_TO_ACTIVE);
} }
static void lps22hh_gpio_callback(struct device *dev, static void lps22hh_gpio_callback(struct device *dev,
@ -90,7 +91,8 @@ static void lps22hh_gpio_callback(struct device *dev,
ARG_UNUSED(pins); ARG_UNUSED(pins);
gpio_pin_disable_callback(dev, cfg->drdy_pin); gpio_pin_interrupt_configure(lps22hh->gpio, cfg->drdy_pin,
GPIO_INT_DISABLE);
#if defined(CONFIG_LPS22HH_TRIGGER_OWN_THREAD) #if defined(CONFIG_LPS22HH_TRIGGER_OWN_THREAD)
k_sem_give(&lps22hh->gpio_sem); k_sem_give(&lps22hh->gpio_sem);
@ -151,8 +153,7 @@ int lps22hh_init_interrupt(struct device *dev)
#endif /* CONFIG_LPS22HH_TRIGGER_OWN_THREAD */ #endif /* CONFIG_LPS22HH_TRIGGER_OWN_THREAD */
ret = gpio_pin_configure(lps22hh->gpio, cfg->drdy_pin, ret = gpio_pin_configure(lps22hh->gpio, cfg->drdy_pin,
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | GPIO_INPUT | cfg->drdy_flags);
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
if (ret < 0) { if (ret < 0) {
LOG_DBG("Could not configure gpio"); LOG_DBG("Could not configure gpio");
return ret; return ret;
@ -166,16 +167,12 @@ int lps22hh_init_interrupt(struct device *dev)
return -EIO; return -EIO;
} }
/* configure interrupt active high */
if (lps22hh_pin_polarity_set(lps22hh->ctx, LPS22HH_ACTIVE_HIGH) < 0) {
return -EIO;
}
/* enable interrupt in pulse mode */ /* enable interrupt in pulse mode */
if (lps22hh_int_notification_set(lps22hh->ctx, if (lps22hh_int_notification_set(lps22hh->ctx,
LPS22HH_INT_PULSED) < 0) { LPS22HH_INT_PULSED) < 0) {
return -EIO; return -EIO;
} }
return gpio_pin_enable_callback(lps22hh->gpio, cfg->drdy_pin); return gpio_pin_interrupt_configure(lps22hh->gpio, cfg->drdy_pin,
GPIO_INT_EDGE_TO_ACTIVE);
} }

View file

@ -14,3 +14,7 @@ properties:
type: phandle-array type: phandle-array
required: false required: false
description: DRDY pin description: DRDY pin
This pin defaults to active high when produced by the sensor.
The property value should ensure the flags properly describe
the signal that is presented to the driver.

View file

@ -14,3 +14,7 @@ properties:
type: phandle-array type: phandle-array
required: false required: false
description: DRDY pin description: DRDY pin
This pin defaults to active high when produced by the sensor.
The property value should ensure the flags properly describe
the signal that is presented to the driver.