Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion boards/arm/96b_argonkey/96b_argonkey.dts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
compatible = "st,lsm6dsl";
reg = <1>;
spi-max-frequency = <1000000>;
irq-gpios = <&gpiob 1 0>;
irq-gpios = <&gpiob 1 GPIO_ACTIVE_HIGH>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already addressed it in #21203. I think it is the proper place (96b_argonkey changes)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But can be done also in this commit honestly.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care where it's done. I'll leave it in here for now, there should be no conflict no matter which gets merged first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avisconti Do you have objections to this PR other than that it updates the devicetree binding that it depends on? I don't think I can remove that, unless #21203 is merged first and then this is rebased on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avisconti Do you have objections to this PR other than that it updates the devicetree binding that it depends on? I don't think I can remove that, unless #21203 is merged first and then this is rebased on it.

Sure.

label = "LSM6DSL_SPI";
};
};
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/disco_l475_iot1/disco_l475_iot1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
lsm6dsl@6a {
compatible = "st,lsm6dsl";
reg = <0x6a>;
irq-gpios = <&gpiod 11 0>;
irq-gpios = <&gpiod 11 GPIO_ACTIVE_HIGH>;
label = "LSM6DSL";
};

Expand Down
2 changes: 1 addition & 1 deletion boards/shields/x_nucleo_iks01a2/x_nucleo_iks01a2.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
compatible = "st,lsm6dsl";
reg = <0x6b>;
label = "LSM6DSL";
irq-gpios = <&arduino_header 10 0>; /* D4 */
irq-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */
};

lsm303agr-magn@1e {
Expand Down
45 changes: 32 additions & 13 deletions drivers/sensor/lsm6dsl/lsm6dsl_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@

LOG_MODULE_DECLARE(LSM6DSL, CONFIG_SENSOR_LOG_LEVEL);

static inline void setup_irq(struct lsm6dsl_data *drv_data,
bool enable)
{
unsigned int flags = enable
? GPIO_INT_EDGE_TO_ACTIVE
: GPIO_INT_DISABLE;

gpio_pin_interrupt_configure(drv_data->gpio,
DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN,
flags);
}

static inline void handle_irq(struct lsm6dsl_data *drv_data)
{
setup_irq(drv_data, false);

#if defined(CONFIG_LSM6DSL_TRIGGER_OWN_THREAD)
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_LSM6DSL_TRIGGER_GLOBAL_THREAD)
k_work_submit(&drv_data->work);
#endif
}

int lsm6dsl_trigger_set(struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler)
Expand All @@ -23,7 +46,7 @@ int lsm6dsl_trigger_set(struct device *dev,

__ASSERT_NO_MSG(trig->type == SENSOR_TRIG_DATA_READY);

gpio_pin_disable_callback(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN);
setup_irq(drv_data, false);

drv_data->data_ready_handler = handler;
if (handler == NULL) {
Expand All @@ -32,7 +55,10 @@ int lsm6dsl_trigger_set(struct device *dev,

drv_data->data_ready_trigger = *trig;

gpio_pin_enable_callback(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN);
setup_irq(drv_data, true);
if (gpio_pin_get(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN) > 0) {
handle_irq(drv_data);
}

return 0;
}
Expand All @@ -45,13 +71,7 @@ static void lsm6dsl_gpio_callback(struct device *dev,

ARG_UNUSED(pins);

gpio_pin_disable_callback(dev, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN);

#if defined(CONFIG_LSM6DSL_TRIGGER_OWN_THREAD)
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_LSM6DSL_TRIGGER_GLOBAL_THREAD)
k_work_submit(&drv_data->work);
#endif
handle_irq(drv_data);
}

static void lsm6dsl_thread_cb(void *arg)
Expand All @@ -64,7 +84,7 @@ static void lsm6dsl_thread_cb(void *arg)
&drv_data->data_ready_trigger);
}

gpio_pin_enable_callback(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN);
setup_irq(drv_data, true);
}

#ifdef CONFIG_LSM6DSL_TRIGGER_OWN_THREAD
Expand Down Expand Up @@ -105,8 +125,7 @@ int lsm6dsl_init_interrupt(struct device *dev)
}

gpio_pin_configure(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN,
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
GPIO_INPUT | DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_FLAGS);

gpio_init_callback(&drv_data->gpio_cb,
lsm6dsl_gpio_callback,
Expand Down Expand Up @@ -141,7 +160,7 @@ int lsm6dsl_init_interrupt(struct device *dev)
drv_data->dev = dev;
#endif

gpio_pin_enable_callback(drv_data->gpio, DT_INST_0_ST_LSM6DSL_IRQ_GPIOS_PIN);
setup_irq(drv_data, true);

return 0;
}
1 change: 1 addition & 0 deletions dts/bindings/sensor/st,lsm6dsl-i2c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ include: i2c-device.yaml

properties:
irq-gpios:
# This signal is active high when produced by the sensor
type: phandle-array
required: false
1 change: 1 addition & 0 deletions dts/bindings/sensor/st,lsm6dsl-spi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ include: spi-device.yaml

properties:
irq-gpios:
# This signal is active high when produced by the sensor
type: phandle-array
required: false
11 changes: 11 additions & 0 deletions samples/sensor/lsm6dsl/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ Building on disco_l475_iot1 board
:goals: build
:compact:

Building on nrf52840_pca10056 board with x-nucleo-iks01a2 shield
================================================================

.. zephyr-app-commands::
:zephyr-app: samples/sensor/lsm6dsl
:host-os: unix
:board: nrf52840_pca10056
:shield: x_nucleo_iks01a2
:goals: build
:compact:

Sample Output
=============

Expand Down