drivers/sensor: iis2iclx: (FIX) enable interrupt selectively
(same considerations as commit 2f01479b
)
In a multi-instance driver it may happen that on some h/w
one device should use interrupts and a second device should use
polling mode. So, CONFIG_IIS2ICLX_TRIGGER is not enough to discriminmate
if interrupt inizialization routine should be called or not; the choice
is now based whether the "irq-gpios" property is present in the DT
for that particular instance or not.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
1f851bc268
commit
468c553190
|
@ -587,6 +587,9 @@ static int iis2iclx_init_chip(const struct device *dev)
|
|||
|
||||
static int iis2iclx_init(const struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_IIS2ICLX_TRIGGER
|
||||
const struct iis2iclx_config *cfg = dev->config;
|
||||
#endif
|
||||
struct iis2iclx_data *data = dev->data;
|
||||
|
||||
LOG_INF("Initialize device %s", dev->name);
|
||||
|
@ -597,9 +600,11 @@ static int iis2iclx_init(const struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_IIS2ICLX_TRIGGER
|
||||
if (iis2iclx_init_interrupt(dev) < 0) {
|
||||
LOG_ERR("Failed to initialize interrupt.");
|
||||
return -EIO;
|
||||
if (cfg->trig_enabled) {
|
||||
if (iis2iclx_init_interrupt(dev) < 0) {
|
||||
LOG_ERR("Failed to initialize interrupt.");
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -639,7 +644,8 @@ static int iis2iclx_init(const struct device *dev)
|
|||
|
||||
#ifdef CONFIG_IIS2ICLX_TRIGGER
|
||||
#define IIS2ICLX_CFG_IRQ(inst) \
|
||||
.gpio_drdy = GPIO_DT_SPEC_INST_GET(inst, drdy_gpios), \
|
||||
.trig_enabled = true, \
|
||||
.gpio_drdy = GPIO_DT_SPEC_INST_GET(inst, drdy_gpios), \
|
||||
.int_pin = DT_INST_PROP(inst, int_pin)
|
||||
#else
|
||||
#define IIS2ICLX_CFG_IRQ(inst)
|
||||
|
|
|
@ -49,6 +49,7 @@ struct iis2iclx_config {
|
|||
uint8_t odr;
|
||||
uint8_t range;
|
||||
#ifdef CONFIG_IIS2ICLX_TRIGGER
|
||||
bool trig_enabled;
|
||||
uint8_t int_pin;
|
||||
const struct gpio_dt_spec gpio_drdy;
|
||||
#endif /* CONFIG_IIS2ICLX_TRIGGER */
|
||||
|
|
|
@ -91,8 +91,14 @@ int iis2iclx_trigger_set(const struct device *dev,
|
|||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler)
|
||||
{
|
||||
const struct iis2iclx_config *cfg = dev->config;
|
||||
struct iis2iclx_data *iis2iclx = dev->data;
|
||||
|
||||
if (!cfg->trig_enabled) {
|
||||
LOG_ERR("trigger_set op not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (trig->chan == SENSOR_CHAN_ACCEL_XYZ) {
|
||||
iis2iclx->handler_drdy_acc = handler;
|
||||
if (handler) {
|
||||
|
|
Loading…
Reference in New Issue