driver/sensor: iis3dhhc: 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:34:48 +01:00 committed by Carles Cufí
commit 0ae55c7ce9
5 changed files with 16 additions and 5 deletions

View file

@ -223,9 +223,11 @@ static const struct iis3dhhc_config iis3dhhc_config = {
#ifdef CONFIG_IIS3DHHC_DRDY_INT1
.int_port = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_CONTROLLER_0,
.int_pin = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_PIN_0,
.int_flags = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_FLAGS_0,
#else
.int_port = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_CONTROLLER_1,
.int_pin = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_PIN_1,
.int_flags = DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_FLAGS_1,
#endif /* CONFIG_IIS3DHHC_DRDY_INT1 */
#endif /* CONFIG_IIS3DHHC_TRIGGER */
#if defined(DT_ST_IIS3DHHC_BUS_SPI)

View file

@ -30,6 +30,7 @@ struct iis3dhhc_config {
#ifdef CONFIG_IIS3DHHC_TRIGGER
const char *int_port;
u8_t int_pin;
u8_t int_flags;
#endif
#ifdef DT_ST_IIS3DHHC_BUS_SPI
struct spi_config spi_conf;

View file

@ -73,7 +73,8 @@ static void iis3dhhc_handle_interrupt(void *arg)
iis3dhhc->handler_drdy(dev, &drdy_trigger);
}
gpio_pin_enable_callback(iis3dhhc->gpio, cfg->int_pin);
gpio_pin_interrupt_configure(iis3dhhc->gpio, cfg->int_pin,
GPIO_INT_EDGE_TO_ACTIVE);
}
static void iis3dhhc_gpio_callback(struct device *dev,
@ -85,7 +86,8 @@ static void iis3dhhc_gpio_callback(struct device *dev,
ARG_UNUSED(pins);
gpio_pin_disable_callback(dev, cfg->int_pin);
gpio_pin_interrupt_configure(iis3dhhc->gpio, cfg->int_pin,
GPIO_INT_DISABLE);
#if defined(CONFIG_IIS3DHHC_TRIGGER_OWN_THREAD)
k_sem_give(&iis3dhhc->gpio_sem);
@ -146,8 +148,7 @@ int iis3dhhc_init_interrupt(struct device *dev)
#endif /* CONFIG_IIS3DHHC_TRIGGER_OWN_THREAD */
ret = gpio_pin_configure(iis3dhhc->gpio, cfg->int_pin,
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
GPIO_INPUT | cfg->int_flags);
if (ret < 0) {
LOG_DBG("Could not configure gpio");
return ret;
@ -167,5 +168,6 @@ int iis3dhhc_init_interrupt(struct device *dev)
return -EIO;
}
return gpio_pin_enable_callback(iis3dhhc->gpio, cfg->int_pin);
return gpio_pin_interrupt_configure(iis3dhhc->gpio, cfg->int_pin,
GPIO_INT_EDGE_TO_ACTIVE);
}

View file

@ -13,3 +13,7 @@ properties:
type: phandle-array
required: false
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

@ -462,8 +462,10 @@
#define DT_INST_0_ST_IIS3DHHC_BUS_NAME ""
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_CONTROLLER_0 ""
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_PIN_0 0
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_FLAGS_0 0
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_CONTROLLER_1 ""
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_PIN_1 0
#define DT_INST_0_ST_IIS3DHHC_IRQ_GPIOS_FLAGS_1 0
#define DT_INST_0_ST_IIS3DHHC_SPI_MAX_FREQUENCY 6400000
#define DT_ST_IIS3DHHC_BUS_SPI 1
#endif