HTS221 driver: Modify to use new interrupt parameter passing hooks.

This commit is contained in:
Gregory Nutt 2017-03-31 05:31:35 -06:00
parent c5d55c62f4
commit 916bd8a48f
2 changed files with 10 additions and 11 deletions

View File

@ -174,8 +174,6 @@ static const struct file_operations g_humidityops =
#endif
};
static struct hts221_dev_s *g_humid_data;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -1069,13 +1067,14 @@ out:
static int hts221_int_handler(int irq, FAR void *context, FAR void *arg)
{
if (!g_humid_data)
return OK;
FAR struct hts221_dev_s *priv = (FAR struct hts221_dev_s *)arg;
g_humid_data->int_pending = true;
DEBUGASSERT(priv != NULL);
priv->int_pending = true;
hts221_dbg("Hts221 interrupt\n");
#ifndef CONFIG_DISABLE_POLL
hts221_notify(g_humid_data);
hts221_notify(priv);
#endif
return OK;
@ -1095,7 +1094,6 @@ int hts221_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
return -ENOMEM;
}
g_humid_data = priv;
priv->addr = addr;
priv->i2c = i2c;
priv->config = config;
@ -1125,7 +1123,7 @@ int hts221_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
priv->config->irq_clear(priv->config);
}
priv->config->irq_attach(priv->config, hts221_int_handler);
priv->config->irq_attach(priv->config, hts221_int_handler, priv);
priv->config->irq_enable(priv->config, false);
return OK;
}

View File

@ -117,10 +117,11 @@ typedef struct hts221_settings_s
typedef struct hts221_config_s
{
int irq;
CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr);
CODE void (*irq_enable)(FAR const struct hts221_config_s * state,
CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr,
FAR void *arg);
CODE void (*irq_enable)(FAR const struct hts221_config_s *state,
bool enable);
CODE void (*irq_clear)(FAR const struct hts221_config_s * state);
CODE void (*irq_clear)(FAR const struct hts221_config_s *state);
CODE int (*set_power)(FAR const struct hts221_config_s *state, bool on);
} hts221_config_t;